Welcome to Raspbot repository
1.Grayscale processing
The process of converting a color picture into a grayscale picture is the grayscale processing of the picture. Each pixel of color picture in a color image is determined by the three components R, G, and B, each component range 0-255, so that a pixel can have more than 16 million (256*256*256 = 1677256) colors.
The grayscale image is a special color image with the same three components of R, G, and B, the range of one pixel is 256 kinds.
Therefore, in digital image processing, we will convert images of various formats into grayscale images to reduce the amount of calculation.
The grayscale image can still reflect the overall and partial distribution of chroma and highlight levels of the picture.
The description of the gray-scale image, like the color image, still reflects the distribution and characteristics of the overall and partial chroma and highlight levels of the entire image.
Image graying
Grayscale processing is the process of converting a color image into a grayscale image. The color image is divided into three components, R, G, and B, and displays various colors such as red, green, and blue. Pixels with larger gray values are brighter (maximum pixel value is 255, white), and pixels with smaller gray values are darker (minimum pixel value is 0, black).
The core idea of image graying is R = G = B, this value is also called gray value
Image graying algorithm
1) Maximum value method: make the value of R, G, B after conversion equal to the largest one of the three values before conversion, that is: R=G=B=max (R, G, B). The brightness of grayscale image converted by this method is very high.
2) Average method: R, G, and B values after conversion are the average values of R, G, and B before conversion. That is: R=G=B=(R + G + B)/3. The grayscale image produced by this method is relatively soft.
3) Weighted average method: according to a certain weight, the weighted average of the values of R, G, and B, that is,
is the weights of R, G, and B. We can take different values to form different gray images. Since the human eye is most sensitive to green, red, and has the lowest sensitivity to blue, we can get a more easily recognizable grayscale image. This method produces the best grayscale images.
The following code contains four methods to grayscale the picture,
Code path:
/home/pi/Yahboom_Project/Raspbot/1.OpenCV_course/03IP_Draw_text_line_segments/ 06_Picture_Rotation.ipynb
|
After running the following program, grayscale picture will be displayed in the jupyterLab control interface, as shown below.
|
After running the following program, grayscale picture will be displayed in the jupyterLab control interface, as shown below.
|
After running the following program, grayscale picture will be displayed in the jupyterLab control interface, as shown below.
|
After running the following program, grayscale picture will be displayed in the jupyterLab control interface, as shown below.