3
元の画像を前処理してこの画像を得ました。さて、私の質問は四角形の座標(最大)を得る方法です。申し訳ありませんが、これはnoob質問です。画像中の矩形のコーナー座標を見つける方法
アップデート:私はOpenCVのを開発していますので、this answer
元の画像を前処理してこの画像を得ました。さて、私の質問は四角形の座標(最大)を得る方法です。申し訳ありませんが、これはnoob質問です。画像中の矩形のコーナー座標を見つける方法
アップデート:私はOpenCVのを開発していますので、this answer
一つの簡単な方法は、になります使用して終了:接続されているすべてのコンポーネント
クイック&汚れのMathematicaソリューション
(* find all connected components, calculate the convex hull for each component *)
convexHulls = ComponentMeasurements[ColorNegate[Binarize[src]], {"ConvexArea", "ConvexVertices"}];
(* pick the component where the convex hull has the largest area *)
vertices = SortBy[convexHulls[[All, 2]], First][[-1, 2]]
(* simplify the convex hull polygon, by iteratively removing the vertex with the lowest distance to the line through the vertex before and after it *)
distanceToNeighbors[vertices_] := MapThread[Abs[(#1 - #2).Cross[#1 - #3]/Norm[#1 - #3]]&, RotateLeft[vertices, #] & /@ {-1, 0, 1}]
removeVertexWithLowestDistance[vertices_] := With[{removeIndex = Ordering[distanceToNeighbors[vertices], 1]}, Drop[vertices, removeIndex]]
verticesSimplified = NestWhile[removeVertexWithLowestDistance, vertices, Min[distanceToNeighbors[#]] < 10&]
(* the vertices of the simplified polygon are the points you're looking for *)
Show[src, Graphics[
{
{EdgeForm[Red], Transparent, Polygon[verticesSimplified]},
{Red, PointSize[Large], Point[verticesSimplified]}
}]]
はそう素晴らしい解決策のように。ありがとう! –