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.
Usage Scenario
This Step is widely used to convert the color space of 2D images, and there is no specific usage scenario.
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.
- 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 .
-
- 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.
- 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.
- 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.
- 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.
- 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.