필터 지우기
필터 지우기

How to make all the .tif files with the same size?

조회 수: 2 (최근 30일)
Rafat
Rafat 2023년 11월 6일
편집: Rafat 2023년 11월 6일
Hello,
My .tif files are not all the same size [m x n], i.e., some are 87x207 pixels, some are 88x207 pixels, some are 88x208 pixels, and some are 87x208 pixels. I cc'd subsample of the tif files, and the code to check the size for them.
I want to cut the number of rows above the minimum m, and delete the number of columns above the minimum n, i.e., I want all of them be in 87x207 pixels size without damaging the geographical information in them. Is that possible?
unzip Test.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);
end
disp(sz)

채택된 답변

Voss
Voss 2023년 11월 6일
편집: Voss 2023년 11월 6일
min_sz = min(sz,[],1);
for ii = 1:N
files(ii).data = files(ii).data(1:min_sz(1),1:min_sz(2));
end
  댓글 수: 3
Voss
Voss 2023년 11월 6일
You got it. Sorry about the typo; typing code on the phone can be difficult.
Rafat
Rafat 2023년 11월 6일
편집: Rafat 2023년 11월 6일
Don't be sorry my friend, it's ok!!. Cheers

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by