Filter löschen
Filter löschen

Calculate the length of an object in image

6 Ansichten (letzte 30 Tage)
Adele Campus
Adele Campus am 17 Mai 2023
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

Akzeptierte Antwort

Antoni Garcia-Herreros
Antoni Garcia-Herreros am 17 Mai 2023
Bearbeitet: Antoni Garcia-Herreros am 17 Mai 2023
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 Kommentare
Adele Campus
Adele Campus am 18 Mai 2023
Thank you very much, the resulting distance is in pixel?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Seismology finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by