Reputation: 831
I have a sequence of large images I would like to load into matlab and then apply some processing too. Due to the images size, reading them in takes a long time, and fills the computer memory very fast.
However, I am only interested in the middle section of the images, a region of about 100 by 100 pixels or so.
Is there a way to only read in that section of the image, therefore saving time, and memory?
Currently I am using:
ROIx = 450:550;
ROIy = 650:750;
image = double( imread( filename ) );
image = image(ROIx, ROIy);
However, imread() loads the whole image, and this takes a long time. Is there a way only to read the part I am interested in?
(One procedure would be to go through and crop each image into a smaller one and resave it. But I would prefer not to crop the images).
Thanks, labjunky
Upvotes: 1
Views: 2677
Reputation:
You will need to use something like fopen to open the file and read the contents in parts manually. You will need to take care of lot of encoding/decoding of course. Or the other way round a little more would be to increase your system's swap space. If you are getting out of memory errors.
Upvotes: 0
Reputation: 78306
Matlab 2012a indicates that you can read parts of images from JPEG2000 and TIFF images. Look at the documentation for imread, inspect the option 'PixelRegion' for reading TIFFs.
Upvotes: 2