monochromatic image with 256 gray levels

7 ビュー (過去 30 日間)
SAMET YILDIZ
SAMET YILDIZ 2014 年 9 月 21 日
コメント済み: Guillaume 2014 年 9 月 21 日
Hello everyone, Assuming a monochrome image with 1024 × 1024 pixels and 256 gray levels, I would like to calculate the total file size (in bytes), assuming a header (containing basic information, such as width and height of the image) of 32 bytes and w/o compression. Can you please help me on this? I have a doubt how to look at the header information on a gray scale image. Thanks
  2 件のコメント
Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014 年 9 月 21 日
Hello Samet,
Good question, although this is a MATLAB furom and I don't see a relation between your question and MATLAB at all!
Why don't you google your question?
Tnx
David Young
David Young 2014 年 9 月 21 日
Would it be possible to write the image to a file using imwrite and then look to see how big the file is?

サインインしてコメントする。

採用された回答

Jan
Jan 2014 年 9 月 21 日
The question seems to be trivial. The header has 32 bytes, 256 gray-scales can be store in a UINT8, which is a byte. So you get a file size of:
1024 * 1024 + 32 = 1'048'608 bytes
I do not see, where your doubts about looking at the header play a role for this question.
  1 件のコメント
Guillaume
Guillaume 2014 年 9 月 21 日
編集済み: Guillaume 2014 年 9 月 21 日
Well, actually some image formats (BMP for e.g.) ensure that each row is aligned on a 32-bit boundary, so depending on the image format there may be some padding (although not for a 1024 pixel wide image since it is a multiple of 4).
However, since the author never specified the image format, your answer is as good as any.

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2014 年 9 月 21 日
Just try it and see. Of course it depends on the image and how many neighboring pixels are alike:
grayImage = imread('cell.tif'); % Read in sample image.
grayImage = imresize(grayImage, [1024, 1024]); % Make it 1024*1024
imwrite(grayImage, 'tiff uncompressed.tif', 'Compression', 'none');
uncompressedFileInfo = dir('tiff uncompressed.tif')
imwrite(grayImage, 'tiff compressed.tif', 'Compression', 'lzw');
compressedFileInfo = dir('tiff compressed.tif')
In the command window:
uncompressedFileInfo =
name: 'tiff uncompressed.tif'
date: '21-Sep-2014 10:30:07'
bytes: 1049286
isdir: 0
datenum: 735863.437581019
compressedFileInfo =
name: 'tiff compressed.tif'
date: '21-Sep-2014 10:30:07'
bytes: 361118
isdir: 0
datenum: 735863.437581019
Note that the header for the built-in imwrite seems to have a different header size than 32 bytes like you said.
  1 件のコメント
Guillaume
Guillaume 2014 年 9 月 21 日
I'm not aware of any file format that has a header as short as 32 bytes. Even, BMP which has one of the simplest header is at least 40 bytes.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDisplay Image についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by