How to save Index Values of an Image by imagesc

4 ビュー (過去 30 日間)
Manuel
Manuel 2012 年 12 月 10 日
Hello:
I am using the Imagesc command to display a matrix. Once obtained the image I can get the intensity value of a position by using Data Cursor. I attach this picture, where you can see the output of my program.
However it only works by clicking on the picture. I would like to save the intensity values of all the image in order to calculate the intensity average value. In the previous picture, the value I mean is called by Index.
Thank you in advance, Manuel

回答 (2 件)

Walter Roberson
Walter Roberson 2012 年 12 月 10 日
See the FEX contribution "freezeColors" to see how they do it.
  3 件のコメント
Walter Roberson
Walter Roberson 2012 年 12 月 10 日
get() the CData of the image after freezing it.
Sean de Wolski
Sean de Wolski 2012 年 12 月 10 日
And use the result of getting the CData to index into the colormap (obtained from cmap = colormap; )

サインインしてコメントする。


Image Analyst
Image Analyst 2012 年 12 月 10 日
Is this an indexed image with a colormap? Why can't you just convert the indexed image to rgb and then use imwrite to save it to disk, if you want it saved to disk?
rgbImage = ind2rgb(indexedImage, colormap);
imwrite(rgbImage, fullFileName);
If you want to see the values without clicking on the image, then call the *impixelinfo(*) function. It will put the same information into a status label, which you can position wherever you want on your gui.
  4 件のコメント
Manuel
Manuel 2012 年 12 月 10 日
編集済み: Manuel 2012 年 12 月 10 日
Hi!
Really thank you for your support and time.
I suppose mine is an indexed image due to the fact that I create it using imagesc(), and colormap ('jet'). If I save the figure using saveas(figure.tif) or using imwrite(X,jet,figure.tif), I managed a matrix nxmx3 (3 because of the RGB), but I had to convert the rgb matrix to an index matrix and I didn't know how to do it.
My program is intended to calculate and compare how "dark" two pictures are. For that, I'm trying to obtain the average Index (according to the name given at "Data Cursor") of each picture. Until now, I have saved to disk each image, converted them into greyscale, calculate its average greyscale color and compare them. However it is not working for my purpose, I need to do it with the paremeter called "Index", not with the greyscale.
On the other hand, the third input that I introduce in the call of imagesc is a number which I suppose Imagesc "scales" to the colormap I ask in colormap('map').
Cheers!
Image Analyst
Image Analyst 2012 年 12 月 10 日
Wow. I'm even more confused. OK, you have gray scale (indexed) images, not true color images. And you applied a pseudocolor look up table ("colormap") to them. OK, you saved them with saveas() and imwrite() and got a color image. OK, fine if that's what you want. But then you say you need to convert that back to the indexed image? Why???? You already had the indexed image when you displayed it and before you saved it to disk. That was the original image - if you use saveas you'll get the whole figure (buttons, tick marks, etc.). Why do you need the whole figure as an indexed image? It just doesn't make sense.
What is the "average index"? Averaged over what? What area are you taking the average over? A 3 by 3 window? The whole image? What? Then you say you saved the figure image to disk and converted it to grayscale. Why? Again, you already had the image, no need to save the whole figure, read it back in, convert it to grayscale, and get it's average. Doesn't make sense. Remember if you saved the figure you're getting much more than just your image.
Then you say "I need to do it with the paremeter called "Index", not with the greyscale." You don't seem to realize that they're the same thing. An indexed image is simply a grayscale image that is confined to integer levels and has an associated color map. If it doesn't have a colormap then it's just a gray scale image or an indexed image that has the "gray" colormap by default. For uint8 monochrome images, there is no difference between a gray level image and an indexed images. Now you could have a grayscale image that takes on fractional, floating point values - that would not be able to be considered as an indexed image because the values are not integers. I hope that explains it better.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by