Content-Length: 420431 | pFad | http://github.com/opencv/opencv/pull/27369/files

12 imgproc: add minEnclosingConvexPolygon by SaraKuhnert · Pull Request #27369 · opencv/opencv · GitHub
Skip to content

imgproc: add minEnclosingConvexPolygon #27369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/opencv.bib
Original file line number Diff line number Diff line change
Expand Up @@ -1553,3 +1553,12 @@ @inproceedings{Zuliani2014RANSACFD
year = {2014},
url = {http://www.marcozuliani.com/docs/RANSAC4Dummies.pdf}
}
@article{Aggarwal1985,
author = {Aggarwal, A. and Chang, J. and Yap, Chee K.},
title = {Minimum area circumscribing Polygons},
year = {1985},
pages = {112--117},
journal = {The Visual Computer},
volume = {7},
url = {https://doi.org/10.1007/BF01898354}
}
60 changes: 29 additions & 31 deletions modules/imgproc/include/opencv2/imgproc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3070,41 +3070,21 @@ Also, the special values #THRESH_OTSU or #THRESH_TRIANGLE may be combined with o
above values. In these cases, the function determines the optimal threshold value using the Otsu's
or Triangle algorithm and uses it instead of the specified thresh.

@note Currently, the Otsu's method is implemented only for CV_8UC1 and CV_16UC1 images,
and the Triangle's method is implemented only for CV_8UC1 images.
@note Currently, the Otsu's and Triangle methods are implemented only for 8-bit single-channel images.

@param src input array (multiple-channel, CV_8U, CV_16S, CV_16U, CV_32F or CV_64F).
@param src input array (multiple-channel, 8-bit or 32-bit floating point).
@param dst output array of the same size and type and the same number of channels as src.
@param thresh threshold value.
@param maxval maximum value to use with the #THRESH_BINARY and #THRESH_BINARY_INV thresholding
types.
@param type thresholding type (see #ThresholdTypes).
@return the computed threshold value if Otsu's or Triangle methods used.

@sa thresholdWithMask, adaptiveThreshold, findContours, compare, min, max
@sa adaptiveThreshold, findContours, compare, min, max
*/
CV_EXPORTS_W double threshold( InputArray src, OutputArray dst,
double thresh, double maxval, int type );

/** @brief Same as #threshold, but with an optional mask

@note If the mask is empty, #thresholdWithMask is equivalent to #threshold.
If the mask is not empty, dst *must* be of the same size and type as src, so that
outliers pixels are left as-is

@param src input array (multiple-channel, 8-bit or 32-bit floating point).
@param dst output array of the same size and type and the same number of channels as src.
@param mask optional mask (same size as src, 8-bit).
@param thresh threshold value.
@param maxval maximum value to use with the #THRESH_BINARY and #THRESH_BINARY_INV thresholding
types.
@param type thresholding type (see #ThresholdTypes).
@return the computed threshold value if Otsu's or Triangle methods used.

@sa threshold, adaptiveThreshold, findContours, compare, min, max
*/
CV_EXPORTS_W double thresholdWithMask( InputArray src, InputOutputArray dst, InputArray mask,
double thresh, double maxval, int type );
Comment on lines -3073 to -3107
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are not relevant. Looks like you need to rebase on top of 4.x and properly fix conflicts.


/** @brief Applies an adaptive threshold to an array.

Expand Down Expand Up @@ -4160,11 +4140,7 @@ CV_EXPORTS_W double contourArea( InputArray contour, bool oriented = false );
/** @brief Finds a rotated rectangle of the minimum area enclosing the input 2D point set.

The function calculates and returns the minimum-area bounding rectangle (possibly rotated) for a
specified point set. The angle of rotation represents the angle between the line connecting the starting
and ending points (based on the clockwise order with greatest index for the corner with greatest \f$y\f$)
and the horizontal axis. This angle always falls between \f$[-90, 0)\f$ because, if the object
rotates more than a rect angle, the next edge is used to measure the angle. The starting and ending points change
as the object rotates.Developer should keep in mind that the returned RotatedRect can contain negative
specified point set. Developer should keep in mind that the returned RotatedRect can contain negative
indices when data is close to the containing Mat element boundary.

@param points Input vector of 2D points, stored in std::vector\<\> or Mat
Expand All @@ -4173,9 +4149,7 @@ CV_EXPORTS_W RotatedRect minAreaRect( InputArray points );

/** @brief Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle.

The function finds the four vertices of a rotated rectangle. The four vertices are returned
in clockwise order starting from the point with greatest \f$y\f$. If two points have the
same \f$y\f$ coordinate the rightmost is the starting point. This function is useful to draw the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same

The function finds the four vertices of a rotated rectangle. This function is useful to draw the
rectangle. In C++, instead of using this function, you can directly use RotatedRect::points method. Please
visit the @ref tutorial_bounding_rotated_ellipses "tutorial on Creating Bounding rotated boxes and ellipses for contours" for more information.

Expand Down Expand Up @@ -4219,6 +4193,30 @@ of the OutputArray must be CV_32F.
*/
CV_EXPORTS_W double minEnclosingTriangle( InputArray points, CV_OUT OutputArray triangle );


/**
@brief Finds a convex polygon of minimum area enclosing a 2D point set and returns its area.

This function takes a given set of 2D points and finds the enclosing polygon with k vertices and minimal
area. It takes the set of points and the parameter k as input and returns the area of the minimal
enclosing polygon.

The Implementation is based on a paper by Aggarwal, Chang and Yap @cite Aggarwal1985. They
provide a \f$\theta(n²log(n)log(k))\f$ algorighm for finding the minimal convex polygon with k
vertices enclosing a 2D convex polygon with n vertices (k < n). Since the #minEnclosingConvexPolygon
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 #convexHull function is \f$O(n log(n))\f$ which
is lower than \f$\theta(n²log(n)log(k))\f$. Thus the overall complexity of the function is
\f$O(n²log(n)log(k))\f$.

@param points Input vector of 2D points, stored in std::vector\<\> or Mat
@param polygon Output vector of 2D points defining the vertices of the enclosing polygon
@param k Number of vertices of the output polygon
*/

CV_EXPORTS_W double minEnclosingConvexPolygon ( InputArray points, OutputArray polygon, int k );


/** @brief Compares two shapes.

The function compares two shapes. All three implemented methods use the Hu invariants (see #HuMoments)
Expand Down
Loading
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/opencv/opencv/pull/27369/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy