Ask Your Question

zetain's profile - activity

2020-09-24 09:54:03 -0600 received badge  Popular Question (source)
2014-01-06 12:12:51 -0600 asked a question Finding the circumference of a shape found by findContours

I am trying to find a red bottle cap and want to use the findContours function together with moments. I know that i get the area of the contour when i access m00 of the moment. I would like to know if there is a way to calculate the circumference of a shape, if there is already a function that handles such a thing or if there is another attribute which i simply have to read.

I looked here but was not able to find something fitting.

2014-01-06 06:50:29 -0600 commented question Using Mat::at with single channel image

mh ... I tried what you have proposed but it is still giving me the same error. My program runs perfectly when i use this line of code instead but is really slow:

binaryImage.col(x).row(y).data[0] == 255

so the rest of my program is not the problem. I also have checked if the picture has the amount of channels and the expected depth of 8Bit.

2014-01-06 04:19:34 -0600 commented question Using Mat::at with single channel image

ahhh! I am such an idiot. Thank you very much :)

2014-01-05 17:00:09 -0600 asked a question Using Mat::at with single channel image

Hello,

i am trying to access the pixels of a single channel grayscale image. I am using this code:

for( int x = 1; x < binaryImage.cols; x++ )
{ 
for( int y = 1; y < binaryImage.rows; y++ )
    { 
     if(binaryImage.at<Vec3b>(x,y)[0] == 255)
     {
        redPixelsInCol[x] += 1;
        totalRedPixels++;
     }
     redCol[x] = redPixelsInCol[x] * x;
     }
 }

I get an error in VisualStudio telling me that i try to access memory i am forbidden to access. I can imagine that this is caused by the datatype Vec3b which forces the at-method to read 3 values every iteration. Due to the fact that a grayscale image only has one channel there aren't 3 values left at the end of the iteration so breaking the size of the mat object.

I am forced to specify the datatype in which the pixel value is returned but this must be an array or a pointer. Which type should i give the at-method for a single channel image? Or is there another reason causing this code to break?

thank you for your help :)