How to save Index Values of an Image by imagesc
1 回表示 (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (2 件)
Walter Roberson
2012 年 12 月 10 日
See the FEX contribution "freezeColors" to see how they do it.
3 件のコメント
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
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 件のコメント
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!