图像抠图算法

来源:互联网 发布:泸州大数据产业园 编辑:程序博客网 时间:2024/06/05 15:52




Mat img = imread("999.jpg");


imshow("原画", img);


waitKey(0);










for (int row = 0; row < img.rows; row++)


{


    for (int col = 0; col < img.cols; col++)


    {


 if ( ((img.at<Vec3b>(row, col)[1] - img.at<Vec3b>(row, col)[0]>65)) 


   && ((img.at<Vec3b>(row, col)[1] - img.at<Vec3b>(row, col)[2]>65)))
 {


     img.at<Vec3b>(row, col) = Vec3b(255, 255, 255);
 }
    } 


}


imshow("新图", img);


imwrite( "111.jpg", img );


waitKey();
原创粉丝点击