问题
I read some similar article, but they are not what I want.
Get the matrix after imagesc?
imagesc plot to matrix in matlab
My Problem
I have a matrix A
with all elements are double.
I do imagesc(A)
and then I have an image.
Now, I want to get the matrix that make the image. How can I do that?
From those articles, if I do
I = imagesc(A)
B = get(I, 'CData')
Then B == A
that is not what I want.
回答1:
To scale the image in the same way as imagesc do the following
Amin = min(A(:));
Amax = max(A(:));
A_scaled = (A - Amin)/(Amax - Amin);
To prove that the scaled image is what imagesc does internally then try this
imagesc(A,[Amin Amax]);
pause
imagesc(A_scaled);
回答2:
It can be done in a simpler way. I tried my code in Octave.
colormap gray;
h=imshow(F,[]);
B=get(h, 'CData');
来源:https://stackoverflow.com/questions/18251044/matlab-how-to-get-the-result-generated-by-imagesc