问题
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