how to find large curvature location

조회 수: 8(최근 30일)
michael scheinfeild 2018년 3월 2일
댓글: John BG 2018년 3월 3일
i want to detect the curve point in the lines the lines themselves not straight

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

채택된 답변

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
.
.
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
John BG
댓글 수: 2표시숨기기 이전 댓글 수: 1
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
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 2018년 3월 3일
편집: michael scheinfeild 2018년 3월 3일
the file is there https://www.mathworks.com/matlabcentral/fileexchange/37388-fast-2d-peak-finder

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

범주

Find more on Surface and Mesh Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by