- Wrote the documentation for the minEnclosingTriangle function (+1 extra picture...
authorOvidiu Parvu <ovidiu.parvu@gmail.com>
Sun, 15 Sep 2013 14:07:17 +0000 (15:07 +0100)
committerOvidiu Parvu <ovidiu.parvu@gmail.com>
Sun, 15 Sep 2013 14:07:17 +0000 (15:07 +0100)
modules/imgproc/doc/pics/minenclosingtriangle.png [new file with mode: 0644]
modules/imgproc/doc/structural_analysis_and_shape_descriptors.rst

diff --git a/modules/imgproc/doc/pics/minenclosingtriangle.png b/modules/imgproc/doc/pics/minenclosingtriangle.png
new file mode 100644 (file)
index 0000000..ec89c6a
Binary files /dev/null and b/modules/imgproc/doc/pics/minenclosingtriangle.png differ
index d346006..c091ba3 100644 (file)
@@ -560,6 +560,41 @@ The function finds the four vertices of a rotated rectangle. This function is us
 
 
 
+minEnclosingTriangle
+----------------------
+Finds a triangle of minimum area enclosing a 2D point set.
+
+.. ocv:function:: void minEnclosingTriangle( InputArray points, OutputArray triangle )
+
+.. ocv:function:: void minEnclosingTriangle( InputArray points, OutputArray triangle, double &area )
+
+.. ocv:pyfunction:: cv2.minEnclosingTriangle(points[, triangle]) -> triangle, area
+
+    :param points: Input vector of 2D points with depth ``CV_32S`` or ``CV_32F``.
+
+    :param triangle: Output vector of three 2D points defining the vertices of the triangle. The depth of the OutputArray must be ``CV_32F``.
+
+    :param area: The area of the minimum enclosing triangle.
+
+The output for a given 2D point set is shown in the image below. The 2D points are depicted in *red* and the enclosing triangle in *yellow*.
+
+.. image:: pics/minenclosingtriangle.png
+    :height: 250px
+    :width: 250px
+    :alt: Sample output of the minimum enclosing triangle function
+
+The implementation of the algorithm is based on O'Rourke's [ORourke86]_ and Klee and Laskowski's [KleeLaskowski85]_ papers. O'Rourke provides a
+:math:`\theta(n)`
+algorithm for finding the minimal enclosing triangle of a 2D convex polygon with ``n`` vertices. Since the :ocv:func:`minEnclosingTriangle` function takes a 2D point set as input an additional preprocessing step of computing the convex hull of the 2D point set is required. The complexity of the :ocv:func:`convexHull` function is
+:math:`O(n log(n))` which is higher than
+:math:`\theta(n)`.
+Thus the overall complexity of the function is
+:math:`O(n log(n))`.
+
+.. note:: See ``opencv_source/samples/cpp/minarea.cpp`` for a usage example.
+
+
+
 minEnclosingCircle
 ----------------------
 Finds a circle of the minimum area enclosing a 2D point set.
@@ -672,6 +707,10 @@ See below a sample output of the function where each image pixel is tested again
 
 .. [Hu62] M. Hu. *Visual Pattern Recognition by Moment Invariants*, IRE Transactions on Information Theory, 8:2, pp. 179-187, 1962.
 
+.. [KleeLaskowski85] Klee, V. and Laskowski, M.C., *Finding the smallest triangles containing a given convex polygon*, Journal of Algorithms, vol. 6, no. 3, pp. 359–375 (1985)
+
+.. [ORourke86] O’Rourke, J., Aggarwal, A., Maddila, S., and Baldwin, M., *An optimal algorithm for finding minimal enclosing triangles*, Journal of Algorithms, vol. 7, no. 2, pp. 258–269 (1986)
+
 .. [Sklansky82] Sklansky, J., *Finding the Convex Hull of a Simple Polygon*. PRL 1 $number, pp 79-83 (1982)
 
 .. [Suzuki85] Suzuki, S. and Abe, K., *Topological Structural Analysis of Digitized Binary Images by Border Following*. CVGIP 30 1, pp 32-46 (1985)