Ask Your Question

Hough Transform example: Result of cvtColor()

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

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:

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

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

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


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

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

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 -0500 )edit

Thank you for the explanation.

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

Question Tools

1 follower


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

Seen: 168 times

Last updated: Oct 28 '16