aboutsummaryrefslogtreecommitdiff
path: root/sys/vops/abav.gx
blob: 0f519216e0be2dc3d26a6b87420d3a261bdc4982 (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
40
41
42
43
44
45
46
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

# ABAV -- Vector block average.  Each pixel in the output vector is the
# average of the input vector over a block of pixels.  The input vector must
# be at least (nblocks * npix_per_block) pixels in length.

procedure abav$t (a, b, nblocks, npix_per_block)

PIXEL	a[ARB]			# input vector
PIXEL	b[nblocks]		# output vector
int	nblocks			# number of blocks (pixels in output vector)
int	npix_per_block		# number of input pixels per block

$if (datatype == cs)
long	sum, width
$else $if (datatype == il)
real	sum, width
$else
PIXEL	sum, width
$endif $endif

int	i, j
int	block_offset, next_block, block_length

begin
	block_offset = 1
	block_length = npix_per_block
	$if (datatype != x)
	    width = block_length
	$else
	    width = complex (block_length, block_length)
	$endif

	if (block_length <= 1)
	    call amov$t (a[block_offset], b, nblocks)
	else {
	    do j = 1, nblocks {
		next_block = block_offset + block_length
		sum = 0
		do i = block_offset, next_block - 1
		    sum = sum + a[i]
		b[j] = sum / width
		block_offset = next_block
	    }
	}
end