How to create MASK from "image.tiff"?

4 views (last 30 days)
Hi Everybody,
I tried to MASK the shapefile of my study area but the matrix of the MASK is only NaN data. so please I need your help. I have attached the script_MASK.
Thank you in advance.
Reyadh

Accepted Answer

Image Analyst
Image Analyst on 3 May 2016
What are the values of your tiff file? It's probably in the range 0-255 so most values will be set to nan because you set all values more than 1 to nan. You might want to set the to nan only if they're outside the range 0-255, or use im2double() to change the range of your image from 0-255 to 0-1.
  3 Comments
Image Analyst
Image Analyst on 3 May 2016
If you pass an array into mat2gray() it will scale it to the 0-1 range.
reyadh Albarakat
reyadh Albarakat on 3 May 2016
Thank you so much
I have question I want to save the output images.tiff in same name of the original images. suppose the names of files are 1981_07_15.n07-VI3g and 1981_07_16.n07-VI3g respectively SO how can I save outputs in same names of inputs.
Thank you
Reyadh
if true
for i=1:length(Ii)
set(0,'DefaultFigureRenderer','zbuffer')
[Plg,Plt]=meshgrid(lg,lt);
LATLIMS=[30.952 32.01];
LONLIMS=[47.09 47.818];
m_proj('Equidistant Cylindrical','lon',LONLIMS,'lat',LATLIMS);
img=Ii{i}.*MASK;
map=m_pcolor(Plg,Plt,img);
a=colormap(jet);
% a=fliplr(a);
set(gcf,'colormap',a);
shading flat;
m_grid('linewi',2,'tickdir','out');
str=num2str(i);
saveas(map,str,'tif');
end

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!