Inflection points of binary image

7 views (last 30 days)
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 Comments
Riccardo Scorretti
Riccardo Scorretti on 30 Apr 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 on 30 Apr 2022
Thanks for suggestion, appreciate it :)

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 30 Apr 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 Comments
Adam Zemánek
Adam Zemánek on 30 Apr 2022
Thanks a lot! Solves my problem perfectly :)
Image Analyst
Image Analyst on 1 May 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.

Sign in to comment.

More Answers (0)

Categories

Find more on Random Number Generation in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!