First, let us understand how black and white images are stored in the computer in binary format. Computers use a pixel to represent the smallest unit of an image, and each pixel can only store two colors: black or white. The computer represents black as 0 and white as 1, and then arranges the color value of each pixel into a series of binary numbers in order to store the entire black and white image. Next, we'll look at how color images are stored.
Each pixel in the image is represented by a numerical value. These numerical values are called pixel values, which represent the brightness or color information of the pixel. In black and white images, pixel values usually range from 0 to 1, where 0 represents black and 1 represents white.
So every image in the computer is saved in this form, where there is a matrix of numbers, and this matrix is also called a channel.
A grayscale image is a monochrome image with only one color. Grayscale images have no color information, only shades of gray. Grayscale is not black and white, but different shades of gray. So it's called grayscale.
Normal grayscale images usually contain 8 bits/pixel data and have 256 gray levels. 12 or 16 bit/pixel images are commonly used in medical imaging and astronomy.
The pixel value of a grayscale monochrome image ranges from 0 to 255, with 0 representing the darkest color and 255 representing the lightest color.
Color images are composed of three colors: red, green, and blue. These three color channels are arranged in RGB order to form a stack. Modern color digital images also follow this principle, as all colors can be generated by mixing these three primary colors.
Processing the three-dimensional space of images sometimes becomes complex and redundant. In feature extraction, compressing the image into a two-dimensional matrix can simplify the processing. This can be achieved through grayscale scaling or binarization. Grayscale scaling is richer than binarization because it can display the image as a combination of different grayscale intensities. Binarization simply constructs a matrix composed of 0s and 1s.
Therefore, when performing computer vision (CV) tasks in machine learning, features can be extracted through compression, such as converting to grayscale or binary format.
The above is the detailed content of Application of image processing and expression in machine learning. For more information, please follow other related articles on the PHP Chinese website!