Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to draw line?

Hi guys, Have anyone could help me resolve this issue, or have any idea. Original

water_4 copy

After applying a series of algorithms, I have the following result. screenshot from 2018-08-29 13-25-38 copy

How to draw line look like bellow. screenshot from 2018-08-29 13-25-38

I have to apply HoughLineP but not good. wwww

Code ``` pyrMeanShiftFiltering( img, res, spatialRad, colorRad, maxPyrLevel );

//imshow( "ShiftFiltering", res );

cvtColor(res, res, COLOR_RGBA2GRAY);

GaussianBlur(res, res, Size(15, 15), 0);

//imshow( "GaussianBlur", res );
adaptiveThreshold(res, res, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY_INV, 11, 1);
//imshow( "adaptiveThreshold", res );

Mat element = getStructuringElement (MORPH_RECT, Size(3, 3));
morphologyEx(res, res, MORPH_CLOSE, element);

Mat edgs;
Canny(res, edgs, 750, 800, 3);
vector<Vec4f> lines3;
HoughLinesP(edgs, lines3, 1, CV_PI / 180, 20, 15, 10);

Mat markEdges = Mat(res.size(), CV_8UC3);
for (size_t i = 0; i < lines3.size(); i++)
{
    Vec4f l = lines3[i];
    double dest = euclideanDist(Point2f(l[0], l[1]), Point2f(l[2], l[3]));
    if (dest > 10) {
        line(markEdges, Point2f(l[0], l[1]), Point2f(l[2], l[3]), Scalar(0, 0, 255), 2, LINE_AA);
    }
}

imshow("markEdges", markEdges);

``` I have applied segment image (watershed) but not good. qqqq

How to draw line?

Hi guys, Have anyone could help me resolve this issue, or have any idea. Original

water_4 copyidea.

After applying a series of algorithms, I have the following result. screenshot from 2018-08-29 13-25-38 copy

How to draw line look like bellow. screenshot from 2018-08-29 13-25-38

I have to apply HoughLineP but not good. wwww

Code ``` pyrMeanShiftFiltering( img, res, spatialRad, colorRad, maxPyrLevel );

//imshow( "ShiftFiltering", res );

cvtColor(res, res, COLOR_RGBA2GRAY);

GaussianBlur(res, res, Size(15, 15), 0);

//imshow( "GaussianBlur", res );
adaptiveThreshold(res, res, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY_INV, 11, 1);
//imshow( "adaptiveThreshold", res );

Mat element = getStructuringElement (MORPH_RECT, Size(3, 3));
morphologyEx(res, res, MORPH_CLOSE, element);

Mat edgs;
Canny(res, edgs, 750, 800, 3);
vector<Vec4f> lines3;
HoughLinesP(edgs, lines3, 1, CV_PI / 180, 20, 15, 10);

Mat markEdges = Mat(res.size(), CV_8UC3);
for (size_t i = 0; i < lines3.size(); i++)
{
    Vec4f l = lines3[i];
    double dest = euclideanDist(Point2f(l[0], l[1]), Point2f(l[2], l[3]));
    if (dest > 10) {
        line(markEdges, Point2f(l[0], l[1]), Point2f(l[2], l[3]), Scalar(0, 0, 255), 2, LINE_AA);
    }
}

imshow("markEdges", markEdges);

``` I have applied segment image (watershed) but not good. qqqq