Tangent line to the edge of binary image

11 visualizaciones (últimos 30 días)
Tala
Tala el 25 de Feb. de 2022
Editada: Matt J el 25 de Feb. de 2022
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 :)

Respuesta aceptada

Matt J
Matt J el 25 de Feb. de 2022
Editada: Matt J el 25 de Feb. de 2022
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

Más respuestas (0)

Categorías

Más información sobre Image Processing and Computer Vision en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by