CR2RE Pipeline Reference Manual 1.6.10
hdrl_cat_areals.c
1/*
2 * This file is part of the HDRL
3 * Copyright (C) 2017 European Southern Observatory
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <string.h>
21
22#include "hdrl_cat_areals.h"
23
24
25/*----------------------------------------------------------------------------*/
33/*----------------------------------------------------------------------------*/
34
37/* ---------------------------------------------------------------------------*/
51/* ---------------------------------------------------------------------------*/
52void hdrl_areals(ap_t *ap, cpl_size iareal[NAREAL])
53{
54
55 /* Initialise some stuff */
56 cpl_size np = ap->npl_pix;
57 plstruct *plarray = ap->plarray;
58 double thresh = ap->thresh;
59 double fconst = ap->fconst;
60 double offset = ap->areal_offset;
61
62 /* Zero the areal profile array */
63 memset(iareal, 0, NAREAL * sizeof(cpl_size));
64
65 /* Loop through the array and form the areal profiles */
66 for (cpl_size i = 0; i < np; i++) {
67
68 double t = plarray[i].z;
69
70 if (t > thresh) {
71
72 cpl_size nup = CPL_MAX(1, CPL_MIN(NAREAL, (cpl_size)(log(t) * fconst - offset) + 1));
73
74 for (cpl_size j = 0; j < nup; j++) {
75 iareal[j]++;
76 }
77 }
78 }
79}
80
void hdrl_areals(ap_t *ap, cpl_size iareal[NAREAL])
Work out the areal profiles for an object.