Convert Color Space

You are viewing an old version of the documentation. You can switch to the documentation of the latest version by clicking the top-right corner of the page.

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.

convert color space functional description

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

convert color space input and output

Parameter Tuning

Conversion Mode

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.

convert color space bgr to gray
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.299R + 0.587G + 0.114B 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 .

convert color space rgb to gray
Grayscale to BGR

Description: Convert the grayscale image to BGR color image.

Example: The conversion result is shown below. 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.

During the conversion from the grayscale image to a BGR color image, the grayscale value is assigned to B, G, and R channels. 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.

convert color space gray to bgr
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.

convert color space gray to rgb
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.

convert color space rgb to hsi
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.

convert color space rgb to hsv
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.

convert color space rgb to yuv

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.