Using PBO to write binary mask of rendered object


I’m trying to write a binary mask corresponding to a rendered object to client (system) memory. I am only rendering a single object in a single colour, stored in a simple array colours[]. I am not using shading or lighting or anything fancy.

What I am trying to do is scan the buffer for the rendered object and write a 0 for a pixel that is not rendered in the colour (colours[1] below) i.e. outside of the object and 1 for a pixel inside object, i.e. rendered in the colour (colours[1]). I think I need to use a PBO to achieve this?

Below is my code

GLuint pboName;

glGenBuffersARB(1, &pboName);
glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB,width * height, myPixelPtr,GL_STREAM_READ_ARB);

// Map the PBO so that it is readable by client (CPU)
// only want to read pixel data in order to set mask values

// initialise mask object pMask
      pMask->initialiseMask(); //initially set all values to false(0)

// Now loop through all values to check whether pixel value == colours[1] if yes then set corresponding Mask
bixel (i,j) of pMask set to true

	for (int i=0;i<height;++i){
		for (int j=0;j<width;++j){ 

			if (myPixelPtr[(i*width)+j]==glColors3fv(colours[1])) pMask[i][j]=true;

// Now unmap the PBO releasing the client side mapping

// Finally clean up
glDeleteBuffersARB(1, &pboName);

Firstly is a PBO the right choice, or would it be better to use a VBO of the rendered object? Secondly is my syntax okay?

The mask is used to determine an aperture which encloses the rendered object, where the aperture consists of two banks of finite moveable elements in x-direction
I would really appreciate some assistance with this as I need to get this done by the end of the week.