Reputation: 950
i want my mask to be black obviously and the red line which is my region of interest to be white so that i can use it inside the inpainting function...! am having this code but it not working
How to concentrate on a particular part of the image... because my mask image is showing all the image... this is the image and code
cv::inRange(img, cv::Scalar(0, 100, 220), cv::Scalar(10, 255, 255), lower);
cv::inRange(img, cv::Scalar(0, 10, 100), cv::Scalar(255, 255, 255), upper);
threshold(mask, mask,10,255, CV_THRESH_BINARY);
inpaint(img, mask, inpainted,3,CV_INPAINT_TELEA);
Upvotes: 1
Views: 1535
Reputation: 950
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 ..
Upvotes: 3