I am trying to find the corners of the "rectangular" shapes. This code is working very well. But I dont know exactly how it works. Can you explain me ??

10 ビュー (過去 30 日間)
[I,J] = find(binaryimg>max(binaryimg(:))/2);
IJ = [I,J];
[~,idx] = min(IJ*[1 1; -1 1; 1 -1; -1 -1].');
Corners = IJ(idx,:);

採用された回答

Matt J
Matt J 2018 年 8 月 1 日
編集済み: Matt J 2019 年 4 月 14 日
Maybe this image will help. The corners of a polyhedron will maximize/minimize the intercept of lines of a certain slope - it's a linear programming principle. In the code shown, the lines used x+y, x-y, -x+y,-x-y are those oriented at 45 degrees to the x,y axes. As long as the rectangle edges are approximately parallel/perpendicular to the x,y axes, its corners will minimize the intercept of one of these lines.
  4 件のコメント
Matt J
Matt J 2018 年 8 月 1 日
編集済み: Matt J 2018 年 8 月 1 日
Thank you for your answer Matt J. Your answer is very clear.
You're welcome, but please Accept-click the answer to certify that it addressed your question.
Can you give me any paper or link about this algorithm ?
I don't think you'll find any papers about it. It's a very ad hoc method (but if you find any, I'd be glad to hear).
Matt J
Matt J 2020 年 2 月 6 日
Incidentally, I have made a File Exchange submission which generalizes the method to any convex polygon:

サインインしてコメントする。

その他の回答 (1 件)

jim as
jim as 2021 年 1 月 14 日
An algorithm addressing this problem that you have raised is escribed in https://arxiv.org/abs/2011.14035
DC

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by