Matlab, How to get the result generated by imagesc?

旧时模样 提交于 2019-12-12 15:57:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!