How to get fuzzy edge of the raindrop

asked 2018-11-28 19:56:55 -0500

bmi262 gravatar image

updated 2018-11-29 18:18:45 -0500

I'm a OpenCV newbie,I want to extract the edge of the raindrop. This is my photo. image description

I divide the picture into 8*8 blocks and extract the edges using sobel and canny.Now I can get a rough edge. This is the edge I got.

image description

I can't get the fuzzy edge of the raindrop.

Paste my code.

//sobel
Mat SobelProcess(Mat src)
{
    Mat Output;
    Mat grad_x, grad_y, abs_grad_x, abs_grad_y, SobelImage;
    Sobel(src, grad_x, CV_16S, 1, 0, CV_SCHARR, 1, 1, BORDER_DEFAULT);
    Sobel(src, grad_y, CV_16S, 0, 1, CV_SCHARR, 1, 1, BORDER_DEFAULT);

    convertScaleAbs(grad_x, abs_grad_x);
    convertScaleAbs(grad_y, abs_grad_y);
    addWeighted(abs_grad_x, 0.5, abs_grad_y, 0.5, 0, Output);

    //subtract(grad_x, grad_y, SobelImage);
    //convertScaleAbs(SobelImage, Output);

    return Output;
}
int main()
{
    Mat Src;
    Src = imread("rain.bmp",0)
    imshow("src", Src);

    Mat Gauss;
    GaussianBlur(Src, Src, Size(5, 5), 0.5);
    imshow("Gauss", Src);

    //M * N = 8 * 8
    int OtsuThresh[M * N];
    vector<Mat>tempThresh = ImageSegment(Src);
    for (int i = 0; i < M * N; i++)
    {
        OtsuThresh[i] = Otsu(tempThresh[i]); //get Otsu Threshold
    }
    vector<Mat>temp;
    temp = ImageSegment(Src);//ImageSegment() is a function to divide the picture into 8*8 blocks
    for (int i = 0; i < M * N; i++)
    {
        temp[i] = SobelProcess(temp[i]);
        GaussianBlur(temp[i], temp[i], Size(3, 3), 0.5);
        Canny(temp[i], temp[i], OtsuThresh[i] / 3, OtsuThresh[i]);
    }
    Mat Tem;
    Tem = ImageMerge(temp);//ImageMerge() is a function to merge the blocks
    imshow("Tem", Tem);
}

Then I use watershed.But I can't use it get an ideal result. Can you help me ? Thank you.

edit retag flag offensive close merge delete