A few changes to comply with upstream requirements for merge.

-Change input/output order from (out Labeled, in Image) -> (in Image, Out Labeled) and convert
to Input/OutputArrays in the process.

-Adopt OutputArray for statistics export so that the algorithm is "wrapper friendly" and not requiring a new struct in
language bindings at the expense of using doubles for everything and slowing statistics computation down..
This commit is contained in:
Jason Newton
2012-11-27 02:25:52 -08:00
parent d5aa679d3f
commit 00bdca7684
4 changed files with 59 additions and 66 deletions

View File

@@ -1091,24 +1091,13 @@ enum { TM_SQDIFF=0, TM_SQDIFF_NORMED=1, TM_CCORR=2, TM_CCORR_NORMED=3, TM_CCOEFF
CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ,
OutputArray result, int method );
struct CV_EXPORTS ConnectedComponentStats
{
int lower_x;//!< lower left corner column
int lower_y;//!< lower left corner row
int upper_x;//!< upper right corner column
int upper_y;//!< upper right corner row
double centroid_x;//!< centroid column
double centroid_y;//!< centroid row
uint64 integral_x;//!< sum of all columns where the image was non-zero
uint64 integral_y;//!< sum of all rows where the image was non-zero
unsigned int area;//!< count of all non-zero pixels
};
enum { CC_STAT_LEFT=0, CC_STAT_TOP=1, CC_STAT_WIDTH=2, CC_STAT_HEIGHT=3, CC_STAT_CX=4, CC_STAT_CY=5, CC_STAT_AREA=6, CC_STAT_INTEGRAL_X=7, CC_STAT_INTEGRAL_Y=8, CC_STAT_MAX = 9};
//! computes the connected components labeled image of boolean image I with 4 or 8 way connectivity - returns N, the total
//number of labels [0, N-1] where 0 represents the background label. L's value type determines the label type, an important
//consideration based on the total number of labels or alternatively the total number of pixels.
CV_EXPORTS_W int connectedComponents(CV_OUT Mat &L, const Mat &I, int connectivity = 8);
CV_EXPORTS_W int connectedComponentsWithStats(CV_OUT Mat &L, const Mat &I, CV_OUT std::vector<ConnectedComponentStats> &statsv, int connectivity = 8);
CV_EXPORTS_W int connectedComponents(InputArray image, OutputArray labels, int connectivity = 8);
CV_EXPORTS_W int connectedComponentsWithStats(InputArray image, OutputArray labels, OutputArray stats, int connectivity = 8);
//! mode of the contour retrieval algorithm