Ask Your Question
2

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

asked 2018-08-09 20:00:47 -0600

updated 2018-08-26 07:41:25 -0600

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

edit retag flag offensive close merge delete

Comments

1

Take a look here

js4267 gravatar imagejs4267 ( 2018-08-09 23:09:58 -0600 )edit
1

take a look at this

sturkmen gravatar imagesturkmen ( 2018-08-10 03:39:34 -0600 )edit

thanks guys,your ideas are great. but the book need us do this work by using

cv::filter2D()

any ideas?

jsxyhelu gravatar imagejsxyhelu ( 2018-08-10 21:14:59 -0600 )edit

1 answer

Sort by » oldest newest most voted
4

answered 2018-08-11 08:43:50 -0600

js4267 gravatar image

updated 2018-08-11 08:55:15 -0600

That is a kernel for a theoretic angle of 62.5 degree.

cv::Mat1f k = (cv::Mat1f(9,9)<<
0,0,0,0,0,0,1,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,1,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,0,1,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,0,1,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
0,0,1,0,0,0,0,0,0);
edit flag offensive delete link more

Comments

that's great,thanks!

jsxyhelu gravatar imagejsxyhelu ( 2018-08-12 09:21:08 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-08-09 20:00:47 -0600

Seen: 370 times

Last updated: Aug 11 '18