Ask Your Question

Revision history [back]

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++)="" <br=""> for(int j=0; j<maskimg.rows; j++)="" <br=""> {
//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 

    }
}

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: below:

for(int i=0; i<maskimg.cols; i++)="" <br="">
i<maskImg.cols; i++)    
    for(int j=0; j<maskimg.rows; j++)="" <br="">
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] ((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] (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 

     }
 }

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 

        }
    }