Edge Smoothing and filling inner contours in opencv with iOS

前端 未结 1 969
我在风中等你
我在风中等你 2021-02-06 18:32

I am trying to tan human skin with different intensity with help of opencv. I have already identified human skin and changing color tone of those pixels. But it is not smooth. <

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 19:26

    how about?

    morphologyEx(grey,grey,MORPH_CLOSE,getStructuringElement( MORPH_ELLIPSE,Size(7,7)));
    

    although the silhouette gets merged for the left hand

    simple

    edit:slightly more involved

    Mat tmp=grey.clone();
    morphologyEx(tmp,tmp,MORPH_GRADIENT,getStructuringElement(MORPH_ELLIPSE,Size(3,3)));
    bitwise_not(tmp,tmp);
    Mat smallholes=Mat::zeros(tmp.size(), CV_8UC1);
    vector> contours;
    findContours(tmp,contours,CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE);
    for(int i = 0; i < contours.size(); i++)
    {       
        double area = contourArea(Mat(contours[i]));
        if(area<100)
            drawContours(smallholes, contours, i, 255, -1);
    }
    Mat done;
    bitwise_or(grey,smallholes,done);
    morphologyEx(done,done,MORPH_CLOSE,getStructuringElement(MORPH_ELLIPSE,Size(3,3)));
    

    long

    0 讨论(0)
提交回复
热议问题