Load only part(block) of a large bmp-image in order to reduce memory requirements

1 回表示 (過去 30 日間)
Hello, I want to process bmp-images without a lot of "memory requirement". The file size is about 300 MB and matlab seems to acquire 1.5 GB whereas the peak memory seems to be about 350 MB (using matlab profiler with the memory options)
As I only use/need a small part of the image (only about 3000 columns instead of 8000), I wonder if it's somehow possible to load only this part of the image.
One goal is to reduce the processing speed and the amount of acquired memory when I compile the matlab code into an exe or jar-file.
I'm very happy about every code fragment or ideas.
Thank you
Andreas

採用された回答

Walter Roberson
Walter Roberson 2016 年 12 月 20 日
You might want to adapt the C code shown in http://stackoverflow.com/questions/14279242/read-bitmap-file-into-structure to not read the full image, either by using fseek() to re-position the input stream or by reading more than you need and throwing away the extra.

その他の回答 (1 件)

Kushagr Gupta
Kushagr Gupta 2016 年 12 月 20 日
The 'imread' function in MATLAB lets one read subimages for TIFF and JPEG2000 formats. So one way to go about this issue would be to covert the BMP images into TIFF and reading the small part of the image thereafter in MATLAB using the 'imread' function with 'PixelRegion' argument.
Go through the 'PixelRegion' section of the 'imread' documentation available at:
Can you tell us more about the source of such large BMP images, as usually only JPEG2000 and TIFF images come in such sizes and it would be interesting to know the use case.
  1 件のコメント
Andreas
Andreas 2017 年 1 月 5 日
The origin of the bmp images was a video camera system.

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

Community Treasure Hunt

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

Start Hunting!

Translated by