MATLAB Function Reference |
Syntax
multibandwrite(data,filename,interleave) multibandwrite(data,filename,interleave,start,totalsize) multibandwrite(...,param,value,...)
Description
multibandwrite(data,filename,interleave)
writes data
, a two- or three-dimensional numeric or logical array, to the binary file specified by filename
. The length of the third dimension of data
determines the number of bands written to the file. The bands are written to the file in the form specified by interleave
. See Interleave Methods for more information about this argument.
If filename already exists, multibandwrite
overwrites it unless you specify the optional offset
parameter. See the last alternate syntax for multibandwrite
for information about other optional parameters.
multibandwrite(data,filename,interleave,start,totalsize)
writes data
to the binary file filename
in chunks. In this syntax, data
is a subset of the complete data set.
start
is a 1-by-3 array [firstrow firstcolumn firstband]
that specifies the location to start writing data. firstrow
and firstcolumn
specify the location of the upper left image pixel. firstband
gives the index of the first band to write. For example, data(I,J,K)
contains the data for the pixel at [firstrow+I-1, firstcolumn+J-1]
in the (firstband+K-1)
-th band.
totalsize
is a 1-by-3 array, [totalrows,totalcolumns,totalbands]
, which specifies the full, three-dimensional size of the data to be written to the file.
multibandwrite(...,param,value...)
writes the multiband data to a file, specifying any of these optional parameter/value pairs.
Parameter |
Description |
'precision' |
String specifying the form and size of each element written to the file. See the help for fwrite for a list of valid values. The default precision is the class of the data. |
'offset' |
The number of bytes to skip before the first data element. If the file does not already exist, fopen using 'r+' permission. |
machfmt |
String to control the format in which the data is written to the file. Typical values are 'ieee-le' for little endian and 'ieee-be' for big endian. See the help for fopen for a complete list of available formats. The default machine format is the local machine format. |
fillvalue |
A number specifying the value to use in place of missing data. 'fillvalue' can be a single number, specifying the fill value for all missing data, or a 1-by-Number-of-bands vector of numbers specifying the fill value for each band. This value is used to fill space when data is written in chunks. |
Interleave Methods
interleave is a string that specifies how multibandwrite
interleaves the bands as it writes data to the file. If data
is two-dimensional, multibandwrite ignores the interleave
argument. The following table lists the supported methods and uses this example multiband file to illustrate each method.
Supported methods of interleaving bands include those listed below.
Examples
In this example, all the data is written to the file with one function call. The bands are interleaved by line.
This example uses multibandwrite
in a loop to write each band to a file separately.
for i=1:totalBands multibandwrite(bandData,'data.img','bip',[1 1 i],... [totalColumns, totalRows, totalBands]); end
In this example, only a subset of each band is available for each call to multibandwrite
. For example, an entire data set can have three bands with 1024-by-1024 pixels each (a 1024-by-1024-by-3 matrix). Only 128-by-128 chunks are available to be written to the file with each call to multibandwrite
.
numBands = 3; totalDataSize = [1024 1024 numBands]; for i=1:numBands for k=1:8 for j=1:8 upperLeft = [(k-1)*128 (j-1)*128 i]; multibandwrite(data,'banddata.img','bsq',... upperLeft,totalDataSize); end end end
See Also
multibandread | munlock |
© 1994-2005 The MathWorks, Inc.