Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

like the picture below,how can i deal with the blue edges?

image description

Mat src,dst;
namedWindow("SRC");
namedWindow("DST");
src = imread("t1.jpg");
if (src.empty())
{
    cout<<"read data error!"<<endl;
    return -1;
}
imshow("SRC",src);

split(src,spl);//split
createTrackbar("thresh","DST",&threshold_value,255,on_Threshold);
on_Threshold(0,0);//CALLBACK

this is callback function

threshold(spl[0],dst,threshold_value,max_thresh,THRESH_BINARY_INV);
imshow("DST",dst);
bk = imread("Daydream.jpg");
if (bk.empty())
{
    cout<<"read data error!"<<endl;
    return ;
}
src.copyTo(bk,dst);//
imshow("dst2",bk);
click to hide/show revision 2
this is the threshold image

like the picture below,how can i deal with the blue edges?

image descriptionimage description

Mat src,dst;
namedWindow("SRC");
namedWindow("DST");
src = imread("t1.jpg");
if (src.empty())
{
    cout<<"read data error!"<<endl;
    return -1;
}
imshow("SRC",src);

split(src,spl);//split
createTrackbar("thresh","DST",&threshold_value,255,on_Threshold);
on_Threshold(0,0);//CALLBACK

this is callback function

threshold(spl[0],dst,threshold_value,max_thresh,THRESH_BINARY_INV);
imshow("DST",dst);
bk = imread("Daydream.jpg");
if (bk.empty())
{
    cout<<"read data error!"<<endl;
    return ;
}
src.copyTo(bk,dst);//
imshow("dst2",bk);
click to hide/show revision 3
this is the source image,i matting the cat with PhotoShopCS5,and setting the background blue

like the picture below,how can i deal with the blue edges?

image descriptionimage descriptionimage description

Mat src,dst;
namedWindow("SRC");
namedWindow("DST");
src = imread("t1.jpg");
if (src.empty())
{
    cout<<"read data error!"<<endl;
    return -1;
}
imshow("SRC",src);

split(src,spl);//split
createTrackbar("thresh","DST",&threshold_value,255,on_Threshold);
on_Threshold(0,0);//CALLBACK

this is callback function

threshold(spl[0],dst,threshold_value,max_thresh,THRESH_BINARY_INV);
imshow("DST",dst);
bk = imread("Daydream.jpg");
if (bk.empty())
{
    cout<<"read data error!"<<endl;
    return ;
}
src.copyTo(bk,dst);//
imshow("dst2",bk);

like the picture below,how can i deal with the blue edges?

this is the source image,i matting the cat with photoshopcs5 and setting the background blue,cause i think this maybe easier to matted by opencv. image description this is the threshold image image description image description

Mat src,dst;
namedWindow("SRC");
namedWindow("DST");
src = imread("t1.jpg");
if (src.empty())
{
    cout<<"read data error!"<<endl;
    return -1;
}
imshow("SRC",src);

split(src,spl);//split
createTrackbar("thresh","DST",&threshold_value,255,on_Threshold);
on_Threshold(0,0);//CALLBACK

this is callback function

threshold(spl[0],dst,threshold_value,max_thresh,THRESH_BINARY_INV);
imshow("DST",dst);
bk = imread("Daydream.jpg");
if (bk.empty())
{
    cout<<"read data error!"<<endl;
    return ;
}
src.copyTo(bk,dst);//
imshow("dst2",bk);