Как рассчитать потребность в байтах для изображения с 256-уровневой серой шкалой

14630
f855a864

Когда размер неподвижного изображения составляет 1600 x 1200 пикселей, и каждый пиксель имеет 256-уровневую серую шкалу в диапазоне от 0 до 255, приблизительно, сколько мегабайт требуется по меньшей мере для хранения пяти таких неподвижных изображений?

Если в вопросе сказано: 1600x1200 пикселей, каждый пиксель имеет 24-битный цвет, результат будет: 1600 * 1200 * 24

но я не знаю, что это значит 256-level gray scale ranging from 0 to 255

1
256 уровень == 8 бит; 1 байт = 8 бит Rowland Shaw 9 лет назад 2

1 ответ на вопрос

1
Damon

8 bits of data gives you 256 different storage combinations because 256 is 2^8 which means 8 bits of data, with each bit having 2 possible values, will give you 256 possible combinations that the 8 bits as whole can be in. This means you can distinguish between 256 different levels of grey in each pixel if you use 8 bits of data per pixel. 24 bits of data per pixel means you can give 2^24 different values of color or 16.7 million colors. This usually equates to 8 bits of value per Red, Green, and Blue colors giving you 16.7 million possible color combinations.

In retrospect you could also have 256 values of color (instead of grey) as well; For this they had 3 bits (8 color levels) for red, 3 bits for green, and 2 bits (4 color levels) for blue for a total of 8 bits as well but in color instead of grey.

To calculate the size you would multiply the the number of total pixels to get the total number of bits needed to store the images. This is (5*1,600*1,200*24)=230,400,000 bits. Divide by 8 to get bytes; 230,400,000/8 = 28,800,000. Divide by 1,024,000 to get megabyte; 28,800,000/1,024,000 = 28.13 MB. This is the total number of MB your would need to store the raw data for the images you decribe.

If you add in file headers and exif data, you usually will see a larger file than just the image alone and of course, compression would alter the value as well.

Maybe this was a bit overkill.

Похожие вопросы