Ask Your Question

Revision history [back]

how to detect only 60-degree lines (a question from 《learning opencv3》chapter 10)

hi,guys learningOpencv3 chapter10 question15 ,says

15 Use cv::filter2D() to create a filter that detects only 60-degree lines in an image. Display the results on a sufficiently interesting image scene.

I know how to detects 45-degree lines ,as

Mat srcLines(100,100,CV_8UC1,Scalar::all(0));//draw lines
line(srcLines,Point(0,0),Point(100,100),Scalar(255),1);
line(srcLines,Point(50,50),Point(100,0),Scalar(255),1);//45 - degree
line(srcLines,Point(0,100),Point(50,0),Scalar(255),1);//60 - degree
Mat srcH(3,3,CV_8UC1,Scalar::all(0));

srcH.at<char>(0,0) = 255;
srcH.at<char>(1,1) = 255;
srcH.at<char>(2,2) = 255;

filter2D(srcLines,dst,srcLines.depth(),srcH);

but ,how to create a 60-degree kenrel? any help will be welcomed. thanks

how to detect only 60-degree lines (a question from 《learning opencv3》chapter 10)

hi,guys learningOpencv3 chapter10 question15 ,says

15 Use cv::filter2D() to create a filter that detects only 60-degree lines in an image. Display the results on a sufficiently interesting image scene.

I know how to detects 45-degree lines ,as

Mat srcLines(100,100,CV_8UC1,Scalar::all(0));//draw lines
line(srcLines,Point(0,0),Point(100,100),Scalar(255),1);
line(srcLines,Point(50,50),Point(100,0),Scalar(255),1);//45 - degree
line(srcLines,Point(0,100),Point(50,0),Scalar(255),1);//60 - degree
Mat srcH(3,3,CV_8UC1,Scalar::all(0));

srcH.at<char>(0,0) = 255;
srcH.at<char>(1,1) = 255;
srcH.at<char>(2,2) = 255;

filter2D(srcLines,dst,srcLines.depth(),srcH);

but ,how to create a 60-degree kenrel? any help will be welcomed. thanks