Four types of images

Source: Internet
Author: User

In a computer, you can divide an image into four basic types, depending on how much color and grayscale you have.

1. Two value image

2. Grayscale image

3. Indexed images

4. True Color RGB image

1. Two value image

A two-value image of the two-dimensional matrix only consists of 0, 12 values, "0" stands for Black, "1" generation of white. Since each pixel (each element in the matrix) has only 0 or 12 possible values, the data type of the binary image in the computer is usually 1 bits. Binary images are commonly used for the storage of text, line graph scanning recognition (OCR), and masking images.

2. Grayscale image

The range of gray image matrix elements is usually [0,255]. Therefore, the data type is generally 8-bit unsigned integer (int8), which is often referred to as 256 grayscale images. "0" means pure black, "255" for pure white, the middle of the number from small to large to represent the transition color from black to white. In some software, grayscale images can also be represented by a double data type (double), with a range of pixels of [0,1],0 for Black, 1 for white, and a decimal between 0 and 1 to represent different grayscale levels. Binary images can be considered as a special case of grayscale images.

3. Indexed images

The file structure of indexed images is rather complex, in addition to the two-dimensional matrix of images, a two-dimensional array called color index matrix map is included. The size of the map is determined by the value of the matrix element that holds the image, such as the matrix element value [0,255], the size of the map matrix is 256ⅹ3, denoted by Map=[rgb]. The three elements of each row in the map specify the red, green, and blue monochrome values for each row of the line, and each row in the map corresponds to a grayscale value for the image matrix pixel, such as a pixel with a grayscale value of 64, then the pixel is mapped to the 64th row in the map, and the actual color on the screen is determined by the [ RGB] combination decision. That is, when the image is displayed on the screen, the color of each pixel is indexed by the grayscale value of the pixel stored in the matrix, which is obtained by retrieving the color index matrix map. The index image data type is generally 8-bit unsigned (int8), the corresponding index matrix map size is 256ⅹ3, so the general index image can only display 256 colors at the same time, but by changing the index matrix, the type of color can be adjusted. The data type of an indexed image can also be a double-precision floating-point type (double). Indexed images are generally used to store color requirements of relatively simple images, such as windows in the color composition of the more simple wallpaper is indexed image storage, if the color of the image is more complex, it is necessary to use RGB true color image.

4. True Color RGB image

RGB images can be used to represent color images as well as indexed images. As with indexed images, it uses a combination of red (R), Green (G), and Blue (B) primaries to represent the color of each pixel. However, unlike indexed images, the color value of each pixel of the RGB image (represented by RGB primary colors) is stored directly in the image matrix, because each pixel color needs to be represented by R, G, b three components, M, n respectively represents the number of rows of the image, and three m x n two-dimensional matrices represent each pixel's R, G, b Three color components. The data type of an RGB image is typically 8-bit unsigned, usually used to represent and store true color images, and of course, to store grayscale images.

grayscale images are stored in rows and columns, with only one channel per column


RGB images are stored as follows, each column contains three channels (note: The order of the channels is BGR instead of RGB)

In general, if the memory is large enough, each row of the image is stored continuously, that is, all the data in memory is stored in a row, which can provide great convenience when accessed.

can be used iscontinuous () function to determine whether an array of images is contiguous.










Four types of images

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.