The error should be here:
dst->at<Vec3b>(y,x)[0] = over.at<Vec3b>(y,x)[0] == color[0] ? under.at<Vec3b>(y,x)[0] : over.at<Vec3b>(y,x)[0]; dst->at<Vec3b>(y,x)[1] = over.at<Vec3b>(y,x)[1] == color[1] ? under.at<Vec3b>(y,x)[1] : over.at<Vec3b>(y,x)[1]; dst->at<Vec3b>(y,x)[2] = over.at<Vec3b>(y,x)[2] == color[2] ? under.at<Vec3b>(y,x)[2] : over.at<Vec3b>(y,x)[2];
On first call
chromakey(blurred_input_color, canny_edges_color, &input_with_canny, Scalar(0, 0, 0));
the canny_edges_color white pixel canny_edges_color is (255, 255, 255), so in the above comparisons you will get over values ββfor each channel, so the pixel color will be (255, 255, 255) and the image will display correctly.
However, in the second case:
chromakey(input_with_canny, hough_lines, &combined_images, Scalar(0, 0, 0));
your hugh_lines red pixels have a value of (0, 0, 255), so for the first two comparisons they will get a value of under , since
over.at<Vec3b>(y,x)[0] == color[0] and
over.at<Vec3b>(y,x)[1] == color[1] .
Only dst->at<Vec3b>(y,x)[2] will get the value 255. In order for the line to appear solid, in this case it should be dst->at<Vec3b>(y,x)[0] = 0 and dst->at<Vec3b>(y,x)[1] = 0 .
Also, according to this answer , you should probably initialize * dst as follows:
*dst = Mat(under.rows,under.cols,CV_8UC3,CV_RGB(0,0,0));
since it is a 3 channel Mat.