Subsections


User Interface

Scripts and Functions

As described in section 1.1, InfoPACK routines can be accessed as Python functions, Python scripts or via the GUI. The latter is simply a front end for the Python scripts. The distinction between the two fundamental ways of calling the routines is as follows:

Python Functions:
the routine is called as a Python function. The functions are contained in the Python module infopack and have a user interface designed to be as convenient as possible to use from within the InfoPACK or Python console. Operations on images are, in general, carried out in memory and so do not provide a suitable environment for handling arbitrarily large images.
Python Scripts
(.py files). These are designed for users who prefer to use a command line interface with or without Unix shell scripts/Windows batch files. Python scripts work file to file and are memory optimised in order to handle arbitrarily large images efficiently.

The scripts have a very similar syntax to the function form, so that switching between them (should you need to do this) is straightforward. Here is an example:

Command line call:
segment.py image_file output_file quality=sensitive
InfoPACK Python function:
array_out = segment(array_in, quality=sensitive)
In the latter call, array_in is the previously loaded image array; the result will be stored in the Numeric array array_out. Section A.1.3 discusses file I/O for InfoPACK functions in greater detail.

GIS Information

InfoPACK import facilities preserve any GIS information in the original file, and the imported NetCDF files can be loaded, processed and saved while continuing to preserve the information. Alternatively, you can ignore it totally if it is not relevant to your application. The way in which this is done is outlined in the next section (Section A.1.3).


File I/O

File I/O is handled behind the scenes when using the Python Script versions of the routines. Python Function calls, however, work via calls to and from the Python Numeric arrays associated with each image file.

Loading and saving of NetCDF files is done by calling the utilities load, save. The load function returns a list with two elements in it; the first is an array containing the image (in Numeric Python format) and the second is a GIS object. For example: from the console

        a, gis = load(``file.img'')
returns a list containing a Numeric array (the actual image data) and a class with the GIS information. Any format recognised by the GDAL library is valid.

The following code segments the Numeric array ``a'', normalise the original image by the intensity value in each segment and saves the resulting file while preserving the GIS information:

        from infopack import *
        a, gis = load("file.img")
        b = segment(a)
        c = a / b
        save(c, "result.nc", gis=gis)
Here, a,gis is a list with a containing the image and gis containing the GIS information. All the InfoPACK .py scripts, and the GUI buttons, preserve GIS information in this way.

However if you do not care about keeping (or using) the GIS information then you can throw it away:

        from infopack import *
        a, dummy = load("file.img")
        b = segment(a)
        c = a / b
        save(c, "result.nc")
If you miss out the ", dummy" then "a" will be a list and you will get all sorts of interesting bugs when you try to use a as an image (unless you access the numeric array and gis information via list elements ``a[0]'' and ``a[1]'' respectively).

For convenience, the routine numload only returns the numeric array and gisload only loads the GIS data.

Online Help

When typing function names in a Python or InfoPACK shell, the Python interpreter will display the function syntax along with a full list of possible parameters. When working with Python Scripts, help concerning a particular routine can be quickly found by entering
pydoc infopack.routine_name on the command line.
InfoSAR Ltd