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
|
# AP_ICTR -- Given a subraster of pixels and an initial center compute
# the centroid of the pixels.
procedure ap_ictr (im, wx, wy, radius, emission, xcenter, ycenter)
pointer im # pointer to the iraf image
real wx # initial x coordinate
real wy # initial y coordinate
int radius # half width of centering box
int emission # emission feature
real xcenter # fitted x coordinate
real ycenter # fitted y coordinate
int nx, ny, ier
pointer cbuf
real xc, yc, datamin, datamax, junk
int ap_mctr1d()
pointer ap_ctrpix()
begin
# Get the pixels.
cbuf = ap_ctrpix (im, wx, wy, radius, xc, yc, nx, ny)
if (cbuf == NULL) {
xcenter = wx
ycenter = wy
return
}
# Fit the center of the subraster.
call alimr (Memr[cbuf], nx * ny, datamin, datamax)
if (emission == YES)
call asubkr (Memr[cbuf], datamin, Memr[cbuf], nx * ny)
else {
call anegr (Memr[cbuf], Memr[cbuf], nx * ny)
call aaddkr (Memr[cbuf], datamax, Memr[cbuf], nx * ny)
}
ier = ap_mctr1d (Memr[cbuf], nx, ny, 1.0, xcenter, ycenter, junk, junk)
# Compute the center in image coordinates.
if (IS_INDEFR(xcenter))
xcenter = wx
else
xcenter = xcenter + wx - xc
if (IS_INDEFR(ycenter))
ycenter = wy
else
ycenter = ycenter + wy - yc
end
|