필터 지우기
필터 지우기

Distinct NaN from other values in image

조회 수: 13 (최근 30일)
Agnete
Agnete 2013년 11월 20일
댓글: Dev Laxman Subramanian 2021년 2월 4일
I want to plot image with different values and easily distinct them from NaN values. As default NaN values are imaged with the same color as the minimum value. I have tried a range of possibilites but each provide their own issue. Here is one example:
The solution from here, image all other values as one color
imagesc(CP)
sc(isnan(CP), 'bone', [1 1 1]);
  댓글 수: 3
Image Analyst
Image Analyst 2013년 11월 25일
The answer has been accepted. I don't see a question in the last comment. And no m-file was attached.
Oliver Woodford
Oliver Woodford 2014년 1월 2일
You did not use sc correctly. Try:
sc(CP, 'bone', 'r')

댓글을 달려면 로그인하십시오.

채택된 답변

Iain
Iain 2013년 11월 21일
This can let you plot NaN & any other logically findable section of the image as white
a = rand(5);
a(3,3) = NaN;
b = imagesc(a);
set(b,'AlphaData',~isnan(a))
Alternatively, you can deliberately control the "colormap" settings to ensure that "invalid" values show up as a colour that isn't used by the colour map.
  댓글 수: 3
Andrea
Andrea 2017년 12월 29일
changed my life
Dev Laxman Subramanian
Dev Laxman Subramanian 2021년 2월 4일
Works like a charm!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2013년 11월 20일
I don't know what "plot" means when talking about an image. I don't know why you want to plot anything on an image, like markers to "cover up" the nan locations. Why not just set the nan's to the min gray level and view it like a normal image?
CP(isnan(CP)) = min(CP(:)); % Set nan values to the min value
image(CP);
colormap(bone(256));
colorbar;
  댓글 수: 3
Agnete
Agnete 2013년 11월 21일
The problem is illustrated in the attached where it is seen that the polygon in northeast corner blends into the background
Image Analyst
Image Analyst 2013년 11월 22일
Sorry but I don't understand this. One just sort of looks like a very blurred version of the other. Both have the same pattern of triangles on them, and I don't even know what a triangle means/represents. Your image is an array. You can't have nan values have the same value as your minimum value. An element can have only one value, either a nan or some number. It can't have both at the same time. So "Nan values are imaged with the same color as my minimum value" makes no sense to me.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by