Pages

Friday 15 August 2014

eCognition tutorial: Exporting eCognition classification file to ENVI

The problem:

I was wondering if anyone could help me export a usable file from eCognition Developer for use in ENVI 5.0? I've classified an image using Multiresolution Segmentation followed by the Classification algorithm using selected samples from the Standard Nearest Neighbour and everything worked so far. I try and export it as an ENVI-supported file type (e.g. *.tif) the raster seems to have "lost" all the classification- leaving a grayscale image- useless! I have been able to open a *.jpg file, but as it is an image it has lost any previous classfication from Ecognition.

Solution:

This is not even a problem but for people who are just starting with ENVI is a big HEADACHE. It’s just a matter of a symbology. If you have been using the ENVI for a while you should know that ENVI uses two files for any image. One binary file and another hdr file where different information about the binary image are stored. One can simply open hdr files with a notepad. Normal raster images have “file type = ENVI Standard” whereas classification images have “file type = ENVI Classification” and some other information such number of classes, class names and class colours. So the classified tiff file that one exports from eCognition does not have those information, hence ENVI opens the classified tiff file as a normal file. There are values differentiating classes but colour information are lost. This is a problem if you want to do some other operation in ENVI that required a classification image as input.

So we need to convert it ENVI Classification type, somehow. So here is a way to do it.

  1. Do your classification in eCognition.
  2. Export it using “export thematic raster files” algorithm in eCognition with Export Type Don’t forget to select your classes in Class Filter parameters
  3. Once you export it, you will have two files. One *.tiff file and other *.csv fil. Open *.csv file, there you will find class names and RGB colour for each class.
  4. Open *.tif file in ENVI.
  5. Then File> File Save as > ENVI Standard>Import file > Pick recently open tif file. Give a name and save it. Now you changed tiff file to ENVI file but remember, its still a normal ENVI standard file.
  6. Open the file created in step 5. Then File> Edit Header Info > Select File type as ENVI classification. It will prompt you for number of classes, class names, colour information. Provide those information by using *.CSV file that you opened in step 3.
  7.   Now you have a ENVI classification image with same class names and colour as in eCognition. Now smile and go for a coffee.

Example of a CSV file
Converting tiff file to ENVI file
Modifying header files
Editing class names and color information

Initial and Final image

10 comments:

  1. Replies
    1. Got it, but can I now calculate the confusion matrix or result statistics of the eCognition classified image which is now opened in Evni?

      Delete
    2. Not yet, you have to import samples into ENVI format. Export your sample as TTA mask and import it to ENVI with above procedure. And then you can perform calculation of confusion matrix in ENVI. BTW in eCogntion also you can calculate confusion matrix.

      Delete
    3. How to export sample as TTA mask? Is it correct--> 1)create TTA mask from sample 2)save TTA mask as tif

      Delete
  2. I have done threshold classification using rule sets in eCognition and got the classified image, but i am worried about the result statistics i.e, confusion matrix, user and producer accuracy of the rule sets based classification which i have done in ecognition. Please help me , I have to compare the results of object based classification in ecognition with those obtained by pixel based approach in ENVI. ?

    ReplyDelete
  3. Thanks for the explanation, what should be the procedure for opening a classification image from Arcgis in ENVI? I have tried to convert it into .dat it is not working when opening in ENVI. Thanks

    ReplyDelete
  4. How to export a object based classified image from eCognition to ArcGIS? I want to analyse the landscape parameters in "patch analyst" addin in ArcGIS. Help me please.

    ReplyDelete