Ask Your Question

monademaidi's profile - activity

2014-08-26 04:14:32 -0600 asked a question Grabcut algorithim - mask mode in Android

Hi ALL, I am using grabcut mask mode algorithm in Android and for some reason iteration through pixels is not working.. Could you please help me. Please see the code below:

for(int i=0; i<maskImg.cols; i++)    
    for(int j=0; j<maskImg.rows; j++)    
    {               
        //if it's red, make it black
        if ((int)maskImg.at<cv::Vec3b>(j,i)[0]==0 && (int)maskImg.at<cv::Vec3b>(j,i)[1] == 0 && (int)maskImg.at<cv::Vec3b>(j,i)[2] == 255) {

            //the whole mask is black so this is redundant
            mask.at<uchar>(j,i)= GC_BGD;  //GC_BGD := 0 := black 

        }           

        //if it's green, make it white
        if ((int)maskImg.at<cv::Vec3b>(j,i)[0]==0 && (int)maskImg.at<cv::Vec3b>(j,i)[1] == 255 && (int)maskImg.at<cv::Vec3b>(j,i)[2] == 0) {    

                mask.at<uchar>(j,i) = GC_FGD; //GC_FGD:= 1 := white 

        }
    }