Calculate the length of an object in image

6 ビュー (過去 30 日間)
Adele Campus
Adele Campus 2023 年 5 月 17 日
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

採用された回答

Antoni Garcia-Herreros
Antoni Garcia-Herreros 2023 年 5 月 17 日
編集済み: Antoni Garcia-Herreros 2023 年 5 月 17 日
Hello Adele,
You could try using the function regionprops and the property MaxFeretDiameter.
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
ans = 18.7883
% 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
xi = 68
yi = 68
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!
  2 件のコメント
Adele Campus
Adele Campus 2023 年 5 月 18 日
Thank you very much, the resulting distance is in pixel?
Antoni Garcia-Herreros
Antoni Garcia-Herreros 2023 年 5 月 18 日
Yes!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeometric Geodesy についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by