aboutsummaryrefslogtreecommitdiff
path: root/noao/onedspec/identify/idcenter.x
blob: 6b6dba06c8ffe9d643d14614e5efbd87a31bf5df (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
include	<smw.h>
include	"identify.h"

# ID_CENTER -- Locate the center of a feature.

double procedure id_center (id, x, width, type)

pointer	id				# ID pointer
double	x				# Initial guess
real	width				# Feature width
int	type				# Feature type

int	np1
real	value
double	dvalue

real	center1d()
double	smw_c1trand()

begin
	if (IS_INDEFD(x))
	    return (x)

	dvalue = smw_c1trand (ID_PL(id), x)
	if (IS_INDEFD(dvalue))
	    return (dvalue)

	np1 = NP1(ID_SH(id)) - 1
	value = dvalue - np1
 	value = center1d (value, IMDATA(id,1), ID_NPTS(id),
	    width, type, ID_CRADIUS(id), ID_THRESHOLD(id))

	if (IS_INDEF(value))
	    return (INDEFD)
	else
	    return (smw_c1trand (ID_LP(id), double(value+np1)))
end