cvBlobsLib过滤器功能和Matlab bwareaopen

时间:2014-06-30 16:32:00

标签: matlab opencv computer-vision edge-detection cvblobslib

我正在尝试删除OpenCv中长度不足的边。在Matlab Canny edge detecor + bwareaopen完成这项工作,但我无法获得cvBlobsLib CBlobResult :: Filter函数,并且无法使用FillBlob显示结果。这是我的代码

    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_open'不是它应该是的。这可能是什么原因?任何编码建议?

感谢。

0 个答案:

没有答案