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 CenterFile Exchange에서 Display Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by