2 followers Follow

Access Image Statistics in Python

Is there a way to get image statistics for different channels in Geomatica through Python (i.e. mean, median, mode, standard deviation, etc)? Sorry if this is a newb question, Im still new to Geomatica.

Christiaan Lott Answered

Please sign in to leave a comment.



Hi Christiaan,

You can use the HIS algorithm to get the channel statistics. The example below shows how to run HIS on one image channel. If you wish to output the results to a report file you can implement the Report class. The answer to a previous question outlines how to create a report:

from pci.his import his

image = r"C:\PCI Geomatics\Geomatica 2015\demo\irvine.pix"

imstat = []

You will notice above that an empty list "imstat" is created before HIS is run. This empty list will be populated with the channel statistics from the "imstat" output parameter. If multiple channels are listed, the channel information from the last channel will be written out to the imstat parameter. In the example above the statistics from channel 1 will be written to the stats variable There are 13 values added to this list after HIS is run. A list of the 13 values is available from the Geomatica help:

You can create other variables for each statistic from imstat. Keep in mind that the first imstat value (channel number) would be imstat[0] as per python’s numbering scheme.

channel = imstat[0]
mean = imstat[1]
median = imstat[2]

print channel, mean, median

Hope this helps,

PCI Geomatics 1 vote
Comment actions Permalink