How to filter out NaNs on images ?

조회 수: 2 (최근 30일)
V.D-C
V.D-C 2020년 2월 10일
댓글: V.D-C 2020년 2월 11일
Hello everybody,
I would like to create a map where I can assign a brownish color to the areas inside the black contour lines (land). But, I also want to display another layer (the colored one on the figure below) on top of it. The issue is that this additionnal layer has NaNs covering the land and the sea, making all the background look blue.
How can I differentiate the colour of the sea and the land, while having this additionnal layer we see below ?
I thought of one way: I could make all the NaNs from this layer be transparent, so the background land would reappeare. But I don't know how to do that.
Maybe there is another solution but I can't think of any.
Thank you !
Filter_NaNs.jpg
  댓글 수: 2
Subhadeep Koley
Subhadeep Koley 2020년 2월 10일
Can you provide your matrix / images / maps so that we can reproduce the issue?
V.D-C
V.D-C 2020년 2월 11일
Here you have the files (I coudn't put the black contour line but this is not really important).
To display things, I was writing:
imagesc(lat,long,Background);
axis xy;
hold on;
imagesc(lat,long,overlay_map);
And this overlay has NaNs for every value displayed in blue. I would like to make them transparent so we can see the background on the land parts.
Sorry I did not answer sooner btw, I left work.

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

채택된 답변

Subhadeep Koley
Subhadeep Koley 2020년 2월 11일
See if the below code works
clc; close all;
% Load data
load Background.mat
load lat.mat
load long.mat
load overlay_map.mat
% Plot the background image
ax1 = axes;
imagesc(ax1, lat, long, Background);
axis xy; hold on;
% Plot the foreground image
ax2 = axes;
imAlpha = ones(size(mean_map));
imAlpha(isnan(mean_map)) = 0;
imagesc(ax2, lat, long, mean_map, 'AlphaData', imAlpha);
set([ax1, ax2], 'Position', [0.17 0.11 0.7 .815]);
colorbar(ax2, 'Position', [0.9 0.11 0.025 0.815]);
axis xy; ax2.Visible = 'off'; hold off;
  댓글 수: 1
V.D-C
V.D-C 2020년 2월 11일
Thank you so so much, it works perfectly !!!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by