0

i'm writting a code in opencv on visual studio c++, that can able to fill the image with any different color like black [with RGB value 0,0,0],but according to my goal. I need to fill color to an image by considering the small matrix of 3*3 pixels in an image,which contains 9 pixels,filling each of 9pixels at a time, according to condition. but i could not able do it. the code is here below, and the output generated is the black line on an,instead of getting black spot on it. plz help me,thanks in advance

 //code for initializing 
while(count<kernel_index){

    for(row_x=init_row; row_x <=(init_row+2); row_x++){

        Vec3b *ptr3 = image.ptr<Vec3b>(init_row);

    for(col_y=init_col; col_y<=(init_col+2); col_y++){

     //reference is taken 
        Vec3b &pixel= ptr3[col_y];

    //some condition to fill the black color

               //pointer for a pixels and allocating to Vec3b variable
              pixel[0] = 0;
              pixel[1] = 0;
              pixel[2] = 0;   
     ++count;
    }

}


 ++mean_index;

 init_col=init_col+3;

 if(col_y>image.cols){
        init_row=init_row+3;
        init_col=0;
 }

if(init_row>image.rows){
break;
}

}
Santhosh
  • 73
  • 1
  • 5
  • 14
  • Next time do a better search... Here you go... http://stackoverflow.com/questions/4337902/how-to-fill-opencv-image-with-one-solid-color – guneykayim Feb 17 '14 at 13:43
  • hey @guneykayim i did,actually my scenario is different,i need to fill the image,considering each group of pixels at a time,[like considering 3x3 pixels at a time].Not for each pixels at a time,you can see for loops in my code. – Santhosh Feb 18 '14 at 03:55

0 Answers0