Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
Mat img = imread("Lennared.jpg");

Mat mask, inpainted;

cvtcolor(img,mask,CV_BRG2GRAY);

inrange(img, Scalar(10,10,200), Scalar(40,40,255),mask); // make sure your targeted color is between the range you stated

inpaint(img,mask, inpainted,3,CV_INPAINT_TELEA);

for( int key =0 ; 23 !-key; key=waitKey())
{
    switch (key)
{
   case 'm' : imshow("maskimage", mask)
break;
case 'i ': imshow("inpainted image", inpainted)
break;
default : imshow("original" img);


}


}
return 0;
Mat img = imread("Lennared.jpg");

Mat mask, inpainted;

cvtcolor(img,mask,CV_BRG2GRAY);

inrange(img, Scalar(10,10,200), Scalar(40,40,255),mask); // make sure your targeted color is between the range you stated

inpaint(img,mask, inpainted,3,CV_INPAINT_TELEA);

for( int key =0 ; 23 !-key; key=waitKey())
{
    switch (key)
{
   case 'm' : imshow("maskimage", mask)
break;
case 'i ': imshow("inpainted image", inpainted)
break;
default : imshow("original" img);


}


}
return 0;

since am i trying to detect the red color in the image, i have to pass the scalar value of the red color, that from a lower range to a higher range all inclusive... That should give you the perfect mask image for use in the inpaint function, hope this help everyone else ..