Calculate the length of an object in image
6 ビュー (過去 30 日間)
古いコメントを表示
Adele Campus
2023 年 5 月 17 日
コメント済み: Antoni Garcia-Herreros
2023 年 5 月 18 日
Hi everyone,
I need some help in calculating the length of an object from a defined starting point.
I'm analising satellite images for volcanic purposes, so I have the position (in terms of lat and lon) of my starting point. My final goal is to calculate the max distance traveled by a lava flow, which can creates different morpholigies, including curves or ingent lava fields.
I can identify which pixels of the image are related to the lava flow, but I need to create a script that calculate the maximum distance it reached. Currently I'm trying to work with binary images, also trying to explore the bwskel function, but didn't find a solution yet.
Here my matrices and variables: LAT and LON are the latitude and longitude matrices related to the LavaField_example matrices, that is a Logical matrix with 1 for the pixels occupied by lava. This is a real example derived by satellite images acquired during the eruption of Piton de la Fournaise in Sep-Oct 2022, I need the max lenght of the main lava field (the other small cluster must be excluded).
starting pixel
LATstart: -21.2429
LONstart: 55.7092
index (in the LavaField matrix): 9046
0 件のコメント
採用された回答
Antoni Garcia-Herreros
2023 年 5 月 17 日
編集済み: Antoni Garcia-Herreros
2023 年 5 月 17 日
Hello Adele,
load('LavaField_example.mat')
thr=10; % Threshold to filter small lava regions
%% Max length of the whole lava field
r=regionprops('table',BWcumL,'Area','MaxFeretProperties');
r=r(r.Area>thr,:); % Retain only the large lava regions
r.MaxFeretDiameter % Max length of the main lava field
% Max distance the lava has flown from the center of the crater
B = bwboundaries(BWcumL);
Bpoints=B{1,1};
[xi,yi]=ind2sub([134,134],9046) % Position of the crater
D=pdist2(Bpoints,[xi,yi]); % Distance from the crater to the boundary
[MAX_FLOWN_DIST,n]=max(D);
% Plot
imshow(BWcumL)
hold on
A=r.MaxFeretCoordinates{1}; % Coordinates of the start-end point
plot(A(:,1),A(:,2),'-r')
plot(xi,yi,'o')
plot([Bpoints(n,2) xi],[Bpoints(n,1) yi])
l=legend({'MAX lava field length', 'Crater','Max lava field length from the crater'});
Hope this helps!
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!