Inflection points of binary image

10 ビュー (過去 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 Center および File ExchangeRandom Number Generation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by