Ask Your Question

Revision history [back]

I think it is better like this :

uchar* ptr_Image = Image.ptr<uchar>(i);
uchar* ptr_BinaryImage = BinaryImage.ptr<uchar>(i);
for (int j = 0; j < Image.cols; ++j,ptr_image++)// three channel = 3 X ptrchannel++
 {
    int y = x - *(ptr_Image+2);// parenthesis i don't remmber priority order

if ((x - *ptr_Image++ < Threshold2) && (y - *ptr_Image++ < Threshold1) && ) // right order here
     {   *ptr_BinaryImage++ = 255;
         *ptr_BinaryImage++ = 255;
         *ptr_BinaryImage++ = 255;
      }
 }

Ok now you can try to use mask :

vector<Mat> chImage(3);
split(Image,chImage);
Mat y=x-chImage[2];
Mat z= y-chImage[1];
Mat mask=(z < Threshold1) && (x - chImage[0]< Threshold2);

BinaryImage(mask)=Vec3b(255,255,255);

I havent check my answer