1 /*********************************************************************
2 Segment - Segment initial labels based on signal structure.
3 Segment is part of GNU Astronomy Utilities (Gnuastro) package.
4 
5 Original author:
6      Mohammad Akhlaghi <mohammad@akhlaghi.org>
7 Contributing author(s):
8 Copyright (C) 2018-2021, Free Software Foundation, Inc.
9 
10 Gnuastro is free software: you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published by the
12 Free Software Foundation, either version 3 of the License, or (at your
13 option) any later version.
14 
15 Gnuastro is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
22 **********************************************************************/
23 #ifndef MAIN_H
24 #define MAIN_H
25 
26 /* Include necessary headers */
27 #include <gnuastro/data.h>
28 
29 #include <gnuastro-internal/options.h>
30 
31 /* Progarm names.  */
32 #define PROGRAM_NAME   "Segment"    /* Program full name.       */
33 #define PROGRAM_EXEC   "astsegment" /* Program executable name. */
34 #define PROGRAM_STRING PROGRAM_NAME" (" PACKAGE_NAME ") " PACKAGE_VERSION
35 
36 
37 /* Macros */
38 #define DETECTION_ALL  "all"
39 
40 
41 
42 
43 
44 
45 /* Main program parameters structure */
46 struct segmentparams
47 {
48   /* From command-line */
49   struct gal_options_common_params  cp; /* Common parameters.             */
50   struct gal_tile_two_layer_params ltl; /* Large tessellation.            */
51   char             *inputname;  /* Input filename.                        */
52   char            *kernelname;  /* Input kernel filename.                 */
53   char                  *khdu;  /* Kernel HDU.                            */
54   char         *convolvedname;  /* Convolved image (to avoid convolution).*/
55   char                  *chdu;  /* HDU of convolved image.                */
56   char         *detectionname;  /* Detection image file name.             */
57   char                  *dhdu;  /* Detection image file name.             */
58   char               *skyname;  /* Filename of Sky image.                 */
59   char                *skyhdu;  /* Filename of Sky image.                 */
60   char               *stdname;  /* File name of Standard deviation image. */
61   char                *stdhdu;  /* HDU of Stanard deviation image.        */
62   uint8_t            variance;  /* The input STD is actually variance.    */
63   uint8_t           rawoutput;  /* Output only object and clump labels.   */
64 
65   float            minskyfrac;  /* Undetected area min. frac. in tile.    */
66   uint8_t              minima;  /* Build clumps from their minima, maxima.*/
67   size_t            snminarea;  /* Minimum area for segmentation.         */
68   uint8_t             checksn;  /* Save the clump S/N values to a file.   */
69   size_t          minnumfalse;  /* Min No. of det/seg for true quantile.  */
70   float               snquant;  /* Quantile of clumps in sky for true S/N.*/
71   uint8_t    keepmaxnearriver;  /* Keep clumps with a peak near a river.  */
72   float         clumpsnthresh;  /* Clump S/N threshold.                   */
73   uint8_t          onlyclumps;  /* Finish after finding true clumps.      */
74   float               gthresh;  /* Multiple of STD to stop growing clumps.*/
75   size_t       minriverlength;  /* Min, len of good grown clump rivers.   */
76   float           objbordersn;  /* Minimum S/N for grown clumps to be one.*/
77   uint8_t         grownclumps;  /* Save grown clumps instead of original. */
78   uint8_t  continueaftercheck;  /* Don't abort after the check steps.     */
79   uint8_t   checksegmentation;  /* Save the segmentation steps in file.   */
80 
81   /* Internal. */
82   char        *clumpsn_s_name;  /* Sky clump S/N name.                    */
83   char        *clumpsn_d_name;  /* Detection clumps S/N name.             */
84   char      *segmentationname;  /* Name of segmentation steps file.       */
85 
86   gal_data_t           *input;  /* Input dataset.                         */
87   gal_data_t          *kernel;  /* Given kernel for convolution.          */
88   gal_data_t            *conv;  /* Convolved dataset.                     */
89   gal_data_t          *binary;  /* For binary operations.                 */
90   gal_data_t          *olabel;  /* Object labels.                         */
91   gal_data_t          *clabel;  /* Clumps labels.                         */
92   gal_data_t             *std;  /* STD of undetected pixels, per tile.    */
93   gal_data_t       *clumpvals;  /* Values to build clumps (avoid bugs).   */
94 
95   float               cpscorr;  /* Counts/second correction.              */
96   size_t        numdetections;  /* Number of final detections.            */
97   size_t            numclumps;  /* Number of true clumps.                 */
98   size_t           numobjects;  /* Number of objects.                     */
99 
100   char     *useddetectionname;  /* Name of file USED for detection image. */
101   char           *usedstdname;  /* Name of file USED for sky STD image.   */
102 
103   float                medstd;  /* For output STD image: median STD.      */
104   float                minstd;  /* For output STD image: median STD.      */
105   float                maxstd;  /* For output STD image: median STD.      */
106 
107   /* Output: */
108   time_t              rawtime;  /* Starting time of the program.          */
109 };
110 
111 #endif
112