Binary image, grayscale image, color image and other related knowledge sorting

In fact, after learning image processing, I basically have my own understanding of binary images, grayscale images, color images, and image channels and depths, but when it comes to actual applications, especially when image processing is performed from the perspective of code , There will always be confusion of concepts. Every time you need to search for specific knowledge points on the Internet, and then solve the problem, you will forget the knowledge points later, so here, I want to systematically sort out these knowledge points for convenience. Establish your own understanding system, after all, what you write down will always be more impressive.

Many digital image processing books will introduce these concepts in some chapters. Of course, the knowledge points introduced in the books are more detailed, but after all, they are written, and the angles of entry are not consistent. Compared with the explanations in books, I prefer to go to various forums to check netizens' understanding of these concepts. This time, I entered single-channel images, multi-channel images, binary images, grayscale images, and RGB and other related words on Google. I selected the first ten search results, which generally come from csdn, short books, Zhihu, etc. Platform, I use my own words to integrate the knowledge points and sort out the knowledge framework.

1. Digital image
An image can be defined as a two-dimensional function f(x,y) , where x and y are spatial (plane) coordinates, and the amplitude of f at any coordinate point
( x,y ) is called the image at The brightness of the point. Grayscale is a term used to represent the brightness of black and white images, while color images are formed by combining individual two-dimensional images. For example, in the RGB color system, a color image is composed of three independent component images (red, green, and blue). Therefore, many techniques developed for black-and-white image processing are applicable to color image processing by processing three independent components separately.
The image is continuous with respect to x and y coordinates and amplitude. Converting such an image into digital form requires digitizing the coordinates and amplitudes. Digitizing the coordinate values ​​is called sampling, and digitizing the amplitude is called quantization. Therefore, when the x, y components and amplitude of f are all finite and discrete quantities, the image is called a digital image. The essence of the image: a two-dimensional matrix composed of pixels

2. Common image format
bmp: uncommon, lossless, basically no compression, large size
jpg (jpeg): use the smallest disk space to get better image quality png: bit image
format with lossless compression
Animation of frame image synthesis

3. Color depth
Color depth is referred to as color depth. In the field of computer graphics, it means the number of bits used to store each pixel in a bitmap or video frame buffer. The common unit is bit/pixel (bpp). The higher the color depth, The more colors available.
To put it simply, color depth refers to the number of colors that each pixel can display ( note that it is the number of colors that can be displayed, of course, in fact, only one color is displayed per pixel ), and it is generally measured in units of "bit" or "bit". describe. The more bits, the more colors are available, and the color performance of the image is more accurate, but the file size of the image will also increase with the bit depth, because in a high bit depth image, each pixel stores Greater color information.

4. Explanation of "bit"
The computer processes and stores information in binary form, so any information entering the computer will become a combination of different digits of 1 and 0, and the same is true for colors.
For example, the color depth of 1 bit can only display 0 or 1 in the computer, so there are only two kinds of color information that can be displayed, white or black. When we increase the color depth to 2 bits, there will be: 00, 01, 10, 11, 4 (2^2) combinations, resulting in a relatively simple black-white-gray relationship. When the color depth reaches 3 bits, it will bring 8 different combinations: 000, 001, 010, 011, 100, 101, 110, 111, and the transition between black, white and gray will become more detailed. It can be seen that every time the number of digits increases, the combination method will bring about a double increase. Of course we are talking about black and white images here

5. Image channel
Single channel: also known as the grayscale image, each pixel has only one value, if the image depth is 8bit, then the pixel value is 0 (black) ~ 255 (white); three channels
: That is to say, through the color map seen, each pixel is represented by three values. If the image depth is 8bit, then the pixel value is superimposed to represent red, green, and blue, and each value is (0~255); four channels
: That is to add transparency on the basis of the three-channel image. In the transparency channel, if the image depth is 8bit, then 0 is completely transparent, and 255 is completely opaque.

6. Binary image
A binary image refers to an image in which each pixel is black or white. By definition, it refers to an image in which each pixel has only two values ​​(black and white), that is, each pixel on the image There are only two possible values ​​or grayscale states.
When the bit depth is 1, each pixel of the binary image has only two values ​​0 and 1, where 0 means black and 1 means white, so the binary image generally looks like this: because each pixel of the binary image has only
insert image description here
two value, so each pixel only needs 1 bit to store.
In the grayscale image, the binary image of the image is to set the grayscale value on the image to 0 or 255, that is, to present the entire image with only black and white visual effects.

7. Grayscale image (single channel image, black and white image)
grayscale image, also known as grayscale image. The logarithmic relationship between white and black is divided into several levels, called gray scale. An image represented in grayscale is called a grayscale image. The grayscale image we commonly call is generally a single-channel image ( because when the values ​​​​of the three-channel images are the same, the image looks the same as the grayscale image, but it is essentially different from the grayscale image. In other words, the three-channel image can look like Grayscale image, but a single-channel image can only be a grayscale image ), compared with a binary image with only 1bit storage space, a single-channel grayscale image is represented by a single pixel through an 8bit grayscale value (0-255) , the value range of each pixel is between [0~255]. So different from the binary image, the grayscale image has richer colors, not only white and black, but also various grays, which are divided into 256 levels in total. For example, a single-channel grayscale image of 500*500 pixels is composed of 500X500=250,000 pixels of different grayscales. ( In fact, it can be understood that a binary image is a type of grayscale image, but its pixel values ​​​​are only black and white. 2bit storage is the minimum requirement for a binary image, but the pixel values ​​​​in an 8bit grayscale image only take 0 and 255, can also achieve the effect of a binary image. )
The grayscale image is as follows:
insert image description here
8. Color image (RGB image, three-channel image)
A color image is usually composed of several superimposed color channels, and each channel represents a given channel value. The color image we refer to in image processing generally refers to an RGB image. Compared with a gray image, it is a single-channel image, that is, each pixel has only 1 component, and each pixel of RGB has 3 components (also called 3 channels). consists of separate red, green and blue primary color components. So RGB can be used to represent color images. Compared with grayscale images, RGB has additional color information.
The GRB image is shown below:
insert image description here
The figure below shows an example of the color channel splitting of a complete RGB color image, the left column shows the isolated color channels of natural colors, and the right figure shows their grayscale equivalents .
insert image description here
9. Vector graphics
Binary images, grayscale images, and RGB images are all called bitmaps, which are stored in the form of a matrix. The rows and columns of the matrix determine the size of the image, and the information of the lines and blocks saved in the vector graphics, so vector graphics files and resolution The rate has nothing to do with the size of the image, but only with the complexity of the image, and the storage space occupied by the image file is small.
Several advantages of vector graphics:
·The image can be scaled infinitely, and the graphics will not produce jagged effects when zooming, rotating or deforming the graphics.
High-resolution printing is available, and vector graphic files can be printed and output on any output device printer with the highest resolution for printing or printing.
Vector graphics are infinitely magnified without blurring, while bitmaps become more blurred as they are enlarged

Guess you like

Origin blog.csdn.net/weixin_43352502/article/details/128979737