The following example illustrates how to compute a histogram of the image data in channel 1 of irvine.pix, sampling only the pixels under the mask in bitmap segment 9 (lake training area). The histogram has 256 entries from value 0 to 255. If values are outside the range, they will not be included in the histogram. After the histogram is computed, all bins in the histogram with a non-zero pixel count are reported along with the image value corresponding to that bin.
local int histogram[256], tfid, i, pixelcount
tfid = DBOpen( GetPCIHOME() + "/demo/irvine.pix", "r" )
pixelcount = DBImageHistogram( tfid, 1, 256, histogram, 0.0, 1.0, 0, 9 )
call DBClose( tfid )
for i = 1 to 256
if( histogram[i] <> 0 )then
printf "%3d - %d\n", i-1, histogram[i]
endif
endfor
48 - 1 51 - 1 52 - 5 53 - 22 54 - 53 55 - 86 56 - 132 57 - 79 58 - 56 59 - 16 60 - 7 61 - 3 62 - 6 65 - 1 69 - 1 80 - 1 Total pixels: 470
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.