measure a curved petiole

asked 2020-02-26 09:24:19 -0600

SylvainArd gravatar image

updated 2020-11-08 05:13:01 -0600

Hello I want to measure the length of a bramble petiole so there are spines and it is often curved. Ideas please ? Thank you :) Bye

Hi I am trying to extract the petiole of a leaf even if it is very small andif there are tooth on the leaf. An idea ? Thank you :) Bye

Hi I am trying to extract the midrib of a leaf Here is my code :

int main( int argc, char** argv )
{
    src = imread(  "foliole1.jpg" , IMREAD_COLOR ); // Load an image

    Mat drawing = src.clone();

    Mat bgr[3];   //destination array
    split(src,bgr);//split source
    src_gray=bgr[1];//green channel
    imwrite("gray.bmp",src_gray);

    Mat grayBlurred;
    blur( src_gray, grayBlurred, Size(4,4) );

    Mat detected_edges_canny;
    Canny( grayBlurred, detected_edges_canny,50,100,3);
    imwrite("grayBlurred.jpg",grayBlurred);
    imwrite("detected_edges_canny.jpg",detected_edges_canny);
    vector<Vec4i> lines;
    HoughLinesP(detected_edges_canny, lines, 1, CV_PI/360, 30,100, 20);
    double maxLength=0;
    bool found;
    Segment midRib;
    Mat segments=src.clone();
    for( size_t i = 0; i < lines.size(); i++ )
    {
        Vec4i l = lines[i];
        Segment S=Segment(Point(l[0], l[1]), Point(l[2], l[3]));
        S.draw(segments,2,Scalar(0,0,255));
        if (S.getLength()>maxLength)
        {
            midRib=S;
            found=true;
            maxLength=S.getLength();
        }
    }
    imwrite("segments.jpg",segments);
    Mat midrib=src.clone();
    midRib.draw(midrib,2,Scalar(0,0,255));
    imwrite("midrib.jpg",midrib);
}

and the images are at : http://sylvain-ard.fr/temp/ like you can see it doen't works. please help me thank you :) bye

Hi, for doing several spines measurements I want firstly to extract the contour of the underside of bramble stems. For example for this image : http://www.sylvain-ard.fr/temp/image2... I want the contours in red in this image : http://www.sylvain-ard.fr/temp/image.jpg other examples of stems are : http://www.sylvain-ard.fr/temp/image3... http://www.sylvain-ard.fr/temp/image4... Thank you ! Best regards

edit retag flag offensive close merge delete

Comments

You wanna to remove stem?

supra56 gravatar imagesupra56 ( 2020-04-10 22:18:44 -0600 )edit

No to detect them but it's goodI suceeded

SylvainArd gravatar imageSylvainArd ( 2020-04-11 03:03:24 -0600 )edit

You wanna contour on red but not on top or both? Is that right?

supra56 gravatar imagesupra56 ( 2020-04-11 21:44:27 -0600 )edit

yes but I succeeded, thank you

SylvainArd gravatar imageSylvainArd ( 2020-04-12 05:00:16 -0600 )edit

I succeeded

SylvainArd gravatar imageSylvainArd ( 2020-04-12 05:01:30 -0600 )edit

Post result image. Will you?

supra56 gravatar imagesupra56 ( 2020-04-12 07:28:15 -0600 )edit