How do I resample my 3 bands data?

2 ビュー (過去 30 日間)
Devendra
Devendra 2024 年 4 月 20 日
編集済み: Walter Roberson 2024 年 4 月 20 日
I am using following matlab lines to resample my 3 bands of 10m resolution to next 3 bands of 20m resolution. But it is not being executed
if ismember(files(i + j).name, {'T43RGN_*_B03_10m.jp2',...
'T43RGN_*_B04_10m.jp2', 'T43RGN_*_B08_10m.jp2'})
img = imresize(img, 0.5, 'Method', 'bilinear');
end
names of image files with bands are as follow;
T43RGN_20210119T053141_B03_10m.jp2
T43RGN_20210119T053141_B04_10m.jp2
T43RGN_20210119T053141_B05_20m.jp2
T43RGN_20210119T053141_B06_20m.jp2
T43RGN_20210119T053141_B07_20m.jp2
T43RGN_20210119T053141_B08_10m.jp2
Please suggest how to execute above mentioned code to resample three 10m resolution to 20m resolution. I will appreciate your kind cooperation.
Deva

回答 (1 件)

Rishi
Rishi 2024 年 4 月 20 日
Hi Devendra,
I understand that you want to know why you are unable to get the desired result from the given code snippet.
This is because of the usage of 'ismember' function with wildcards ('*'). The 'ismember' function checks for exact matches from the provided list of names, and it does not interpret the wildcard ('*') as 'any characters'.
To achieve the functionality you're looking for, you can use regular expressions to identify files that match your pattern. For this, you can use 'regexp' function. The given code shows how to use it:
filename = files(i + j).name;
% Regular expression to match the filenames
pattern = 'T43RGN_.*_(B03|B04|B08)_10m.jp2';
if ~isempty(regexp(filename, pattern, 'once'))
img = imresize(img, 0.5, 'Method', 'bilinear');
end
You can learn more about the 'regexp' function from the below documentation:
Hope this helps!

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by