MATLAB: Processing tiff file in matlab and save it again as tiff file

satellite imagetiff

I have a tiff satellite image ı want to make some calculations with it and ı want to save it as a tiff file again how can I do this ?

Best Answer

There is more than one way that you can save multiple images in a .tif . The following code works with one of the common ways:
in_filename = '200301.tif';
imgcount = 0;
saved_images = {};
while true
nextimg = imgcount + 1;
try
t = imread(in_filename, 'Index', nextimg);
imgcount = nextimg;
saved_images{imgcount} = t;
catch
break; %end of tiff
end
end
Now manipulate the contents that are in the cell array saved_images, producing new_images
Afterwards,
out_filename = '200301_processed.tif';
imwrite(new_images{1}, out_filename);
for K = 2 : length(new_images)
imwrite(new_images{K}, out_filename, 'WriteMode', 'append');
end