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

@@ -12,7 +12,7 @@ static void on_trackbar(int, void*)
{
Mat bw = threshval < 128 ? (img < threshval) : (img > threshval);
Mat labelImage(img.size(), CV_32S);
int nLabels = connectedComponents(labelImage, bw, 8);
uint64_t nLabels = connectedComponents(labelImage, bw, 8);
Vec3b colors[nLabels];
colors[0] = Vec3b(0, 0, 0);//background
for(int label = 1; label < nLabels; ++label){