matlab nan 无色_在Matlab图像中为NaN值分配不同的颜色
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:figurei
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?
解决方案
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.
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)