Load only part(block) of a large bmp-image in order to reduce memory requirements
2 views (last 30 days)
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.
Walter Roberson on 20 Dec 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.
More Answers (1)
Kushagr Gupta on 20 Dec 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.