Ask Your Question

delaila's profile - activity

2020-09-02 08:29:33 -0600 received badge  Popular Question (source)
2015-11-20 13:36:05 -0600 received badge  Enthusiast
2015-03-14 03:15:46 -0600 received badge  Scholar (source)
2015-03-05 21:32:04 -0600 commented answer how to flood fill to differentiate between obstacle and the path that can be taken

thank you very much for your answer @theodore. :) I got the result like what you did after I added threshold at the 'last result'. But, the result still same as before. I think there are something wrong at for loops coding. I try to change j++ with j-- (same with i) , but the result shows completely white. I don't know how to solve it.

2015-03-03 20:18:30 -0600 commented question how to flood fill to differentiate between obstacle and the path that can be taken

Okay..I have already upload the original image.. :)

2015-03-03 20:14:43 -0600 received badge  Editor (source)
2015-03-02 21:45:38 -0600 asked a question how to flood fill to differentiate between obstacle and the path that can be taken

)I try this coding and I got the result..I want the object and wall to be black while the floor which is the path that can be taken by the robot is in white..But, the result that I have obtained is different from what I expected (object and floor are black; wall is white)..can anyone help me?..any suggestion?

the original image : C:\fakepath\box_1.jpg

This is the result that I got..

after edge detection : image description

last result : image description

    Mat img_bw;
    threshold(grad, img_bw, 128, 255, CV_THRESH_BINARY);

    // Loop through the border pixels and if they're black, floodFill from there
    cv::Mat mask;
    img_bw.copyTo(mask);

    for (int j = 0; j < mask.rows; j++)
    {

        for (int i = 0; i < mask.cols ; i++)
        {
            if (mask.at<char>(i,j) == 0)
            {
                cv::floodFill(mask, cv::Point(i, j), 255, 0, 10, 10);
            }
            else
            {
                break;
            }
        }
    }

    // Compare mask with original.
    cv::Mat newImage;
    img_bw.copyTo(newImage);
    for (int row = 0; row < mask.rows; ++row) {

        for (int col = 0; col < mask.cols; ++col) {
            if (mask.at<char>(row, col) == 0) {
                newImage.at<char>(row, col) = 255;
            }
        }
    }
    Mat img_bw1;
    threshold(newImage, img_bw1, 128, 255, CV_THRESH_BINARY_INV);