Analysis of common image formats

1. The basic structure of the image:

1. In the computer, the image is composed of pixels, the pixels are the color points, and the easiest way to express the color is to use RGB or RGBA;


2.     If there is an A channel, it means that the image can have a transparent effect ; each component of R, G, and B is generally represented by one byte (8 bits) ;

3.     The image is two-dimensional data, and the data can only be stored one-dimensionally in the memory. There are different corresponding ways to convert two-dimensional to one-dimensional; there are only two common ways: according to the pixel " row arrangement" from top to bottom or from bottom up ;


(1) The image as shown in the figure has 9 pixels. If the one-dimensional data is arranged from top to bottom, it is (123456789), and if it is arranged from bottom to top, it is (789456123);

(2) The only reason for this difference is that the former is based on the screen coordinate system of computer graphics (the upper left is the origin, and the y-axis is down) , while the latter is based on the standard mathematical coordinate system. Reference ( the bottom left is the origin, the y axis is up) ; these two coordinate systems are only different in the y value;

(3) But it seems that there are only bmp image formats and GDI under windows, GDI+ is arranged from bottom to top ; others such as DirectX, OpenGL, Cocoa (NSImage, UIImage), OpenCV , etc. are arranged from top to bottom ;

4. RGB arrangement order:

(1)   The sorting order of RGBA in each pixel in different graphics libraries may be different ;

(2) The sorting order includes: RGBA; RBGA; GRAB; AGBR; BAGR and other 24 cases;

(3) However, there are generally only RGB , BGR , RGBA , BGRA arrangements; most graphics libraries or environments are BGR/BGRA arrangements ;

5. The necessity of image format:

(1) If the original format of the image is directly stored into the file, it will be very large, such as a 5000*500024 bitmap, the size of the file is 5000*5000*3 bytes = 71.5MB, and its size is very considerable;

(2)   If a general algorithm such as zip or rar is used to compress pixel data, the resulting compression ratio is usually not too high, because these compression algorithms do not carry out special processing for the image data structure ; so there are formats such as jpeg, png, etc. ;

(3)   jpeg and png files are equivalent to images in zip and rar formats ; jpeg is more suitable for storing pictures with "cluttered" colors , while png is more suitable for storing graphic pictures with strong geometric features;


https://blog.csdn.net/fanhenghui/article/details/54692904












Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326292163&siteId=291194637