We will use the file rio.lan
for this example and try to manipulate its visible spectrum bands. The file contains seven bands, from which the third contains red color, the second green one, and the first blue one. Let's use the following steps to import and process just these three bands in MATLAB:
multibandread
(imread
could still be used, in the possible case, where the multiband image is of type .tif
):>> image = multibandread('rio.lan', [512, 512, 7],...
'uint8=>uint8',128, 'bil', 'ieee-le', {'Band','Direct',[3 21]});
>> figure,imshow(image),title('Original RGB image')
>> for i=1:size(image,3) adjusted(:,:,i) = imadjust(image(:,:,i)); end >> subplot(1,2,1),imshow(image),title('Original RGB image') >> subplot(1,2,2),imshow(adjusted),title('Adjusted RGB image')
decorrstretch
function, followed by a linear contrast stretch performed by defining the fraction of the image 'Tol'
to be saturated at low and high intensities:>> stretched = decorrstretch(image,'Tol',0.01);
>> subplot(1,2,1),imshow(adjusted),title('Adjusted RGB image') >> subplot(1,2,2),imshow(stretched),title('Stretched RGB image')
You just got acquainted with multiband images. The first step was to import a binary file, rio.lan
, which is a multiband BIL (Band Interleaved by Line) satellite image of Rio, into MATLAB. The function used to accomplish this was multibandread
, which used the following as inputs:
'rio.lan'
)[512 512 7]
)'uint8=>uint8'
)128
)'bil'
)'ieee-le'
for little endian){'Band','Direct',[3 2 1]}
denotes reading the visible bands of the spectrum, which are the third (red), second (green), and first (blue))Then, we displayed the imported image and saw that it seems monochromatic, and so fixed this defect by adjusting the contrast of each color channel separately. To offer an alternative solution that can further enhance differences in the land surface, we performed decorrelation stretching, followed by linear stretch of the contrast of the resulting image. Such techniques might be used as the foundations for geospatial analysis systems that either automatically or semi-automatically, classify the areas depicted in satellite imagery into various terrain classes. In the next example, we will see how we can use more bands of the same multispectral image.