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;
}
}