aboutsummaryrefslogtreecommitdiff
path: root/sys/vops/ak/ahgmr.x
blob: a1f90d670a406bbc5cc0a2c0d47ff84b4e66b889 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<mach.h>

# AHGM -- Accumulate the histogram of the input vector.  The output vector
# HGM (the histogram) should be cleared prior to the first call.

procedure ahgmr (data, npix, hgm, nbins, z1, z2)

real 	data[ARB]		# data vector
int	npix			# number of pixels
int	hgm[ARB]		# output histogram
int	nbins			# number of bins in histogram
real	z1, z2			# greyscale values of first and last bins

real	z
real	dz
int	bin, i

begin
	dz = real (nbins - 1) / real (z2 - z1)
	if (abs (dz - 1.0) < (EPSILONR * 2.0)) {
	    do i = 1, npix {
		z = data[i]
		if (z >= z1 && z <= z2) {
		    bin = int (z - z1) + 1
		    hgm[bin] = hgm[bin] + 1
		}
	    }
	} else {
	    do i = 1, npix {
		z = data[i]
		if (z >= z1 && z <= z2) {
		    bin = int ((z - z1) * dz) + 1
		    hgm[bin] = hgm[bin] + 1
		}
	    }
	}
end