Ask Your Question
0

Hough Transform example: Result of cvtColor()

asked 2016-10-28 21:55:43 -0600

skr_robo gravatar image

I am learning to implement Hough transform and I have this example program from OpenCV documentation. It contains the following two lines of code:

Canny(src,dst,50,200,3);
cvtColor(dst,cdst, CV_GRAY2BGR);

I tried displaying both dst and cdst. Both these images look the same. So, I wonder why cvtColor is applied? Is cdst created for the sole purpose of displaying lines detected in dst?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-10-28 22:09:46 -0600

Tetragramm gravatar image

It's so that it can draw lines in color. The canny edges are white, but it draws on that cdst image in blue and red to show the lines it detects.

edit flag offensive delete link more

Comments

But the cdst edges are also white. I don't get your point.

skr_robo gravatar imageskr_robo ( 2016-10-28 22:18:58 -0600 )edit
1

Look at the tutorial you linked.

line( cdst, pt1, pt2, Scalar(0,0,255), 3, CV_AA);

This draws on the image. But if it were to draw on dst, it could only draw a white line on top of the existing white lines because there's only one channel. With three channels in cdst, it can draw in colors, in this case, red.

Tetragramm gravatar imageTetragramm ( 2016-10-29 00:05:38 -0600 )edit

Thank you for the explanation.

skr_robo gravatar imageskr_robo ( 2016-10-31 22:08:40 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-10-28 21:55:43 -0600

Seen: 271 times

Last updated: Oct 28 '16