필터 지우기
필터 지우기

Calculate the length of an object in image

조회 수: 6 (최근 30일)
Adele Campus
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

채택된 답변

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 CenterFile Exchange에서 Seismology에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by