Assign different color to NaN values in Matlab images

谁都会走 提交于 2019-12-13 05:23:59

问题


I am working with satellite images on Matlab and am writing a code for calculating Net Radiation. The output contains the image in form of a matrix with NaN values. When I try to plot it using:

figure
imshow(X);

it assigns the NaN values the same color as 0. Is there any way I can assign those values to be a different color?

Also, I want to save my matrix as an image, but in a format that its values don't get changed ... possibly ASCII. Is there a tool for converting matrix to ASCII?


回答1:


If your X matrix, is a 2D matrix with values between 0 and 1 and NaN values, you can use the following command to change NaN values to for example 0.88.

X(isnan(X))=0.88;

but if the X matrix is 3D (for RGB) the answer is slightly different and this solution does not work.



来源:https://stackoverflow.com/questions/33320015/assign-different-color-to-nan-values-in-matlab-images

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