Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered Dec 20 '12

Haris gravatar image

Using below code you can easily access image pixel from a Mat, from that R,G,B value you can check your condition and store the pixel value.

 or(int i = 0; i < img.rows; i++)
   {
  for(int j = 0; j < img.cols; j++)
   { 
    Vec3b bgr = foo.at<Vec3b>(i, j);

    // using BGR values check the condition and store the pixel value
   }
  }
click to hide/show revision 2
No.2 Revision

Using below code you can easily access image pixel from a Mat, from that R,G,B value you can check your condition and store the pixel value.

 or(int i = 0; i < img.rows; i++)
   {
  for(int j = 0; j < img.cols; j++)
   { 
    Vec3b bgr = foo.at<Vec3b>(i, img.at<Vec3b>(i, j);

    // using BGR values check the condition and store the pixel value
   }
  }
click to hide/show revision 3
No.3 Revision

Using below code you can easily access image pixel from a Mat, from that R,G,B value you can check your condition and store the pixel value.

 or(int for(int i = 0; i < img.rows; i++)
   {
  for(int j = 0; j < img.cols; j++)
   { 
    Vec3b bgr = img.at<Vec3b>(i, j);

    // using BGR values check the condition and store the pixel value
   }
  }