Pages

Monday 10 June 2013

Maximum reflectance in a spectra of Multispectral or Hyperspectral image in MATLAB

This is a very short post, something related to processing of remote sensing images. The image can be either multi-spectral or hyper-spectral images. One of my colleagues asked me this simple help in MATLAB  He was trying that in ENVI with band-math and IDL, with no avail.

I wanted to produce 2 images from my hyper-spectral image: 1) showing the maximum reflectance value across the bands and 2) the band number where the maximum came from.

First step is to read the image in MATLAB, of course :). That's no-brainer. For that you have to use multibandread function. I have a written post about it earlier. Search in the site. Now you have your image read in the MATLAB.

Here is the code, that i have written to perform what my friend asked.Hope this is useful for someone else.

%find the number of rows and columns
[rows,cols,bands]= size(imt1);
%reshape it 
imt1= reshape(imt1,[],4)';
%find max_value and band which has maximum value
[max_value,idx]= max(imt1,[],1);
%reconstruct the image
band_image= reshape(idx,rows,cols);
max_image= reshape(max_value,rows,cols);

No comments:

Post a Comment