2021-01-12 Image size calculation bit depth and color depth

Image size calculation

1. Bit depth and color depth

Bit depth: In a certain resolution, how many colors can be described by each pixel, the unit is "bit" (bit). Typical color depths are 8-bit, 16-bit, 24-bit and 32-bit. The higher the depth value, the more colors you can get.

Image depth refers to the number of bits used to store each pixel, and is also used to measure the color resolution of an image. Image depth determines the number of colors that each pixel of a color image may have, or determines the number of gray levels that each pixel of a grayscale image may have. It determines the maximum number of colors that can appear in a color image, or in a grayscale image The maximum gray level . For example, for a monochrome image, if each pixel has 8 bits, the maximum number of gray scales is 2 to the 8th power, or 256. The pixel bits of the RGB3 components of a color image are 4, 4, 2, respectively, and the maximum number of colors is 2 to the power of 4+4+2, which is 1024, which means that the depth of the pixel is 10 bits, and each pixel can It is one of 1024 colors.

For example: if the size of a picture is 1024*768 and the depth is 16, its data volume is 1.5M.

The calculation is as follows: 1024*768*16bit(bit)=(1024*768*16)/8Byte(byte)=[(1024*768*16)/8]/1024KB=1536KB={[(1024*768*16 )/8]/1024}/1024MB=1.5MB

 

Color depth, also called color depth. Each of the three color channels of red, green, and blue in the video screen has N bits, and the total number of color bits is 3N. The color depth is the range of colors that the video equipment can distinguish.

Currently there are 18bit, 24bit, 30bit, 36bit, 42bit and 48bit.

24-bit color is called true color, R, G, B are each 8bit, often said 8bit, the total number of colors is 16.7 million

16-bit color value: X1 bit, R5 bit, G5 bit, B5 bit; or X, R, G, B are all 4 bits, etc.;

24-bit color value is called "true color", it has a uniform color distribution: R8 bit, G8 bit, B8 bit;

32-bit color values ​​are generally allocated as follows: X8 bits, R8 bits, G8 bits, B8 bits

Or A8 bit, R8 bit, G8 bit, B8 bit.

The RGB value of pure white is 255,255,255. The RGB value of black on the screen is 0,0,0.

 

2. The size of the space occupied by the image

Size = resolution * bit depth / 8
resolution = width * height (such as: 1024 * 768, 640 * 480)
bit depth: such as 24 bits, 16 bits, 8 bits
/ 8 to calculate the number of bytes.

For example, a 32-bit 1024*768 pixel picture, its size is: 1024*768*32/8=3145728 bytes (byte).

3. Unit conversion

    One byte Byte=8bit
    so 1Bps=8bps
    1MBps=8Mbps

1M bandwidth means 1Mbps, which is bps instead of Bps!  
    Conversion, 1Bps=8bps; So 1Mbps=128KBps; So the maximum download speed is 128KBps 1Mbps=1024KBps/8=128KBps
    1Byte=8bit  
    1Kb=1024byte(byte)=8*1024bit 1Mb=1024kb 1Gb=1024Mb 1Tb=1024Gb
 

4. Centimeters and pixels

Centimeters have nothing to do with pixels. Centimeters are a unit of length. What is a pixel? Pixels are the most basic unit of an image. It is a small square color block.

An image usually consists of many pixels, these pixels are arranged in horizontal rows or columns, each pixel is square. When you use the zoom tool to enlarge the image large enough, you can see a mosaic-like effect, and each small square is a pixel.

Each pixel has a different color value. The more pixels per unit area and the higher the resolution (dpi), the better the image effect.

When the image normally displayed on the monitor is enlarged to a certain ratio, you will see a mosaic-like effect. Each small square is a pixel, which can also be called a grid. The quality of the pixel map is determined by the resolution. The more pixels per unit area, the higher the resolution, and the better the image.

5. DPI calculation

This image has a resolution of 200*200dpi and a size of 450*450 pixels, then you can get:
image size = image size / resolution = 450/200 = 2.25
so, the size of this image is 2.25*2.25 inches
if the image size is required It becomes 1.5*1.5 inches, but the number of pixels is still 450*450. According to the formula:
image size = number of image pixels / image resolution, the resolution of the image should be: 450 / 1.5 = 300dpi.
Therefore, you should use the command imwrite(f,'sf.tif','compression','none','resolution', [300 300])

Guess you like

Origin blog.csdn.net/qingfengxd1/article/details/112541612