Ask Your Question

Revision history [back]

black out everything outside the 2 lines

I perform the hough transform on image to detect lines. but I want to blackout everything outside the 2 lines... i get this kind of output

image description

but i want this type of output..

image description

i used this code..

vector<Vec2f> lines;
HoughLines(dst, lines, 1, 2*CV_PI/180, 70, 0, 0 );
for( size_t i = 0; i < lines.size(); i++ )
{
    float rho = lines[i][0], theta = lines[i][1];
    Point pt1, pt2;
    double a = cos(theta), b = sin(theta);
    double x0 = a*rho, y0 = b*rho;
    pt1.x = cvRound(x0 + 1000*(-b));
    pt1.y = cvRound(y0 + 1000*(a));
    pt2.x = cvRound(x0 - 1000*(-b));
    pt2.y = cvRound(y0 - 1000*(a));
    line( src, pt1, pt2, Scalar(0,0,255), 3, CV_AA);
}

any suggestion..

black out everything outside the 2 lines

I perform the hough transform on image to detect lines. but I want to blackout everything outside the 2 lines... i get this kind of output

image description

but i want this type of output..

image description

i used this code..

vector<Vec2f> lines;
HoughLines(dst, lines, 1, 2*CV_PI/180, 70, 0, 0 );
for( size_t i = 0; i < lines.size(); i++ )
{
    float rho = lines[i][0], theta = lines[i][1];
    Point pt1, pt2;
    double a = cos(theta), b = sin(theta);
    double x0 = a*rho, y0 = b*rho;
    pt1.x = cvRound(x0 + 1000*(-b));
    pt1.y = cvRound(y0 + 1000*(a));
    pt2.x = cvRound(x0 - 1000*(-b));
    pt2.y = cvRound(y0 - 1000*(a));
    line( src, pt1, pt2, Scalar(0,0,255), 3, CV_AA);
}

any suggestion..