0

Is there a way to plot colored points (or rectangles) on a black and white image using OpenCV? My image was typically created using CV_8UC1: it's a 8 bits unsigned char image.

herohuyongtao
  • 49,413
  • 29
  • 133
  • 174
PhonoDots
  • 149
  • 1
  • 12

1 Answers1

3

You need to convert the image to colored image (e.g. 3 channels) first in order to draw and display colors.

Mat img_rgb(img_gray.size(), CV_8UC3);
cvtColor(img_gray, img_rgb, CV_GRAY2RGB);

See a similar question openCV - draw color contours on greyscale image.

Community
  • 1
  • 1
herohuyongtao
  • 49,413
  • 29
  • 133
  • 174