MATLAB: How to write an image adapter class for a .bmp image

blockprocclassimage processingImage Processing Toolboximage types

I'm trying to develop an image adapter class to accommodate some very large images with blockproc. I've tested the rest of my algorithms with a .tiff image and everything worked as expected but when trying to work with a .bmp file (what will be required for my project) I was unable to successfully write an image adapter class.
Here is the image adapter class that I've written and attempted to use.
classdef bmpAdapter < ImageAdapter
properties
Filename
Info
end
methods
function obj = bmpAdapter(filename)
obj.Filename = filename;
obj.Info = imfinfo(filename);
obj.ImageSize = [obj.Info.Height obj.Info.Width];
end
function result = readRegion(obj, start, count)
result = imread(obj.Filename,'Index', [1 2 3], ...
'Info',obj.Info,'PixelRegion', ...
{[start(1), start(1) + count(1) - 1], ...
[start(2), start(2) + count(2) - 1]});
end
function result = close(obj) %#ok
end
end
end
While using this adapter class with blockproc I'm receiving the following error messages:
Error encountered while executing the readRegion method of the bmpAdapter
class. The input arguments were:
region_start: [1 1]
region_size : [316 348]
The cause of the error was:
Error using imagesci\private\readbmp
Too many input arguments.
Error in imread (line 434)
[X, map] = feval(fmt_s.read, filename, extraArgs{:});
Error in bmpAdapter/readRegion (line 13)
result = imread(obj.Filename,'Index', [1 2 3], ...
Error in internal.images.AdapterDispatcher/readRegion (line 81)
data = obj.Adapter.readRegion(region_start, region_size);
Error in blockproc>getBlock (line 788)
source_data = source.readRegion(...
Error in blockproc (line 282)
block_struct = getBlock(source_dispatcher,block_struct,1,1,options);
I've gone through the following tutorial but haven't had much luck. http://blogs.mathworks.com/steve/2011/09/23/dealing-with-really-big-images-image-adapters/
Based on the error messages that I'm receiving my method is properly determining the starting positions to read the image data. Any help would be greatly appreciated.
Thanks,
Chris

Best Answer

Those Name/Value pairs are defined for TIFF only. BMP is not defined with any Name/Value pairs, so you will need to strip them out before calling imread()