I am working on TIFF files to produce the median matrix for them, I am using the following Matlab code for that. How I can make the output as .tif while keeping the coordinate reference system (CRS)?

unzip Test3.zip
% Warning: Cannot open file "" for reading.
files = dir('*.tif');
filenames = fullfile({files.folder},{files.name});
N = numel(files);
sz = zeros(N,2);
for ii = 1:N
    files(ii).data = imread(filenames{ii});
    sz(ii,:) = size(files(ii).data);
datablock = cat(3, files.data);
image_median = median(datablock, 3, 'omitnan');
[min(image_median(:)), max(image_median(:))]

link to subsample of the data https://www.dropbox.com/scl/fi/u7ysb91awhih29ery4txa/Test3.zip?rlkey=7eh80xf0rshh445vhyv0w0pne&dl=0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.