MATLAB: How to find large curvature location

curveMATLAB

i want to detect the curve point in the lines the lines themselves not straight

Best Answer

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