template<int code, int ROWS, int COLS, int SRC_T, int DST_T>
void hls::CvtColor( hls::Mat<ROWS, COLS, SRC_T>& src,
                    hls::Mat<ROWS, COLS, DST_T>& dst );


  • src – the input image.
  • dst – the output image.
  • code – template parameter of type of color conversion.


Converts a color image from/to a grayscale image. The type of conversion is defined by the value of code:
  • HLS_RGB2GRAY convert a RGB color image to a grayscale image.
  • HLS_BGR2GRAY convert a BGR color image to a grayscale image.
  • HLS_GRAY2RGB convert a grayscale image to a RGB image.

Image data must be stored in src, the image data of dst must be empty before invocations. Invoking this function will consume the data in src, and filling the image data of dst.
src and dstmust have the same size and required number of channels.

OpenCV reference

cvCvtColor, cv::cvtColor