how to find large curvature location

7 次查看(过去 30 天)
i want to detect the curve point in the lines the lines themselves not straight

采纳的回答

John BG
John BG 2018-3-2
编辑:John BG 2018-3-3
Hi Michael
There's an easy way to encircle the points you want, with a high degree of accuracy.
The areas of the image you want to spot are inflection points with change of derivative sign: geometric vertices.
If we look for high degree of Curvature only, it has to do with the radius only, and very small circles would give false detections.
You are precisely asking for a sudden change of sign of the direction of the trace.
1.
Image acquisition:
I tried with your original image, that includes a grey trace, but it complicates the processing.
Allow me to show a solution for black traces only:
clear all;clc;close all
A=imread('011.jpg');
.
.
sz1=size(A,1);
sz2=size(A,2);
hf1=figure(1);imshow(A);
ax1=hf1.CurrentAxes;
cp1=campos;
.
do not apply imbinarize here, it removes the grey line
% A2=imbinarize(A1)
% th1=200;
% A(A>th1)=255;
% A(A<=th1)=0;
% A=255-A;
% figure(2);imshow(A)
2.-
The 2D variance of the images points straight to the areas of interest
D=var(double(A),0,3);
hf=figure(3);hs=surf(D);
hs.EdgeColor='none';
hs.FaceAlpha=.5;
ax=hf.CurrentAxes;
ax.DataAspectRatio=[50 50 1];
ax.CameraPosition= [cp1(1) cp1(2) -cp1(3)];
3.-
Now with Natan's function FastPeakFind
the coordinates of a 2D surface are readily available, note that the supplied coordinates are interleaved.
p=FastPeakFind(D)
pxy=[p(2:2:end) p(1:2:end)]; % deinterleave peaks coordinates
hold(ax1,'on');plot(ax1,p(1:2:end),p(2:2:end),'r+') % variance peaks
[idx,C] = kmeans(pxy,4);
hold all;viscircles(ax1, flip(uint32(C),2),10*ones(1,4),'Color','green')
.
.
Michael
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
John BG
  2 个评论
michael scheinfeild
finaly i just use somthing more simple i look for edges curve i take the angle between the vectors
if true
dataxy=[jx iy];
vec20a=[dataxy(end-60,:) ;dataxy(end-40,:)];
vec20b=[dataxy(end-40,:) ;dataxy(end-20,:)];
vec20c=[dataxy(end-20,:) ;dataxy(end,:)];
angle20b = rad2deg(getVecAngle(vec20a,vec20b))
angle20 = rad2deg(getVecAngle(vec20b,vec20c))
function [angleRadVec]=getVecAngle(vec1,vec2) % vector M*2 %line(vec1(:,1),vec1(:,2)) %line(vec2(:,1),vec2(:,2),'Color','c') z1=[diff(vec1)]; z2=[diff(vec2)];
n=size(z1,1);
for(k=1:n) ua=z1(k,:); ub=z2(k,:); angleRadVec(k)=acos(dot(ua,ub)/(norm(ua)*norm(ub)));
end
end
John BG
John BG 2018-3-3
Hi Michael
I was also considering the approach of focusing on the white points only, after obtaining the skeleton, so I did the following:
clear all;clc;close all
A=imread('010.jpg');
figure(1);imshow(A);
% cp1=campos;
th1=200;
A(A>th1)=255;
A(A<=th1)=0;
A=255-A;
figure(2);imshow(A)
A1=A(:,:,1); % just one layer
A2=imbinarize(A1) ;
A3 = bwmorph(A2,'skel',Inf);
figure(3);imshow(A3)
[n1,n2,v]=find(A3==1);
but there are 3 problems:
1.-
there is no longer sharp derivative sign, the sudden way-backs all look like a small radius but more a turn than a 180º sharp thrust inversion.
2.-
right on 2 sharp bents, the 2 on the left hand side, with black ink, now show a short shoot each that is not supposed to be there, but bwmorph shrinks these trace around the points of interest in a way that an apparent bifurcation is added, that doesn't really exist.
3.-
the top left trace now has again a short shoot that looks like as if there's a three way intersection.
.
.
I have also had a look into the change of sign of the derivatives of the variance:
A4=del2(double(A(:,:,1)+A(:,:,2)+A(:,:,3)));
figure(4);imshow(A4);
W1=var(A4,0,1);
figure;plot(W1)
figure;plot(diff(W1.*W1))
W2=var(A4,0,2);
figure;plot(diff(W2.*W2))
W2=var(A4,0,2);
V=diff(W2.*W2);
nV=[1:1:numel(V)];
figure;plot(-V([end:-1:1]),nV);
.
.
The overlaps get solved if isolating each trace.
John BG

请先登录,再进行评论。

更多回答(1 个)

michael scheinfeild
编辑:michael scheinfeild 2018-3-3
the file is there https://www.mathworks.com/matlabcentral/fileexchange/37388-fast-2d-peak-finder

类别

Help CenterFile Exchange 中查找有关 Environment and Clutter 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by