Tangent line to the edge of binary image
11 次查看(过去 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!