Steve on Image Processing with MATLAB

Image processing concepts, algorithms, and MATLAB

Note

Steve on Image Processing with MATLAB has been archived and will not be updated.

Consider multibandread for reading your data

I've seen several situations recently in which a user couldn't figure out how to get their data into MATLAB, and it turned out that the data was in a form that could be handled by the MATLAB function multibandread. So I have a feeling that not enough people know about this useful function.

There are a lot of relatively simple gridded data file formats in use that follow a common pattern: the format has a fixed-length header, followed immediately by all the data values, in some defined order. Sometimes the data has multiple bands, in which case there is some variation from format to format in the ordering of band values in the file. This is the perfect scenario for using multibandread.

You can tell multibandread the header size, the data-value precision, the byte order, and how the bands are arranged, and then multibandread can read any band, or all of them, or even a subset of a band.

Here's an example. The Image Processing Toolbox ships with a few sample .lan files, which are Landsat Thematic Mapper images in Erdas LAN format. The file paris.lan contains a 7-band 512-by-512 Landsat image. A 128-byte header is followed by the pixel values, which are band interleaved by line (BIL) in order of increasing band number. They are stored as unsigned 8-bit integers. The following command reads in bands 4, 3, and 2 from the file.

CIR = multibandread('paris.lan', [512, 512, 7], 'uint8=>uint8',...
                    128, 'bil', 'ieee-le', {'Band','Direct',[4 3 2]});
imshow(CIR)
xlabel('Image courtesy of Space Imaging, LLC')

And for no extra charge, I'll toss in a quick demo of decorrstretch (decorrelation stretch) from the Image Processing Toolbox.

decorrCIR = decorrstretch(CIR, 'Tol', 0.01);
imshow(decorrCIR)

The examples above are from the "Finding Vegetation in a Multispectral Image" example in the Image Processing Toolbox.

Give multibandread a try. You might find it to be just what you need.




Published with MATLAB® 7.7

|
  • print

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.