Skip to content
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

there is some questions about the example of connectedComponentsWithStats #67

Open
jsxyhelu opened this issue Aug 27, 2017 · 2 comments

Comments

@jsxyhelu
Copy link
Contributor

in page 419(pdf)
1、when i use

 int i, nccomps = cv::connectedComponentsWithStats (
    img_edge, labels,
    stats, cv::noArray()
  );

OpenCV gvies me an ERROR,
I had change my code to

cv::Mat  centroids;
int nccomps = cv::connectedComponentsWithStats (
		img_edge, labels,
		stats, centroids
		);

2、i think

for( i = 1; i <= nccomps; i++ ) {

    colors[i] = Vec3b(rand()%256, rand()%256, rand()%256);

    if( stats.at<int>(i-1, cv::CC_STAT_AREA) < 100 )

      colors[i] = Vec3b(0,0,0); // small regions are painted with black too.

  }

may be changed to

for( i = 1; i < nccomps; i++ ) {
		colors[i] = Vec3b(rand()%256, rand()%256, rand()%256);
		if( stats.at<int>(i, cv::CC_STAT_AREA) < 100 )
			colors[i] = Vec3b(0,0,0); // small regions are painted with black too.
	}

and the below code gives me the right result.
am i right?thanks.

@zacniewski
Copy link

@jsxyhelu I think you are correct. I had the same problems and your solution gives proper results.
Best regards
Artur

@jsxyhelu
Copy link
Contributor Author

that's OK!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants