Inflection points of binary image

12 visualizaciones (últimos 30 días)
Adam Zemánek
Adam Zemánek el 30 de Abr. de 2022
Comentada: Image Analyst el 1 de Mayo de 2022
Hello all, I have a question. Is there any way, how to find inflection points of the curve in the attached binary image? I don't necessarily need an exact position of these points. All I ask is to know how many inflections this curve has. Thanks for any suggestions :)
  2 comentarios
Riccardo Scorretti
Riccardo Scorretti el 30 de Abr. de 2022
I would suggest to try something like:
  1. determine the candidate points to be inflection points
  2. use the function evalclusters to cluster these points and (most importantly) determine the optimal number of clusters.
The second step is easy to program (that doesn't mean that if will provide the correct result). As for the first point, I would suggest you to do more or less like this:
  1. find NZ = set of non-zero points
  2. for each point P in NZ, determine if it can be considered an inflexion point. If yes, add it to the set of candidates to be inflexion points.
Of course the tricky step is how to check if a point is an inflection point. Basically, you could estimate the tangent vector T to the point P. Then, if you divide the plane in 4 quadrants, with the origin in P and one axis aligned with the tangent vector T, an inflexion point leaves all the remaining points either in quadrans I and III, or II and IV :
Of course this property must hold locally only, so you must define a distance at which two points are considered as belonging to a reasonable neighborhood to check the property.
Adam Zemánek
Adam Zemánek el 30 de Abr. de 2022
Thanks for suggestion, appreciate it :)

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 30 de Abr. de 2022
Start with this and adapt as needed:
s = load('matlab.mat')
bw = s.bw;
subplot(4, 1, 1:2);
imshow(bw)
[rows, columns] = size(bw)
topRow = nan(1, columns);
for col = 1 : columns
t = find(bw(:, col), 1, 'first');
if ~isempty(t)
topRow(col) = t;
end
end
subplot(4, 1, 3);
plot(topRow, 'b-', 'LineWidth', 2)
grid on;
xlabel('Column')
ylabel('row')
% Compute second derivative
dy = diff(topRow, 2);
subplot(4, 1, 4);
plot(dy, 'b-', 'LineWidth', 2)
grid on;
xlabel('Column')
ylabel('row');
[peakValues, indexesOfPeaks, w, prominences] = findpeaks(dy, 'MinPeakHeight', 5, 'MinPeakDistance', 25)
hold on;
plot(indexesOfPeaks, peakValues, 'rv', 'MarkerSize', 10);
subplot(4, 1, 3);
hold on;
for k = 1 : length(indexesOfPeaks)
xline(indexesOfPeaks, 'Color', 'r', 'LineWidth', 2);
end
  2 comentarios
Adam Zemánek
Adam Zemánek el 30 de Abr. de 2022
Thanks a lot! Solves my problem perfectly :)
Image Analyst
Image Analyst el 1 de Mayo de 2022
@Adam Zemánek, Glad I could help. Thanks for Accepting. However be aware that it finds inflection points, like where it goes from cupping upwards to cupping downwards. Where that doesn't happen, like in a flat ramp, there will be no inflection point. In that case you might want to use findpeaks() and find the peaks and valleys and then find the halfway intensity point between each peak and valley.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Random Number Generation en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by