Fastest Method to Loop Through Contour Pixels [closed]

asked 2014-03-09 20:47:31 -0600

MarkH gravatar image

updated 2020-10-11 14:44:41 -0600

I am looking for the fastest way to iterate through the pixels in a contour.

I am currently creating a new grayscale and then using the function cvDrawContours to fill in the contours pixels in the grayscale. Next, I loop through contours min area rectangle pixels skipping the pixels which are not filled in with the grayscale.

This seems a bit inefficient, is there a better method???

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-09-27 11:43:19.714988

Comments

Hi,when you use cvDrawContours and you get contour pixels.so why do you oop through contours min area rectangle pixels skipping the pixels which are not filled in with the grayscale???

wuling gravatar imagewuling ( 2014-03-10 09:42:16 -0600 )edit

What you described is the method I am using. I was wondering if there was faster method than creating a grayscale mask from cvDrawContours to isolate a contours pixels.

MarkH gravatar imageMarkH ( 2014-03-10 14:17:54 -0600 )edit

hi,you mean like this findContours(image, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
for(;itContours != contours.end();++itContours)
{ ………………
}

as i know the loop is to get each contours of the shapes

wuling gravatar imagewuling ( 2014-03-10 19:27:50 -0600 )edit

Did you ever find a better way? I have the same issue, and believe this to be the bottleneck of my application :-/

Sejdenfaden gravatar imageSejdenfaden ( 2014-05-13 06:43:43 -0600 )edit

Maybe first you should clear an isolated contours pixels for example if area size is less than constanst area then do not draw, and area size is larger than ,then do what you want.

wuling gravatar imagewuling ( 2014-05-13 08:53:43 -0600 )edit