How to Get Index Values of an Image by imagesc

19 views (last 30 days)
Hi everyone,
I have a matrix that includes complex values. I am using imagesc to see the output. I can see the index values by using data cursor but How can I assign and get index values of that output ?
Thanks BR Hans
  2 Comments
Manuel
Manuel on 10 Dec 2012
Edited: Manuel on 10 Dec 2012
Hello:
I also need the intensity values but not only the max of the picture, but also all of them, in order to save this values into a matrix and to calculate the intensity average value.
Thank you in advance, Manuel
Image Analyst
Image Analyst on 10 Dec 2012
You already have the values, or else you would not have been able to display anything. meanIntensity = mean(yourImage(:)). Why don't you start your own thread to discuss further?

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 21 Aug 2012
What is "the output" - is that the same as "matrix" or is it different? And imagesc doesn't work with complex images. Can you explain how you got it to work? Also I don't know what you mean by index. If you use impixelinfo you can see the x (column) and y (row) and the value (gray level). And there is also some funky colormap applied to the image, which you can retrieve. But I don't know which of these several numbers you call "index". Do you mean like the index into a colormap (i.e. the intensity value), or the linear index of the image (i.e. the pixel location), or something else. And I don't know what you want to do when you say you want to "assign" and "get" the indexes. Why do you need to both set and get these values (whatever they are)?
% Generate some sample complex image.
realPart = rand(300);
imaginaryPart = i * rand(300);
complexImage = realPart + imaginaryPart;
% Try to display complex image - won't work.
% imagesc(complexImage); % Does not work.
% Display the real part only.
imagesc(realPart);
% Set up where it will show x, y, and value in status line.
impixelinfo;
% Get the current colormap
cmap = colormap
  3 Comments
Image Analyst
Image Analyst on 21 Aug 2012
How about if you use ginput() go get an x,y coordinate and then just assign your parameter like this:
% Find the value where the user clicks.
uiwait(msgbox('Click a point'));
[x y] = ginput(1);
row = int32(y)
column = int32(x)
a = realPart(row, column);
b = i * imaginaryPart(row, column);
theParameter = a + i * b
Or find the max over the entire image, if you don't want them to click anywhere.
% Find the location of the max intensity value
% of the real part over the entire image.
[row column] = find(realPart == max(realPart(:)), 1, 'first')
aMax = realPart(row, column);
bMax = i * imaginaryPart(row, column);
theParameterFromTheMax = aMax + i * bMax
HANS
HANS on 22 Aug 2012
I appreciated your help. :] Thanks a lot. It does.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 20 Aug 2012
See the File Exchange contribution "freezeColors"
  3 Comments
Walter Roberson
Walter Roberson on 21 Aug 2012
The mapping done by freezeColors is not very complex; you can extract the ideas and implement them in a few lines.
HANS
HANS on 22 Aug 2012
Thanks a lot. I will try. It is sure that it helps.

Sign in to comment.

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!