Convert Color Space

Function

This Step is used to convert the color space of the image, such as converting RGB color image to grayscale and converting BGR color image to grayscale.

../../../../../_images/functional_description.png

Usage Scenario

This Step is widely used to convert the color space of 2D images, and there is no specific usage scenario.

Input and Output

../../../../../_images/input_and_output3.png

Parameter Tuning

Convert Type

BGR to Grayscale
Description: Convert the BGR color image to grayscale image.
Example: The conversion result is shown below. The figure on the left is the BGR color image and the figure on the right is the converted grayscale image.
../../../../../_images/bgr_to_gray.png
RGB to Grayscale
Description: Convert the RGB color image to grayscale image. Once this option is selected, a conversion ratio needs to be set. Usually, Psychological formula can be applied. The descriptions of the conversion methods are as follows.

Conversion Method:

  • Psychological formula: Use the classical psychological formula \(Gray = 0.299 \times R + 0.587 \times G + 0.114 \times B\) to get the weighted averages of the RGB channels, which conforms to the human eyes’ perception sensitivity to colors.

  • Average: Use the average value of R, G, and B channels for the output grayscale. The conversion formula is \(Gray = (R + G + B)/3\).

  • Max: For each pixel of the grayscale image, take the maximum value among the three pixels corresponding to the three channels R, G, and B.

  • Min: For each pixel of the grayscale image, take the minimum value among the three pixels corresponding to the three channels R, G, and B.

  • R Channel Values: Take the R channel values as the pixel values of the output grayscale image and ignore the information in other channels.

  • G Channel Values: Take the G channel values as the pixel values of the output grayscale image and ignore the information in other channels.

  • B Channel Values: Take the B channel values as the pixel values of the output grayscale image and ignore the information in other channels.

  • Custom Weights: Customize the values’ weight for the RGB channels.

Example: The figures below from left to right shows the conversion results when R Channel Values, G Channel Values, and B Channel Values are selected as the conversion method respectively.
../../../../../_images/rgb_to_gray.png
Grayscale to BGR
Description: Convert the grayscale image to BGR color image.
Example: The conversion result is shown below. The figure on the left is the grayscale image and the figure on the right is the converted BGR color image.

Hint

When converting the grayscale image to a BGR color image, the grayscale value is assigned to B, G, and R channels respectively. Since the assigned values of the three channels are the same, the converted image looks like black and white. However, it is a BGR color image with three channels in nature.

../../../../../_images/gray_to_bgr.png
Grayscale to RGB
Description: Convert the grayscale image to RGB color image.
Example: The conversion result is shown below. The figure on the left is the grayscale image and the figure on the right is the converted RGB color image.
../../../../../_images/gray_to_rgb.png
Heatmap to BGR
Description: Convert the heat map to BGR color image.
RGB to HSI
Description: Convert the RGB color image to HSI. Once this option is selected, you will need to select an output channel type.
Example: The conversion result of output in the first channel is shown below. The figure on the left is the RGB color image, and the figure on the right is the converted HSI image.
../../../../../_images/rgb_to_hsi.png
RGB to HSV
Description: Convert the RGB color image to HSV. Once this option is selected, you will need to select an output channel type.
Example: The conversion result of output in the first channel is shown below. The figure on the left is the RGB color image, and the figure on the right is the converted HSV image.
../../../../../_images/rgb_to_hsv.png
RGB to YUV
Description: Convert the RGB color image to YUV. Once this option is selected, you will need to select an output channel type.
Example: The conversion result of output in the first channel is shown below. The figure on the left is the RGB color image, and the figure on the right is the converted YUV image.
../../../../../_images/rgb_to_yuv.png