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);

Friday, 7 June 2013

eConition Tutorial: Customized algorithm for performing majority vote in eCognition

Today, I present you a customized rule set which lets you to assign super-object by evaluating all of its sub-objects based on which classification makes up the largest proportion of the area. This is one of the wishlist in eCognition Ideas and was also frequently asked in the ecognition community.

A majority statistic customized algorithm lets you assign  super- object to the class with the majority value of the pixels within each object. This would be useful for converting existing pixel-based classifications into an object-based format where additional object-based edits can be made.

The only parameter in this customized algorithm is a level variable. This is a level which consists of super-object. The customized algorithm will look one level below the level variable and perform all the necessary calculation.

Sub-objects level with classification


Super-objects level with no classification

Super-object level with classification from customized algorithm
The customized algorithm does assignment of super-object with following steps.

1) store all the classes in an array ( array_class)
3) loop through your objects in super objects
2) loop through your class arrays
4) store rel. area of (1) in an array for the class ( array_occur)
5) find maximum in the array_occur
6) assign super-object as maximum occurrence class in array  array_occur.

All of these steps are performed behind the scene in customized algorithm, so the user does not need to worry about how to perform these steps.

I have uploaded a zip file where you will find a project which shows the usage of the customized algorithm. There is a  customized rule-set as well. Load the customized rule set in your project and after that you will find a algorithm MajorityVote in the available algorithm list.

The algorithm was developed with eCogntion 8.8 and  will not work below that version.



eCognition tutorial: Customized algorithm for performing majority vote in eCognition

Today, I present you a customized rule set which lets you to assign super-object by evaluating all of its sub-objects based on which classification makes up the largest proportion of the area. This is one of the wishlist in eCognition Ideas and was also frequently asked in the ecognition community.

A majority statistic customized algorithm lets you assign  super- object to the class with the majority value of the pixels within each object. This would be useful for converting existing pixel-based classifications into an object-based format where additional object-based edits can be made.

The only parameter in this customized algorithm is a level variable. This is a level which consists of super-object. The customized algorithm will look one level below the level variable and perform all the necessary calculation.


Sub-objects level with classification

Super-objects level with no classification

Super-object level with classification from customized algorithm

The customized algorithm does assignment of super-object with following steps.

1) store all the classes in an array ( array_class)
3) loop through your objects in super objects
2) loop through your class arrays
4) store rel. area of (1) in an array for the class ( array_occur)
5) find maximum in the array_occur
6) assign super-object as maximum occurrence class in array  array_occur.

All of these steps are performed behind the scene in customized algorithm, so the user does not need to worry about how to perform this steps.

I have uploaded a zip file where you will find a project which shows the usage of the customized algorithm. There is a  customized rule-set as well. Load the customized rule set in your project and after that you will find a algorithm MajorityVote in the available algorithm list.

The algorithm was developed with eCogntion 8.8 and  will not work below that version.