Reputation: 1749
I used houghLines transformation to detect lines in an image and I draw the lines detected by that on a separate Mat image using cv::line() function. Note that the lines detected by houghLinesP are usually overlapping with each other and high in number. (even if there is 1 line in the image it will detect number of adjacent lines for it)
for (size_t i = 0; i < lines.size(); i++)
{
Vec4i l = lines[i];
line(src, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 255, 0), 10, CV_AA);
}
I wanted to draw the lines in solid green color without any transparency. But in the resulting image I noticed that some lines at the edges are transparent. (or the borders of lines are blurred) Following is a part of my resulting image.
I want to avoid this. I want to have sharp edges for the lines and should not have any transparency. How to do it?
Upvotes: 0
Views: 445
Reputation: 17285
The CV_AA
flag tell cv::line()
to draw an Anti-Aliased line. This is the source of your transparent line border pixels.
If you remove the CV_AA
flag, the line will be drawn jagged, but without transparencies (Bresenham).
Looking more closely at the image there are visible JPG artifacts inside the colored area (sporadic darker spots). These artifacts to not exist in the image in memory but will appear in a JPG saved file. Try saving your image as PNG.
Upvotes: 4