Tangent line to the edge of binary image
8 ビュー (過去 30 日間)
古いコメントを表示
Attached please see a binarized image of water droplets spraying out of a sprinkler.
I am trying to define a the angle between a normal line and (1) the right edge of the blob (dotted line) and left edge of the blob (dashed line). A solution that comes mind is to get rid of smaller blobs and is to extract the (x,y) values of the edges and fit a curve to each section. Can anyone suggest a better solution to me?
thanks you all :)
0 件のコメント
採用された回答
Matt J
2022 年 2 月 25 日
編集済み: Matt J
2022 年 2 月 25 日
A solution that comes mind is to get rid of smaller blobs and is to extract the (x,y) values of the edges and fit a curve to each section.
Sounds good to me.
load Image
BW0=BW;
BW=bwperim( bwconvhull(bwareaopen(BW,100)) );
[I,J]=find(BW);
[~,p]=min(I);
[~,l]=min(J);
[~,r]=max(J);
Ip=I(p); Jp=J(p);
Il=I(l); Jl=J(l);
Ir=I(r); Jr=J(r);
Ic=min(Il,Ir);
Im=round((Ip+Ic)/2);
BW(Ic:end,:)=0;
BW(1:Im,:)=0;
reg=regionprops(BW,'PixelList');
for i=1:2
x = reg(i).PixelList(:,1);
y = reg(i).PixelList(:,2);
reg(i).p=polyfit(x,y,1);
end
imshow(BW0,[]);
hold on
x1=1:Jp;
y1=polyval(reg(1).p,x1);
x2=Jp:size(BW,2);
y2=polyval(reg(2).p,x2);
plot(x1,y1,'rx')
plot(x2,y2,'rx')
hold off
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Processing and Computer Vision についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!