Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Separate the leafs into single leaf

before segmentation after segmentation

There are 5 leafs stick together after segmentation(I do it by watershed), how could I separate the whole leaf into 5 independent leaf(blob)?

I am a newbie of computer vision, there are tons of algorithms I haven't learned yet.Now I am studying how to use surf and sift to recognize the object, is it possible to use sift to segment in into 5 independent leafs(do not glue them together)?

Separate the leafs into single leaf

before segmentation after segmentation

There are 5 leafs stick together after segmentation(I do it by watershed), how could I separate the whole leaf into 5 independent leaf(blob)?

I am a newbie of computer vision, there are tons of algorithms I haven't learned yet.Now I am studying how to use surf and sift to recognize the object, is it possible to use sift to segment in into 5 independent leafs(do not glue them together)?

Any algorithms are possible to solve this problem?

Separate the leafs into single leafDetect multiple similar in a bunch of still images

before segmentation after segmentation

There are 5 leafs stick together after segmentation(I do it by watershed), how could I separate the whole leaf into 5 independent leaf(blob)?

I am a newbie of computer vision, there are tons of algorithms I haven't learned yet.Now I am studying how to use surf and sift to recognize the object, is it possible to use sift to segment in into 5 independent leafs(do not glue them together)?

Any algorithms are possible to solve this problem?

Edit : According to the suggestion of GilLevi, i use houghLinesP to draw the lines on the image after segmentation.

//remove contours size which smaller than cmin or bigger than cmax
void remove_contours(std::vector<std::vector<cv::Point> > &contours, double cmin, double cmax)
{            
    auto it = std::partition(std::begin(contours), std::end(contours), [=](std::vector<cv::Point> const &data)
    {
       auto const size = cv::contourArea(data);
       return !(size < cmin || size > cmax);
    });
    contours.erase(it, std::end(contours));
}

void cut_to_single_leaf(cv::Mat const &input, std::string const &num)
{    
    cv::Mat fore_ground_edge;
    cv::cvtColor(input, fore_ground_edge, CV_BGR2GRAY);
    cv::Canny(fore_ground_edge, fore_ground_edge, 100, 350);        

    cv::Mat result = input.clone();
    std::vector<cv::Vec4i> lines;
    cv::HoughLinesP(fore_ground_edge, lines, 1, CV_PI/180, 80, 0, 40);
    for( auto const &line : lines){
        cv::line(result, cv::Point(line[0], line[1]),
                cv::Point(line[2], line[3]), cv::Scalar(0,0,0), 2, 8);
    }

    cv::Mat binary_result;
    cv::cvtColor(result, binary_result, CV_BGR2GRAY);
    ContoursType contours;
    cv::findContours(binary_result, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
    gray_result.setTo(0);
    OCV::remove_contours(contours, 500, 50000);
    std::cout<<contours.size()<<std::endl;
    cv::drawContours(binary_result, contours, -1, cv::Scalar(255), 2);         

    cv::waitKey();
}

The results

hough lines binary results

The results are far from perfect The leftmost leaf are separated to two leafs The center leaf are glue as one leaf

Question 1 : Any good idea to find out which contours should merge together? ex : leftmost contours should apply dilation since it is splited to two leafts

Question 2 : How could I open the leaf of center? try erosion and open, but the results are not good, hard to predict

Question 3 : Any other algorithms are good to detect multiple similar objects in a still image? just study SIFT and SURF, they could not detect multiple objects in a still image. I can not separate the image into different ROI and apply SIFT or SURF, because the orientation of the leafs are different in the images. Question 2 :

Detect multiple similar in a bunch of still images

before segmentation after segmentation

There are 5 leafs stick together after segmentation(I do it by watershed), how could I separate the whole leaf into 5 independent leaf(blob)?

I am a newbie of computer vision, there are tons of algorithms I haven't learned yet.Now I am studying how to use surf and sift to recognize the object, is it possible to use sift to segment in into 5 independent leafs(do not glue them together)?

Any algorithms are possible to solve this problem?

Edit : According to the suggestion of GilLevi, GilLevi(thanks), i use houghLinesP to draw the lines on the image after segmentation.

//remove contours size which smaller than cmin or bigger than cmax
void remove_contours(std::vector<std::vector<cv::Point> > &contours, double cmin, double cmax)
{            
    auto it = std::partition(std::begin(contours), std::end(contours), [=](std::vector<cv::Point> const &data)
    {
       auto const size = cv::contourArea(data);
       return !(size < cmin || size > cmax);
    });
    contours.erase(it, std::end(contours));
}

void cut_to_single_leaf(cv::Mat const &input, std::string const &num)
{    
    cv::Mat fore_ground_edge;
    cv::cvtColor(input, fore_ground_edge, CV_BGR2GRAY);
    cv::Canny(fore_ground_edge, fore_ground_edge, 100, 350);        

    cv::Mat result = input.clone();
    std::vector<cv::Vec4i> lines;
    cv::HoughLinesP(fore_ground_edge, lines, 1, CV_PI/180, 80, 0, 40);
    for( auto const &line : lines){
        cv::line(result, cv::Point(line[0], line[1]),
                cv::Point(line[2], line[3]), cv::Scalar(0,0,0), 2, 8);
    }

    cv::Mat binary_result;
    cv::cvtColor(result, binary_result, CV_BGR2GRAY);
    ContoursType contours;
    cv::findContours(binary_result, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
    gray_result.setTo(0);
    OCV::remove_contours(contours, 500, 50000);
    std::cout<<contours.size()<<std::endl;
    cv::drawContours(binary_result, contours, -1, cv::Scalar(255), 2);         

    cv::waitKey();
}

The results

hough lines binary results

The results are far from perfect The leftmost leaf are separated to two leafs The center leaf are glue as one leaf

Question 1 : Any good idea to find out which contours should merge together? ex : leftmost contours should apply dilation since it is splited to two leafts

Question 2 : How could I open the leaf of center? try erosion and open, but the results are not good, hard to predict

Question 3 : Any other algorithms are good to detect multiple similar objects in a still image? just study SIFT and SURF, they could not detect multiple objects in a still image. I can not separate the image into different ROI and apply SIFT or SURF, because the orientation of the leafs are different in the images. Question 2 :

Detect multiple similar objects in a bunch of still images

before segmentation after segmentation

There are 5 leafs stick together after segmentation(I do it by watershed), how could I separate the whole leaf into 5 independent leaf(blob)?

I am a newbie of computer vision, there are tons of algorithms I haven't learned yet.Now I am studying how to use surf and sift to recognize the object, is it possible to use sift to segment in into 5 independent leafs(do not glue them together)?

Any algorithms are possible to solve this problem?

Edit : According to the suggestion of GilLevi(thanks), i use houghLinesP to draw the lines on the image after segmentation.

//remove contours size which smaller than cmin or bigger than cmax
void remove_contours(std::vector<std::vector<cv::Point> > &contours, double cmin, double cmax)
{            
    auto it = std::partition(std::begin(contours), std::end(contours), [=](std::vector<cv::Point> const &data)
    {
       auto const size = cv::contourArea(data);
       return !(size < cmin || size > cmax);
    });
    contours.erase(it, std::end(contours));
}

void cut_to_single_leaf(cv::Mat const &input, std::string const &num)
{    
    cv::Mat fore_ground_edge;
    cv::cvtColor(input, fore_ground_edge, CV_BGR2GRAY);
    cv::Canny(fore_ground_edge, fore_ground_edge, 100, 350);        

    cv::Mat result = input.clone();
    std::vector<cv::Vec4i> lines;
    cv::HoughLinesP(fore_ground_edge, lines, 1, CV_PI/180, 80, 0, 40);
    for( auto const &line : lines){
        cv::line(result, cv::Point(line[0], line[1]),
                cv::Point(line[2], line[3]), cv::Scalar(0,0,0), 2, 8);
    }

    cv::Mat binary_result;
    cv::cvtColor(result, binary_result, CV_BGR2GRAY);
    ContoursType contours;
    cv::findContours(binary_result, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
    gray_result.setTo(0);
    OCV::remove_contours(contours, 500, 50000);
    std::cout<<contours.size()<<std::endl;
    cv::drawContours(binary_result, contours, -1, cv::Scalar(255), 2);         

    cv::waitKey();
}

The results

hough lines binary results

The results are far from perfect The leftmost leaf are separated to two leafs The center leaf are glue as one leaf

Question 1 : Any good idea to find out which contours should merge together? ex : leftmost contours should apply dilation since it is splited to two leafts

Question 2 : How could I open the leaf of center? try erosion and open, but the results are not good, hard to predict

Question 3 : Any other algorithms are good to detect multiple similar objects in a still image? just study SIFT and SURF, they could not detect multiple objects in a still image. I can not separate the image into different ROI and apply SIFT or SURF, because the orientation of the leafs are different in the images. Question 2 :

Detect multiple similar objects in a bunch of still images

before segmentation after segmentation

There are 5 leafs stick together after segmentation(I do it by watershed), how could I separate the whole leaf into 5 independent leaf(blob)?

I am a newbie of computer vision, there are tons of algorithms I haven't learned yet.Now I am studying how to use surf and sift to recognize the object, is it possible to use sift to segment in into 5 independent leafs(do not glue them together)?

yet. Any algorithms are possible to solve this problem?

Edit : According to the suggestion of GilLevi(thanks), i use houghLinesP to draw the lines on the image after segmentation.

//remove contours size which smaller than cmin or bigger than cmax
void remove_contours(std::vector<std::vector<cv::Point> > &contours, double cmin, double cmax)
{            
    auto it = std::partition(std::begin(contours), std::end(contours), [=](std::vector<cv::Point> const &data)
    {
       auto const size = cv::contourArea(data);
       return !(size < cmin || size > cmax);
    });
    contours.erase(it, std::end(contours));
}

void cut_to_single_leaf(cv::Mat const &input, std::string const &num)
{    
    cv::Mat fore_ground_edge;
    cv::cvtColor(input, fore_ground_edge, CV_BGR2GRAY);
    cv::Canny(fore_ground_edge, fore_ground_edge, 100, 350);        

    cv::Mat result = input.clone();
    std::vector<cv::Vec4i> lines;
    cv::HoughLinesP(fore_ground_edge, lines, 1, CV_PI/180, 80, 0, 40);
    for( auto const &line : lines){
        cv::line(result, cv::Point(line[0], line[1]),
                cv::Point(line[2], line[3]), cv::Scalar(0,0,0), 2, 8);
    }

    cv::Mat binary_result;
    cv::cvtColor(result, binary_result, CV_BGR2GRAY);
    ContoursType contours;
    cv::findContours(binary_result, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
    gray_result.setTo(0);
    OCV::remove_contours(contours, 500, 50000);
    std::cout<<contours.size()<<std::endl;
    cv::drawContours(binary_result, contours, -1, cv::Scalar(255), 2);         

    cv::waitKey();
}

The results

hough lines binary results

The results are far from perfect The leftmost leaf are separated to two leafs The center leaf are glue as one leaf

Question 1 : Any good idea to find out which contours should merge together? ex : leftmost contours should apply dilation since it is splited to two leafts

Question 2 : How could I open the leaf of center? try erosion and open, but the results are not good, hard to predict

Question 3 : Any other algorithms are good to detect multiple similar objects in a still image? just study SIFT and SURF, they could not detect multiple objects in a still image. I can not separate the image into different ROI and apply SIFT or SURF, because the orientation of the leafs are different in the images. Question 2 :images.

Detect multiple similar objects in a bunch of still images

before segmentation after segmentation

There are 5 leafs stick together after segmentation(I do it by watershed), how could I separate the whole leaf into 5 independent leaf(blob)?

I am a newbie of computer vision, there are tons of algorithms I haven't learned yet. Any algorithms are possible to solve this problem?

Edit : According to the suggestion of GilLevi(thanks), i use houghLinesP to draw the lines on the image after segmentation.

//remove contours size which smaller than cmin or bigger than cmax
void remove_contours(std::vector<std::vector<cv::Point> > &contours, double cmin, double cmax)
{            
    auto it = std::partition(std::begin(contours), std::end(contours), [=](std::vector<cv::Point> const &data)
    {
       auto const size = cv::contourArea(data);
       return !(size < cmin || size > cmax);
    });
    contours.erase(it, std::end(contours));
}

void cut_to_single_leaf(cv::Mat const &input, std::string const &num)
&input)
{    
    cv::Mat fore_ground_edge;
    cv::cvtColor(input, fore_ground_edge, CV_BGR2GRAY);
    cv::Canny(fore_ground_edge, fore_ground_edge, 100, 350);        

    cv::Mat result = input.clone();
    std::vector<cv::Vec4i> lines;
    cv::HoughLinesP(fore_ground_edge, lines, 1, CV_PI/180, 80, 0, 40);
    for( auto const &line : lines){
        cv::line(result, cv::Point(line[0], line[1]),
                cv::Point(line[2], line[3]), cv::Scalar(0,0,0), 2, 8);
    }

    cv::Mat binary_result;
    cv::cvtColor(result, binary_result, CV_BGR2GRAY);
    ContoursType contours;
    cv::findContours(binary_result, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
    gray_result.setTo(0);
    OCV::remove_contours(contours, 500, 50000);
    std::cout<<contours.size()<<std::endl;
    cv::drawContours(binary_result, contours, -1, cv::Scalar(255), 2);         

    cv::waitKey();
}

The results

hough lines binary results

The results are far from perfect perfect. The leftmost leaf are separated to two leafs leafs. The center leaf are glue as one leafleaf.

Question 1 : Any good idea to find out which contours should merge together? ex : leftmost contours should apply dilation since it is splited to two leafts

Question 2 : How could I open the leaf of center? try erosion and open, but the results are not good, hard to predict

Question 3 : Any other algorithms are good to detect multiple similar objects in a still image? just study SIFT and SURF, they could not detect multiple objects in a still image. I can not separate the image into different ROI and apply SIFT or SURF, because the orientation of the leafs are different in the images.

Detect multiple similar objects in a bunch of still images

before segmentation after segmentation

There are 5 leafs stick together after segmentation(I do it by watershed), how could I separate the whole leaf into 5 independent leaf(blob)?leaf(blob)?The ultimate purpose is collect the BGR value of each leaf(leaf1, leaf2, leaf3, leaf4 and so on).

I am a newbie of computer vision, there are tons of algorithms I haven't learned yet. Any algorithms are possible to solve this problem?

Edit : According to the suggestion of GilLevi(thanks), i use houghLinesP to draw the lines on the image after segmentation.

//remove contours size which smaller than cmin or bigger than cmax
void remove_contours(std::vector<std::vector<cv::Point> > &contours, double cmin, double cmax)
{            
    auto it = std::partition(std::begin(contours), std::end(contours), [=](std::vector<cv::Point> const &data)
    {
       auto const size = cv::contourArea(data);
       return !(size < cmin || size > cmax);
    });
    contours.erase(it, std::end(contours));
}

void cut_to_single_leaf(cv::Mat const &input)
{    
    cv::Mat fore_ground_edge;
    cv::cvtColor(input, fore_ground_edge, CV_BGR2GRAY);
    cv::Canny(fore_ground_edge, fore_ground_edge, 100, 350);        

    cv::Mat result = input.clone();
    std::vector<cv::Vec4i> lines;
    cv::HoughLinesP(fore_ground_edge, lines, 1, CV_PI/180, 80, 0, 40);
    for( auto const &line : lines){
        cv::line(result, cv::Point(line[0], line[1]),
                cv::Point(line[2], line[3]), cv::Scalar(0,0,0), 2, 8);
    }

    cv::Mat binary_result;
    cv::cvtColor(result, binary_result, CV_BGR2GRAY);
    ContoursType contours;
    cv::findContours(binary_result, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
    gray_result.setTo(0);
    OCV::remove_contours(contours, 500, 50000);
    std::cout<<contours.size()<<std::endl;
    cv::drawContours(binary_result, contours, -1, cv::Scalar(255), 2);         

    cv::waitKey();
}

The results

hough lines binary results

The results are far from perfect. The leftmost leaf are separated to two leafs. The center leaf are glue as one leaf.

Question 1 : Any good idea to find out which contours should merge together? ex : leftmost contours should apply dilation since it is splited to two leafts

Question 2 : How could I open the leaf of center? try erosion and open, but the results are not good, hard to predict

Question 3 : Any other algorithms are good to detect multiple similar objects in a still image? just study SIFT and SURF, they could not detect multiple objects in a still image. I can not separate the image into different ROI and apply SIFT or SURF, because the orientation of the leafs are different in the images.

Detect multiple similar objects in a bunch of still images

before segmentation after segmentation

There are 5 leafs stick together after segmentation(I do it by watershed), how 00 01 02

How could I separate the whole leaf into 5 independent leaf(blob)?The ultimate purpose is collect the BGR value of each leaf(leaf1, leaf2, leaf3, leaf4 and so on).

I am a newbie of computer vision, there are tons of algorithms I haven't learned yet. Any algorithms are possible to solve this problem?

Edit : According to the suggestion of GilLevi(thanks), i use houghLinesP to draw the lines on the image after segmentation.

//remove contours size which smaller than cmin or bigger than cmax
void remove_contours(std::vector<std::vector<cv::Point> > &contours, double cmin, double cmax)
{            
    auto it = std::partition(std::begin(contours), std::end(contours), [=](std::vector<cv::Point> const &data)
    {
       auto const size = cv::contourArea(data);
       return !(size < cmin || size > cmax);
    });
    contours.erase(it, std::end(contours));
}

void cut_to_single_leaf(cv::Mat const &input)
{    
    cv::Mat fore_ground_edge;
    cv::cvtColor(input, fore_ground_edge, CV_BGR2GRAY);
    cv::Canny(fore_ground_edge, fore_ground_edge, 100, 350);        

    cv::Mat result = input.clone();
    std::vector<cv::Vec4i> lines;
    cv::HoughLinesP(fore_ground_edge, lines, 1, CV_PI/180, 80, 0, 40);
    for( auto const &line : lines){
        cv::line(result, cv::Point(line[0], line[1]),
                cv::Point(line[2], line[3]), cv::Scalar(0,0,0), 2, 8);
    }

    cv::Mat binary_result;
    cv::cvtColor(result, binary_result, CV_BGR2GRAY);
    ContoursType contours;
    cv::findContours(binary_result, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
    gray_result.setTo(0);
    OCV::remove_contours(contours, 500, 50000);
    std::cout<<contours.size()<<std::endl;
    cv::drawContours(binary_result, contours, -1, cv::Scalar(255), 2);         

    cv::waitKey();
}

The resultsresults(use first image as an example)

hough lines binary results

The results are far from perfect. The leftmost leaf are separated to two leafs. The center leaf are glue as one leaf.

Question 1 : Any good idea to find out which contours should merge together? ex : leftmost contours should apply dilation since it is splited to two leafts

Question 2 : How could I open the leaf of center? try erosion and open, but the results are not good, hard to predict

Question 3 : Any other algorithms are good to detect multiple similar objects in a still image? just study SIFT and SURF, they could not detect multiple objects in a still image. I can not separate the image into different ROI and apply SIFT or SURF, because the orientation of the leafs are different in the images.

Detect multiple similar objects in a bunch of still images

00 01 02

How could I separate the whole leaf into 5 independent leaf(blob)?The ultimate purpose is collect the BGR value of each leaf(leaf1, leaf2, leaf3, leaf4 and so on).

I am a newbie of computer vision, there are tons of algorithms I haven't learned yet. Any algorithms are possible to solve this problem?

Edit : According to the suggestion of GilLevi(thanks), i use houghLinesP to draw the lines on the image after segmentation.

//remove contours size which smaller than cmin or bigger than cmax
void remove_contours(std::vector<std::vector<cv::Point> > &contours, double cmin, double cmax)
{            
    auto it = std::partition(std::begin(contours), std::end(contours), [=](std::vector<cv::Point> const &data)
    {
       auto const size = cv::contourArea(data);
       return !(size < cmin || size > cmax);
    });
    contours.erase(it, std::end(contours));
}

void cut_to_single_leaf(cv::Mat const &input)
{    
    cv::Mat fore_ground_edge;
    cv::cvtColor(input, fore_ground_edge, CV_BGR2GRAY);
    cv::Canny(fore_ground_edge, fore_ground_edge, 100, 350);        

    cv::Mat result = input.clone();
    std::vector<cv::Vec4i> lines;
    cv::HoughLinesP(fore_ground_edge, lines, 1, CV_PI/180, 80, 0, 40);
    for( auto const &line : lines){
        cv::line(result, cv::Point(line[0], line[1]),
                cv::Point(line[2], line[3]), cv::Scalar(0,0,0), 2, 8);
    }

    cv::Mat binary_result;
    cv::cvtColor(result, binary_result, CV_BGR2GRAY);
    ContoursType contours;
    cv::findContours(binary_result, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
    gray_result.setTo(0);
    OCV::remove_contours(contours, 500, 50000);
    std::cout<<contours.size()<<std::endl;
    cv::drawContours(binary_result, contours, -1, cv::Scalar(255), 2);         

    cv::waitKey();
}

The results(use first image as an example)

hough lines binary results

The results are far from perfect. The leftmost leaf are separated to two leafs. The center leaf are glue as one leaf.

Question 1 : Any good idea to find out which contours should merge together? ex : leftmost contours should apply dilation since it is splited to two leafts

Question 2 : How could I open the leaf of center? try erosion and open, but the results are not good, hard to predict

Question 3 : Any other algorithms are good to detect multiple similar objects in a still image? just study SIFT and SURF, they could not detect multiple objects in a still image. I can not separate the image into different ROI and apply SIFT or SURF, because the orientation of the leafs are different in the images.