Ask Your Question

Revision history [back]

is there a bug on erode & dilate

could someone ( using last version of OpenCV ) try the code below and share his remarks.

thanks in advance.

#include "opencv2\opencv.hpp"

using namespace cv;

int main() {
    Mat binary(Size(400, 400), CV_8U, Scalar(0));
    rectangle(binary, Rect(200, 200, 100, 100), Scalar(255), -1);
    Mat test1, test2, test3, test4;
    for (int i = 0; i < 90; i++)
    {
        erode(binary, test1, Mat(Size(i, i), CV_8U, Scalar(1)));
        erode(binary, test2, Mat(Size(i, i), CV_8U, Scalar(0)));
        dilate(binary, test3, Mat(Size(i, i), CV_8U, Scalar(1)));
        dilate(binary, test4, Mat(Size(i, i), CV_8U, Scalar(0)));
        imshow("binary", binary);
        imshow("test1", test1);
        imshow("test2", test2);
        imshow("test3", test3);
        imshow("test4", test4);
        moveWindow("test1", 0, 0);
        moveWindow("test2", 400, 0);
        moveWindow("test3", 0, 400);
        moveWindow("test4", 400, 400);
        waitKey(100);
    }
    waitKey();
    return 0;
}

is there a bug on misusing of erode & dilate

could someone ( using last version of OpenCV ) try the code below and share his remarks.

thanks in advance.

#include "opencv2\opencv.hpp"

using namespace cv;

int main() {
    Mat binary(Size(400, 400), CV_8U, Scalar(0));
    rectangle(binary, Rect(200, 200, 100, 100), Scalar(255), -1);
    Mat test1, test2, test3, test4;
    for (int i = 0; i < 90; i++)
    {
        erode(binary, test1, Mat(Size(i, i), CV_8U, Scalar(1)));
        erode(binary, test2, Mat(Size(i, i), CV_8U, Scalar(0)));
        dilate(binary, test3, Mat(Size(i, i), CV_8U, Scalar(1)));
        dilate(binary, test4, Mat(Size(i, i), CV_8U, Scalar(0)));
        imshow("binary", binary);
        imshow("test1", test1);
        imshow("test2", test2);
        imshow("test3", test3);
        imshow("test4", test4);
        moveWindow("test1", 0, 0);
        moveWindow("test2", 400, 0);
        moveWindow("test3", 0, 400);
        moveWindow("test4", 400, 400);
        waitKey(100);
    }
    waitKey();
    return 0;
}

misusing of erode & dilate

could someone ( using last version of OpenCV ) try the code below and share his remarks.

thanks in advance.

#include "opencv2\opencv.hpp"

using namespace cv;

int main() {
    Mat binary(Size(400, 400), CV_8U, Scalar(0));
    rectangle(binary, Rect(200, 200, 100, 100), Scalar(255), -1);
    Mat test1, test2, test3, test4;
    for (int i = 0; i < 90; i++)
    {
        erode(binary, test1, Mat(Size(i, i), CV_8U, Scalar(1)));
        erode(binary, test2, Mat(Size(i, i), CV_8U, Scalar(0)));
        dilate(binary, test3, Mat(Size(i, i), CV_8U, Scalar(1)));
        dilate(binary, test4, Mat(Size(i, i), CV_8U, Scalar(0)));
        imshow("binary", binary);
        imshow("test1", test1);
        imshow("test2", test2);
        imshow("test3", test3);
        imshow("test4", test4);
        moveWindow("test1", 0, 0);
        moveWindow("test2", 400, 0);
        moveWindow("test3", 0, 400);
        moveWindow("test4", 400, 400);
        waitKey(100);
    }
    waitKey();
    return 0;
}