Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

sequence of morphological operators

Hi, I'm facing and old code review, and trying to optimize and better understand it. I have this function:

cv::Mat morphology(cv::Mat frame)
{
    cv::Mat process1, process2, process3, process4;
    int size_slider = 3;
    cv::Mat st_elem = cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(size_slider, size_slider));
    cv::dilate(frame, process1, 3);
    cv::erode(process1, process2, st_elem);
    cv::erode(process2, process3, st_elem);
    cv::dilate(process3, process4, 2);
    return process4;
}

Do I get the same result substituting the double erode function call with only one, doubling the structuring element? I've always tried to understand this part, but only found empirical solution on the web, (like this one). I'd like to have a logical approach to morphological operators. Any hints about this code will be appreciated.

sequence of morphological operators

Hi, I'm facing and old code review, and trying to optimize and better understand it. I have this function:

cv::Mat morphology(cv::Mat frame)
{
    cv::Mat process1, process2, process3, process4;
    int size_slider = 3;
    cv::Mat st_elem = cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(size_slider, size_slider));
    cv::dilate(frame, process1, 3);
    cv::erode(process1, process2, st_elem);
    cv::erode(process2, process3, st_elem);
    cv::dilate(process3, process4, 2);
    return process4;
}

Do I get the same result substituting the double erode function call with only one, doubling the structuring element? How to choose the structuring element shape? I've always tried to understand this part, but only found empirical solution on the web, (like this one). I'd like to have a logical approach to morphological operators. Any hints about this code will be appreciated.