how can I find the coordinates of the central axis of a river in an image (binary)?

조회 수: 1 (최근 30일)
I am trying to find a vector that contains the midpoint or talweg of an image of the Valdivia River (Chile) To do this I am using a code that I found on this page, I attached it. The problem is that with the example there is no problem, but when changing to my image I get an error. help!!
CON REMOVE.png
the "1.png" image can be downloaded from the link.
clc
clear all
a=imread('1.png');
imshow(a);
impixelinfo
b=im2bw(a);
figure,imshow(b)
imfinfo('1.png')
impixelinfo
E = edge(b);
figure;imshow(E)
c=imcomplement(E);
figure,imshow(c)
impixelinfo
[col row]=size(c);
k=1;
count=1;
for i=1:col
for j=1:row
if c(i,j)==0
[j i]
if i==i
z(k)=j
k=k+1;
g=i;
end
count=count+1;
end
end
k=1;
if (z(2)-z(1))>2
av=(z(1)+z(2))/2;
hold on
plot(av,g,'.')
else
av=(z(1)+z(3))/2;
hold on
plot(av,g,'.k')
end
end

채택된 답변

Matt J
Matt J 2019년 11월 11일
편집: Matt J 2019년 11월 11일
load River
C=watershed(bwdist(A))==0;
[icoords,jcoords]=find(C); %coordinates of center line
imshow(A+C)
  댓글 수: 3
Matt J
Matt J 2019년 11월 11일
It's just a cropping of the image in the original post.
Hernán Madrid Oyarzún
Hernán Madrid Oyarzún 2019년 11월 25일
thanks, works perfectly and it´s very simple,
Now i´m trying to find the coordinates of the north or south banks to can find the width of every point of the line detected by this process. if you can help me I would appreciate it a lot.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by