1

I am trying to delete edges whose length is under a limit in OpenCv. In Matlab Canny edge detecor+bwareaopen does the job, however I could not get the cvBlobsLib CBlobResult::Filter function and cannot show the results using FillBlob. Here is my code

    image = imread(imageflname, CV_LOAD_IMAGE_COLOR);
    Mat gray;
    cvtColor(image,gray, CV_BGR2GRAY);
    float min_thr = 54; 
    GaussianBlur(gray, gray, Size(5,5), 0.8, BORDER_REPLICATE);
    imwrite("gray.png", gray);
    Canny(gray, edge_im, min_thr, min_thr*3, 3); 
    imwrite("edge_im.png", edge_im);
    CBlobResult blobs;
    Mat binary_image(edge_im.size(), CV_8UC1);
    blobs = CBlobResult(binary_image,Mat(),4);
    cout<<"# blobs found: "<<blobs.GetNumBlobs()<<endl;
    blobs.Filter( blobs, B_INCLUDE, CBlobGetArea(), B_GREATER, 70 );
    cout<<"After deletion found: "<<blobs.GetNumBlobs()<<endl;
    Mat edge_open(edge_im.size(), image.type());
    edge_open.setTo(0);
    for(int i=0;i<blobs.GetNumBlobs();i++){
            blobs.GetBlob(i)->FillBlob(edge_open,CV_RGB(255,255,255));
    }   
    imwrite("edge_im_open.png", edge_open);

Edge image comes out ok, but the area opening part does not work properly. 'edge_open' is not what it is supposed to be. What could be the reason for this? Any coding suggestions?

Thanks.

bariskand
  • 31
  • 4
  • Please be very specific about what is not 'as it is supposed to be'. Also include a reproducible example, including the output and desired output. – Dennis Jaheruddin Jul 08 '14 at 14:31

0 Answers0