aboutsummaryrefslogtreecommitdiff
path: root/noao/imred/quadred/src/quad/qsplitr.x
blob: adba483d9d6c6613c34932f85a9da84c5d886fbf (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
include <imhdr.h>
include "quadgeom.h"

# QSPLITx -- Split multi-readout image into separate images one for each 
# readout.

procedure qsplitr (in, out, qg)

pointer	in			#I Image pointer for input image
pointer	out[ARB]		#I Image pointer for output images
pointer	qg			#I pointer to quadgeom structure

long	ivec[IM_MAXDIM], ovec[IM_MAXDIM, QG_MAXAMPS]
int	amp, amp2, x, y, line, junk
pointer	ibuf, obuf, ptr
bool	all_phantom

int	imgnlr(), impnlr()

begin
	# Setup start vectors for sequential reads ...
	call amovkl (long(1), ivec, IM_MAXDIM)
	# ... and writes
	do amp = 1, QG_NAMPS (qg)
	    call amovkl (long(1), ovec[1, amp], IM_MAXDIM)

	do y = 1, QG_NAMPSY(qg) {
	    amp2 = QG_AMP(qg, 1, y)

	    # Check to see if there are any non phantom regions in this tier
	    all_phantom = true
	    do x = 1, QG_NAMPSX(qg) {
		amp = QG_AMP(qg, x, y)
		if (QG_PHANTOM (qg, amp) == NO) {
		    all_phantom = false 
		    break
		}
	    }

	    if (all_phantom) {

		# Reset start vector for reads to skip phantom data
		ivec[2] = ivec[2] + long (QG_NY (qg, amp2))

	    } else {

		do line = 1, QG_NY(qg, amp2) {
		    junk = imgnlr (in, ibuf, ivec)
		    ptr = ibuf
		    do x = 1, QG_NAMPSX(qg) {
			amp = QG_AMP(qg, x, y)
			if (QG_PHANTOM (qg, amp) == NO) {
			    junk = impnlr (out[amp], obuf, ovec[1, amp])
			    call amovr (Memr[ptr], Memr[obuf], QG_NX(qg, amp))
			}
			ptr  = ptr + QG_NX(qg, amp)
		    }
		}
	    }
	}
end

# QJOINx -- Join multi-readout sub-images into a single image.

procedure qjoinr (in, out, qg)

pointer	in[ARB]			#I Image pointer for input images.
pointer	out			#I Image pointer for output image.
pointer	qg			#I pointer to quadgeom structure.

long	ivec[IM_MAXDIM, QG_MAXAMPS], ovec[IM_MAXDIM]
int	amp, amp2, x, y, line, junk
pointer	ibuf, obuf, ptr

int	imgnlr(), impnlr()

begin
	# Setup start vectors for sequential reads ...
	do amp = 1, QG_NAMPS (qg)
	    call amovkl (long(1), ivec[1, amp], IM_MAXDIM)
	# ... and writes
	call amovkl (long(1), ovec, IM_MAXDIM)

	do y = 1, QG_NAMPSY(qg) {
	    amp2 = QG_AMP(qg, 1, y)
	    do line = 1, QG_NY(qg, amp2) {
		junk = impnlr (out, obuf, ovec)
		ptr = obuf
		do x = 1, QG_NAMPSX(qg) {
		    amp = QG_AMP(qg, x, y)
		    junk = imgnlr (in[amp], ibuf, ivec[1, amp])
		    call amovr (Memr[ibuf], Memr[ptr], QG_NX(qg, amp))
		    ptr  = ptr + QG_NX(qg, amp)
		}
	    }
	}
end