After cvtcolor
, your grayscale image is in one channel. Change it back to three channel after you have performed threshold
. So, between threshold
and addWeighted
, add the statement:
cv::cvtColor ( copy, copy, CV_GRAY2BGR );
Also, I am not sure what you want to achieve. If you want to just extract the regions that are white, you are better off using the cv::bitwise_and
.