-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
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
SaraKuhnert
wants to merge
2
commits into
opencv:4.x
Choose a base branch
from
SaraKuhnert:minEnclosingPolygon
base: 4.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ); | ||
|
||
/** @brief Applies an adaptive threshold to an array. | ||
|
||
|
@@ -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 | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
||
|
@@ -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) | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.