Inflection points of binary image

조회 수: 6 (최근 30일)
Adam Zemánek
Adam Zemánek 2022년 4월 30일
댓글: Image Analyst 2022년 5월 1일
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
Riccardo Scorretti
Riccardo Scorretti 2022년 4월 30일
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 2022년 4월 30일
Thanks for suggestion, appreciate it :)

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

채택된 답변

Image Analyst
Image Analyst 2022년 4월 30일
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
Adam Zemánek
Adam Zemánek 2022년 4월 30일
Thanks a lot! Solves my problem perfectly :)
Image Analyst
Image Analyst 2022년 5월 1일
@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.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by