How do I resample my 3 bands data?
2 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (1 件)
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!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!