connectedComponents: peep-hole optimizations, mostly surrouding the fact that cv::Mat::at is expensive in a tight-loop -also added a "blobstats" version

This commit is contained in:
Jason Newton
2012-08-25 02:31:52 -07:00
parent 45b4f4f32b
commit 4c0cb2576d
3 changed files with 252 additions and 121 deletions

View File

@@ -1091,9 +1091,24 @@ 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
{
int32_t lower_x;
int32_t lower_y;
int32_t upper_x;
int32_t upper_y;
double centroid_x;
double centroid_y;
uint64_t integral_x;
uint64_t integral_y;
uint32_t area;
};
//! 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.
//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 uint64_t connectedComponents(Mat &L, const Mat &I, int connectivity = 8);
CV_EXPORTS_W uint64_t connectedComponents(Mat &L, const Mat &I, std::vector<ConnectedComponentStats> &statsv, int connectivity = 8);
//! mode of the contour retrieval algorithm