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

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 20 Dez. 2016
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.

Weitere Antworten (1)

Kushagr Gupta
Kushagr Gupta am 20 Dez. 2016
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.

Community Treasure Hunt

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

Start Hunting!

Translated by