Time for action – visible spectrum from a multiband image of Rio

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:

  1. First, we load the multiband image using 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]});
  2. The previous step saves the red, green, and blue bands of the image in a matrix with 8-bit integer values, which can be now displayed as a RGB image, in the usual way:
    >> figure,imshow(image),title('Original RGB image')
    Time for action – visible spectrum from a multiband image of Rio
  3. However, the image derived from step 2 has very little contrast and its color bands are highly correlated with each other. This is why, the resulting image seems like it is monochromatic, that is, includes only the shades of one color. To enhance the image and acquire a more decent and life-like result, we can adjust the contrast of all the three channels. A way to accomplish this is:
    >> 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')
    Time for action – visible spectrum from a multiband image of Rio
  4. Sometimes we will need to have a result that is even more pronounced, for example, have the vegetation of a landsat image denoted with a very bright color. This can be achieved using a so called decorrelation stretch, that produces an image with high correlation among its bands.
  5. Contrast stretches can easily be achieved using MATLAB's 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);
  6. Now, we can display our resulting image next to the original:
    >> subplot(1,2,1),imshow(adjusted),title('Adjusted RGB image')
    >> subplot(1,2,2),imshow(stretched),title('Stretched RGB image') 
    Time for action – visible spectrum from a multiband image of Rio

What just happened?

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:

  • the name of the binary file ('rio.lan')
  • the number of rows, columns, and bands of the image ([512 512 7])
  • the format used for reading the data from the binary file (integer, that is, 'uint8=>uint8')
  • the offset, that is, the number of bytes after the beginning of the file, where the data begins (128)
  • the format in which the data is stored ('bil')
  • the byte ordering in which the data is stored ('ieee-le' for little endian)
  • the subset, which is a cell that describes the way the data will be imported from the binary file (in our example, {'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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset