gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master e90b490 116/125: Internal headers moved to spe


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master e90b490 116/125: Internal headers moved to special directory
Date: Sun, 23 Apr 2017 22:36:51 -0400 (EDT)

branch: master
commit e90b490d2bd89270235b8706828e607952a656a0
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    Internal headers moved to special directory
    
    Until now, Gnuastro's internal headers were simply in the `lib/'
    directory. So when you wanted to include `options.h', the include directive
    would be `#include <options.h>'. Since Gnuastro's installed libraries are
    in a `gnuastro' directory, the fact that the internal library headers are
    simply mixed with the `.c' files of all the libraries can be confusing for
    a new inquirer into the code.
    
    To fix this issue and also to allow further symmetricity and clarity of the
    source code, a new `lib/gnuastro-internal/' directory was created and all
    internal headers are now put into there. So the include directive is now
    `#include <gnuastro-internal/options.h>', it is longer, but it provides a
    better level of documentation and clarity.
    
    Work is also ongoing on the re-write of NoiseChisel, it has currently
    reached the stage of filling holes that is necessary to define
    pseudo-detections.
---
 bin/arithmetic/arithmetic.c                      |   2 +-
 bin/arithmetic/main.c                            |   2 +-
 bin/arithmetic/main.h                            |   2 +-
 bin/arithmetic/ui.c                              |  10 +-
 bin/convertt/convertt.c                          |   2 +-
 bin/convertt/eps.c                               |   4 +-
 bin/convertt/main.c                              |   2 +-
 bin/convertt/main.h                              |   2 +-
 bin/convertt/ui.c                                |  10 +-
 bin/convolve/convolve.c                          |   2 +-
 bin/convolve/main.c                              |   2 +-
 bin/convolve/main.h                              |   2 +-
 bin/convolve/ui.c                                |  10 +-
 bin/cosmiccal/main.c                             |   2 +-
 bin/cosmiccal/main.h                             |   2 +-
 bin/cosmiccal/ui.c                               |  10 +-
 bin/crop/crop.c                                  |   4 +-
 bin/crop/main.c                                  |   2 +-
 bin/crop/main.h                                  |   2 +-
 bin/crop/onecrop.c                               |   4 +-
 bin/crop/ui.c                                    |  10 +-
 bin/fits/fits.c                                  |   4 +-
 bin/fits/keywords.c                              |   2 +-
 bin/fits/main.c                                  |   2 +-
 bin/fits/main.h                                  |   2 +-
 bin/fits/ui.c                                    |   8 +-
 bin/mknoise/main.c                               |   2 +-
 bin/mknoise/main.h                               |   2 +-
 bin/mknoise/mknoise.c                            |   2 +-
 bin/mknoise/ui.c                                 |  10 +-
 bin/mkprof/main.c                                |   2 +-
 bin/mkprof/main.h                                |   2 +-
 bin/mkprof/mkprof.c                              |   4 +-
 bin/mkprof/oneprofile.c                          |   2 +-
 bin/mkprof/ui.c                                  |  10 +-
 bin/noisechisel/detection.c                      | 127 ++++++-
 bin/noisechisel/detection.h                      |   3 +
 bin/noisechisel/main.c                           |   2 +-
 bin/noisechisel/main.h                           |   4 +-
 bin/noisechisel/noisechisel.c                    |   5 +-
 bin/noisechisel/threshold.c                      | 445 +++++++++++++++++------
 bin/noisechisel/threshold.h                      |  18 +
 bin/noisechisel/ui.c                             |  10 +-
 bin/statistics/main.c                            |   2 +-
 bin/statistics/main.h                            |   2 +-
 bin/statistics/sky.c                             |   4 +-
 bin/statistics/statistics.c                      |   4 +-
 bin/statistics/ui.c                              |  10 +-
 bin/table/main.c                                 |   2 +-
 bin/table/main.h                                 |   2 +-
 bin/table/ui.c                                   |  10 +-
 bin/warp/main.c                                  |   2 +-
 bin/warp/main.h                                  |   2 +-
 bin/warp/ui.c                                    |  10 +-
 doc/Makefile.am                                  |   2 +-
 lib/Makefile.am                                  |  13 +-
 lib/arithmetic-onlyint.c                         |   2 +-
 lib/arithmetic.c                                 |   4 +-
 lib/binary.c                                     |  32 ++
 lib/blank.c                                      |   2 +-
 lib/checkset.c                                   |   2 +-
 lib/config.h.in                                  |  78 ----
 lib/convolve.c                                   |   2 +-
 lib/data.c                                       |   2 +-
 lib/fits.c                                       |   4 +-
 lib/gnuastro-internal/README                     |   9 +
 lib/{ => gnuastro-internal}/arithmetic-binary.h  |   0
 lib/{ => gnuastro-internal}/arithmetic-onlyint.h |   0
 lib/{ => gnuastro-internal}/checkset.h           |   2 +-
 lib/{ => gnuastro-internal}/commonopts.h         |   0
 lib/{ => gnuastro-internal}/fixedstringmacros.h  |   0
 lib/{ => gnuastro-internal}/options.h            |   0
 lib/{ => gnuastro-internal}/timing.h             |   0
 lib/gnuastro/binary.h                            |   6 +
 lib/gnuastro/tile.h                              |  49 +++
 lib/interpolate.c                                |   2 +-
 lib/linkedlist.c                                 |   2 +-
 lib/options.c                                    |   6 +-
 lib/statistics.c                                 |   2 +-
 lib/table.c                                      |   4 +-
 lib/tile.c                                       |   2 +-
 lib/timing.c                                     |   2 +-
 lib/txt.c                                        |   2 +-
 tmpfs-config-make                                |   3 +-
 84 files changed, 717 insertions(+), 323 deletions(-)

diff --git a/bin/arithmetic/arithmetic.c b/bin/arithmetic/arithmetic.c
index 182e039..44677fe 100644
--- a/bin/arithmetic/arithmetic.c
+++ b/bin/arithmetic/arithmetic.c
@@ -33,7 +33,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/array.h>
 #include <gnuastro/arithmetic.h>
 
-#include <checkset.h>
+#include <gnuastro-internal/checkset.h>
 
 #include "main.h"
 
diff --git a/bin/arithmetic/main.c b/bin/arithmetic/main.c
index b0eea01..5756181 100644
--- a/bin/arithmetic/main.c
+++ b/bin/arithmetic/main.c
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <timing.h>    /* Includes time.h and sys/time.h */
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
diff --git a/bin/arithmetic/main.h b/bin/arithmetic/main.h
index 660ea80..df69d0c 100644
--- a/bin/arithmetic/main.h
+++ b/bin/arithmetic/main.h
@@ -26,7 +26,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/fits.h>
 #include <gnuastro/linkedlist.h>
 
-#include <options.h>
+#include <gnuastro-internal/options.h>
 
 
 /* Progarm name macros: */
diff --git a/bin/arithmetic/ui.c b/bin/arithmetic/ui.c
index 66711fa..f44ee51 100644
--- a/bin/arithmetic/ui.c
+++ b/bin/arithmetic/ui.c
@@ -31,10 +31,10 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/table.h>
 #include <gnuastro/linkedlist.h>
 
-#include <timing.h>
-#include <options.h>
-#include <checkset.h>
-#include <fixedstringmacros.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/options.h>
+#include <gnuastro-internal/checkset.h>
+#include <gnuastro-internal/fixedstringmacros.h>
 
 #include "main.h"
 
@@ -317,7 +317,7 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
imgarithparams *p)
      those headers which make them hard to read and modify. This also helps
      in having a clean environment: everything in those headers is only
      available within the scope of this function. */
-#include <commonopts.h>
+#include <gnuastro-internal/commonopts.h>
 #include "args.h"
 
 
diff --git a/bin/convertt/convertt.c b/bin/convertt/convertt.c
index 285fe4e..f96a410 100644
--- a/bin/convertt/convertt.c
+++ b/bin/convertt/convertt.c
@@ -34,7 +34,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/txtarray.h>
 #include <gnuastro/arithmetic.h>
 
-#include <timing.h>
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
diff --git a/bin/convertt/eps.c b/bin/convertt/eps.c
index a4b2f61..6e75ea7 100644
--- a/bin/convertt/eps.c
+++ b/bin/convertt/eps.c
@@ -28,8 +28,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdlib.h>
 #include <string.h>
 
-#include <timing.h>
-#include <checkset.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/checkset.h>
 
 #include "main.h"
 
diff --git a/bin/convertt/main.c b/bin/convertt/main.c
index 443680b..2d1f9b8 100644
--- a/bin/convertt/main.c
+++ b/bin/convertt/main.c
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <timing.h>              /* Includes time.h and sys/time.h */
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
diff --git a/bin/convertt/main.h b/bin/convertt/main.h
index 37d0c78..ea48dc7 100644
--- a/bin/convertt/main.h
+++ b/bin/convertt/main.h
@@ -26,7 +26,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /* Include necessary headers */
 #include <gnuastro/data.h>
 
-#include <options.h>
+#include <gnuastro-internal/options.h>
 
 /* Progarm names.  */
 #define PROGRAM_NAME   "ConvertType"   /* Program full name.       */
diff --git a/bin/convertt/ui.c b/bin/convertt/ui.c
index d6977aa..f32372b 100644
--- a/bin/convertt/ui.c
+++ b/bin/convertt/ui.c
@@ -34,10 +34,10 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/table.h>
 #include <gnuastro/arithmetic.h>
 
-#include <timing.h>
-#include <options.h>
-#include <checkset.h>
-#include <fixedstringmacros.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/options.h>
+#include <gnuastro-internal/checkset.h>
+#include <gnuastro-internal/fixedstringmacros.h>
 
 #include "main.h"
 
@@ -780,7 +780,7 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
converttparams *p)
      those headers which make them hard to read and modify. This also helps
      in having a clean environment: everything in those headers is only
      available within the scope of this function. */
-#include <commonopts.h>
+#include <gnuastro-internal/commonopts.h>
 #include "args.h"
 
 
diff --git a/bin/convolve/convolve.c b/bin/convolve/convolve.c
index 7327598..4e993f4 100644
--- a/bin/convolve/convolve.c
+++ b/bin/convolve/convolve.c
@@ -36,7 +36,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/convolve.h>
 #include <gnuastro/spatialconvolve.h>
 
-#include <timing.h>
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 #include "convolve.h"
diff --git a/bin/convolve/main.c b/bin/convolve/main.c
index bdf018b..760746c 100644
--- a/bin/convolve/main.c
+++ b/bin/convolve/main.c
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <timing.h>             /* Includes time.h and sys/time.h */
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
diff --git a/bin/convolve/main.h b/bin/convolve/main.h
index 03edab5..0e9d924 100644
--- a/bin/convolve/main.h
+++ b/bin/convolve/main.h
@@ -26,7 +26,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /* Include necessary headers */
 #include <gnuastro/data.h>
 
-#include <options.h>
+#include <gnuastro-internal/options.h>
 
 /* Program names.  */
 #define PROGRAM_NAME   "Convolve"      /* Program full name.       */
diff --git a/bin/convolve/ui.c b/bin/convolve/ui.c
index 052a0ee..582e33d 100644
--- a/bin/convolve/ui.c
+++ b/bin/convolve/ui.c
@@ -38,10 +38,10 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/statistics.h>
 #include <gnuastro/linkedlist.h>
 
-#include <timing.h>
-#include <options.h>
-#include <checkset.h>
-#include <fixedstringmacros.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/options.h>
+#include <gnuastro-internal/checkset.h>
+#include <gnuastro-internal/fixedstringmacros.h>
 
 #include "main.h"
 
@@ -495,7 +495,7 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
convolveparams *p)
      those headers which make them hard to read and modify. This also helps
      in having a clean environment: everything in those headers is only
      available within the scope of this function. */
-#include <commonopts.h>
+#include <gnuastro-internal/commonopts.h>
 #include "args.h"
 
 
diff --git a/bin/cosmiccal/main.c b/bin/cosmiccal/main.c
index d4906ad..cc38b55 100644
--- a/bin/cosmiccal/main.c
+++ b/bin/cosmiccal/main.c
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <timing.h>    /* Includes time.h and sys/time.h */
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
diff --git a/bin/cosmiccal/main.h b/bin/cosmiccal/main.h
index acdae15..248b348 100644
--- a/bin/cosmiccal/main.h
+++ b/bin/cosmiccal/main.h
@@ -26,7 +26,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /* Include necessary headers */
 #include <gnuastro/data.h>
 
-#include <options.h>
+#include <gnuastro-internal/options.h>
 
 /* Progarm names.  */
 #define PROGRAM_NAME   "CosmicCalculator" /* Program full name.       */
diff --git a/bin/cosmiccal/ui.c b/bin/cosmiccal/ui.c
index 9521537..a212914 100644
--- a/bin/cosmiccal/ui.c
+++ b/bin/cosmiccal/ui.c
@@ -33,10 +33,10 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/table.h>
 #include <gnuastro/linkedlist.h>
 
-#include <timing.h>
-#include <options.h>
-#include <checkset.h>
-#include <fixedstringmacros.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/options.h>
+#include <gnuastro-internal/checkset.h>
+#include <gnuastro-internal/fixedstringmacros.h>
 
 #include "main.h"
 
@@ -247,7 +247,7 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
cosmiccalparams *p)
      those headers which make them hard to read and modify. This also helps
      in having a clean environment: everything in those headers is only
      available within the scope of this function. */
-#include <commonopts.h>
+#include <gnuastro-internal/commonopts.h>
 #include "args.h"
 
 
diff --git a/bin/crop/crop.c b/bin/crop/crop.c
index 2de990d..433c119 100644
--- a/bin/crop/crop.c
+++ b/bin/crop/crop.c
@@ -32,8 +32,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/fits.h>
 #include <gnuastro/threads.h>
 
-#include <timing.h>
-#include <checkset.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/checkset.h>
 
 #include "main.h"
 
diff --git a/bin/crop/main.c b/bin/crop/main.c
index bf2a589..c929774 100644
--- a/bin/crop/main.c
+++ b/bin/crop/main.c
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <timing.h>    /* Includes time.h and sys/time.h */
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
diff --git a/bin/crop/main.h b/bin/crop/main.h
index 77828b5..c53b3ec 100644
--- a/bin/crop/main.h
+++ b/bin/crop/main.h
@@ -26,7 +26,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /* Include necessary headers */
 #include <gnuastro/data.h>
 
-#include <options.h>
+#include <gnuastro-internal/options.h>
 
 /* Progarm names.  */
 #define PROGRAM_NAME   "Crop"     /* Program full name.       */
diff --git a/bin/crop/onecrop.c b/bin/crop/onecrop.c
index a09b52e..cd97e7b 100644
--- a/bin/crop/onecrop.c
+++ b/bin/crop/onecrop.c
@@ -36,8 +36,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/blank.h>
 #include <gnuastro/polygon.h>
 
-#include <timing.h>
-#include <checkset.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/checkset.h>
 
 #include "main.h"
 
diff --git a/bin/crop/ui.c b/bin/crop/ui.c
index f988f7a..85c17c6 100644
--- a/bin/crop/ui.c
+++ b/bin/crop/ui.c
@@ -34,10 +34,10 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/table.h>
 #include <gnuastro/linkedlist.h>
 
-#include <timing.h>
-#include <options.h>
-#include <checkset.h>
-#include <fixedstringmacros.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/options.h>
+#include <gnuastro-internal/checkset.h>
+#include <gnuastro-internal/fixedstringmacros.h>
 
 #include "main.h"
 
@@ -771,7 +771,7 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
cropparams *p)
      those headers which make them hard to read and modify. This also helps
      in having a clean environment: everything in those headers is only
      available within the scope of this function. */
-#include <commonopts.h>
+#include <gnuastro-internal/commonopts.h>
 #include "args.h"
 
 
diff --git a/bin/fits/fits.c b/bin/fits/fits.c
index 2a70ed6..773c467 100644
--- a/bin/fits/fits.c
+++ b/bin/fits/fits.c
@@ -29,8 +29,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/fits.h>
 #include <gnuastro/blank.h>
 
-#include "timing.h"
-#include "checkset.h"
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/checkset.h>
 
 #include "main.h"
 
diff --git a/bin/fits/keywords.c b/bin/fits/keywords.c
index bfdaffe..d97c985 100644
--- a/bin/fits/keywords.c
+++ b/bin/fits/keywords.c
@@ -31,7 +31,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/fits.h>
 #include <gnuastro/linkedlist.h>
 
-#include "checkset.h"
+#include <gnuastro-internal/checkset.h>
 
 #include "main.h"
 
diff --git a/bin/fits/main.c b/bin/fits/main.c
index 4f3eefb..d19b6da 100644
--- a/bin/fits/main.c
+++ b/bin/fits/main.c
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <timing.h>    /* Includes time.h and sys/time.h */
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
diff --git a/bin/fits/main.h b/bin/fits/main.h
index 142ab00..13f1405 100644
--- a/bin/fits/main.h
+++ b/bin/fits/main.h
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 #include <gnuastro/fits.h>
 
-#include <options.h>
+#include <gnuastro-internal/options.h>
 
 /* Progarm name macros: */
 #define PROGRAM_NAME  "Fits"        /* Program full name.       */
diff --git a/bin/fits/ui.c b/bin/fits/ui.c
index f83c8f9..4359455 100644
--- a/bin/fits/ui.c
+++ b/bin/fits/ui.c
@@ -31,9 +31,9 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/fits.h>
 #include <gnuastro/linkedlist.h>
 
-#include <options.h>
-#include <checkset.h>
-#include <fixedstringmacros.h>
+#include <gnuastro-internal/options.h>
+#include <gnuastro-internal/checkset.h>
+#include <gnuastro-internal/fixedstringmacros.h>
 
 #include "main.h"
 
@@ -471,7 +471,7 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
fitsparams *p)
      those headers which make them hard to read and modify. This also helps
      in having a clean environment: everything in those headers is only
      available within the scope of this function. */
-#include <commonopts.h>
+#include <gnuastro-internal/commonopts.h>
 #include "args.h"
 
 
diff --git a/bin/mknoise/main.c b/bin/mknoise/main.c
index 12e9c73..dd2c311 100644
--- a/bin/mknoise/main.c
+++ b/bin/mknoise/main.c
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <timing.h>             /* Includes time.h and sys/time.h */
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
diff --git a/bin/mknoise/main.h b/bin/mknoise/main.h
index a09c350..d143cdd 100644
--- a/bin/mknoise/main.h
+++ b/bin/mknoise/main.h
@@ -27,7 +27,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/data.h>
 #include <gsl/gsl_rng.h>
 
-#include <options.h>
+#include <gnuastro-internal/options.h>
 
 /* Progarm names.  */
 #define PROGRAM_NAME   "MakeNoise"     /* Program full name.       */
diff --git a/bin/mknoise/mknoise.c b/bin/mknoise/mknoise.c
index 873cca6..78d9bb5 100644
--- a/bin/mknoise/mknoise.c
+++ b/bin/mknoise/mknoise.c
@@ -34,7 +34,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/fits.h>
 #include <gsl/gsl_randist.h>     /* To make noise.        */
 
-#include <timing.h>
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
diff --git a/bin/mknoise/ui.c b/bin/mknoise/ui.c
index c9b283a..f2a6134 100644
--- a/bin/mknoise/ui.c
+++ b/bin/mknoise/ui.c
@@ -32,10 +32,10 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/table.h>
 #include <gnuastro/linkedlist.h>
 
-#include <timing.h>
-#include <options.h>
-#include <checkset.h>
-#include <fixedstringmacros.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/options.h>
+#include <gnuastro-internal/checkset.h>
+#include <gnuastro-internal/fixedstringmacros.h>
 
 #include "main.h"
 
@@ -334,7 +334,7 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
mknoiseparams *p)
      those headers which make them hard to read and modify. This also helps
      in having a clean environment: everything in those headers is only
      available within the scope of this function. */
-#include <commonopts.h>
+#include <gnuastro-internal/commonopts.h>
 #include "args.h"
 
 
diff --git a/bin/mkprof/main.c b/bin/mkprof/main.c
index e47f538..9927864 100644
--- a/bin/mkprof/main.c
+++ b/bin/mkprof/main.c
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <timing.h>             /* Includes time.h and sys/time.h */
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 #include "mkprof.h"
diff --git a/bin/mkprof/main.h b/bin/mkprof/main.h
index eac8c1d..74f62cf 100644
--- a/bin/mkprof/main.h
+++ b/bin/mkprof/main.h
@@ -28,7 +28,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 #include <gnuastro/fits.h>
 
-#include <options.h>
+#include <gnuastro-internal/options.h>
 
 
 /* Progarm name macros: */
diff --git a/bin/mkprof/mkprof.c b/bin/mkprof/mkprof.c
index fe4e961..2bebb33 100644
--- a/bin/mkprof/mkprof.c
+++ b/bin/mkprof/mkprof.c
@@ -37,8 +37,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/txtarray.h>
 #include <gnuastro/statistics.h>
 
-#include <timing.h>
-#include <checkset.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/checkset.h>
 
 #include "main.h"
 
diff --git a/bin/mkprof/oneprofile.c b/bin/mkprof/oneprofile.c
index aa2101c..9941f92 100644
--- a/bin/mkprof/oneprofile.c
+++ b/bin/mkprof/oneprofile.c
@@ -39,7 +39,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/statistics.h>
 #include <gnuastro/linkedlist.h>
 
-#include <timing.h>
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
diff --git a/bin/mkprof/ui.c b/bin/mkprof/ui.c
index 57bc439..0b352d7 100644
--- a/bin/mkprof/ui.c
+++ b/bin/mkprof/ui.c
@@ -35,10 +35,10 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/table.h>
 #include <gnuastro/linkedlist.h>
 
-#include <timing.h>
-#include <options.h>
-#include <checkset.h>
-#include <fixedstringmacros.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/options.h>
+#include <gnuastro-internal/checkset.h>
+#include <gnuastro-internal/fixedstringmacros.h>
 
 #include "main.h"
 
@@ -941,7 +941,7 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
mkprofparams *p)
      those headers which make them hard to read and modify. This also helps
      in having a clean environment: everything in those headers is only
      available within the scope of this function. */
-#include <commonopts.h>
+#include <gnuastro-internal/commonopts.h>
 #include "args.h"
 
 
diff --git a/bin/noisechisel/detection.c b/bin/noisechisel/detection.c
index 404cd3b..827d30e 100644
--- a/bin/noisechisel/detection.c
+++ b/bin/noisechisel/detection.c
@@ -28,7 +28,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/fits.h>
 #include <gnuastro/binary.h>
 
-#include <timing.h>
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
@@ -50,7 +50,6 @@ detection_initial(struct noisechiselparams *p)
   struct timeval t0, t1;
 
 
-
   /* Get the starting time. */
   if(!p->cp.quiet)
     {
@@ -59,7 +58,6 @@ detection_initial(struct noisechiselparams *p)
     }
 
 
-
   /* Find and apply the threshold on the input. */
   threshold_quantile_find_apply(p);
   if(p->detectionname)
@@ -70,7 +68,6 @@ detection_initial(struct noisechiselparams *p)
     }
 
 
-
   /* Erode the image. */
   if(!p->cp.quiet) gettimeofday(&t1, NULL);
   gal_binary_erode(p->binary, p->erode, p->erodengb, 1);
@@ -88,12 +85,10 @@ detection_initial(struct noisechiselparams *p)
     }
 
 
-
   /* Correct the no-erode values. */
   bf=(b=p->binary->array)+p->binary->size; do *b = *b>0; while(++b<bf);
 
 
-
   /* Do the opening. */
   if(!p->cp.quiet) gettimeofday(&t1, NULL);
   gal_binary_open(p->binary, p->opening, p->openingngb, 1);
@@ -111,7 +106,6 @@ detection_initial(struct noisechiselparams *p)
     }
 
 
-
   /* Label the connected components. */
   p->numobjects=gal_binary_connected_components(p->binary, &p->olabel, 1);
   if(p->detectionname)
@@ -122,7 +116,6 @@ detection_initial(struct noisechiselparams *p)
     }
 
 
-
   /* Report the ending of initial detection. */
   if(!p->cp.quiet)
     {
@@ -130,7 +123,125 @@ detection_initial(struct noisechiselparams *p)
       gal_timing_report(&t0, msg, 1);
       free(msg);
     }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/****************************************************************
+ ************     Pseudo detection S/N threshold     ************
+ ****************************************************************/
+/* We have the thresholded image (with blank values for regions that should
+   not be used). Find the pseudo-detections in those regions. */
+void
+detection_find_pseudos(struct noisechiselparams *p, gal_data_t workbin)
+{
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/****************************************************************
+ ************        Removing false detections       ************
+ ****************************************************************/
+/*  */
+static void
+detection_keep_sky_or_det(struct noisechiselparams *p, uint8_t *w, int s0d1)
+{
+  uint32_t *l=p->olabel->array;
+  uint8_t *b=p->binary->array, *bf=b+p->binary->size;
+
+  if(s0d1)
+    /* Set all sky regions (label equal to zero) to blank. */
+    do *w++ = *l++ ? *b : GAL_BLANK_UINT8; while(++b<bf);
+  else
+    /* Set all detected pixels (label larger than zero) to blank. */
+    do *w++ = *l++ ? GAL_BLANK_UINT8 : *b; while(++b<bf);
+}
+
+
+
+
+
+/* The initial detection has been done, now we want to remove false
+   detections. */
+void
+detection_remove_false(struct noisechiselparams *p)
+{
+  char *msg;
+  struct timeval t1;
+  gal_data_t *workbin;
+
+  /* Find the Sky and its Standard Deviation from the initial detectios. */
+  if(!p->cp.quiet) gettimeofday(&t1, NULL);
+  threshold_sky_and_std(p);
+  if(!p->cp.quiet)
+    gal_timing_report(&t1, "Initial (crude) Sky and its STD found.", 2);
+
+
+  /* Apply the sky threshold. */
+  if(!p->cp.quiet) gettimeofday(&t1, NULL);
+  threshold_apply(p, p->sky->array, p->std->array, THRESHOLD_SKY_STD);
+  if(!p->cp.quiet)
+    {
+      asprintf(&msg, "Pseudo-detection thresh (%.3f sigma) applied.",
+               p->dthresh);
+      gal_timing_report(&t1, msg, 2);
+      free(msg);
+    }
+
+
+  /* Allocate the space for the pseudo-detection threshold. */
+  workbin=gal_data_alloc(NULL, GAL_TYPE_UINT8, p->input->ndim,
+                         p->input->dsize, p->input->wcs, 0, p->cp.minmapsize,
+                         NULL, NULL, NULL);
+
+
+  /* Set all the initial detected pixels to blank values. */
+  detection_keep_sky_or_det(p, workbin->array, 0);
+  if(p->detectionname)
+    {
+      workbin->name="DTHRESH-ON-SKY";
+      gal_fits_img_write(workbin, p->detectionname, NULL, PROGRAM_STRING);
+      workbin->name=NULL;
+    }
+
 
+  /* Clean up. */
+  gal_data_free(workbin);
 
 
   /* If the user wanted to check the threshold and hasn't called
diff --git a/bin/noisechisel/detection.h b/bin/noisechisel/detection.h
index 1923622..b785f9f 100644
--- a/bin/noisechisel/detection.h
+++ b/bin/noisechisel/detection.h
@@ -26,4 +26,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 void
 detection_initial(struct noisechiselparams *p);
 
+void
+detection_remove_false(struct noisechiselparams *p);
+
 #endif
diff --git a/bin/noisechisel/main.c b/bin/noisechisel/main.c
index d7eb2d5..53565a4 100644
--- a/bin/noisechisel/main.c
+++ b/bin/noisechisel/main.c
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <timing.h>             /* Includes time.h and sys/time.h */
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
diff --git a/bin/noisechisel/main.h b/bin/noisechisel/main.h
index aa9c388..5bf608c 100644
--- a/bin/noisechisel/main.h
+++ b/bin/noisechisel/main.h
@@ -26,7 +26,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /* Include necessary headers */
 #include <gnuastro/data.h>
 
-#include <options.h>
+#include <gnuastro-internal/options.h>
 
 /* Progarm names.  */
 #define PROGRAM_NAME   "NoiseChisel"    /* Program full name.       */
@@ -97,6 +97,8 @@ struct noisechiselparams
   gal_data_t            *conv;  /* Convolved input.                       */
   gal_data_t          *binary;  /* For binary operations.                 */
   gal_data_t          *olabel;  /* Labels of objects in the detection.    */
+  gal_data_t             *sky;  /* Mean of undetected pixels, per tile.   */
+  gal_data_t             *std;  /* STD of undetected pixels, per tile.    */
   time_t              rawtime;  /* Starting time of the program.          */
 
   size_t           numobjects;  /* Number of objects detected.            */
diff --git a/bin/noisechisel/noisechisel.c b/bin/noisechisel/noisechisel.c
index d25fab8..39ec6ec 100644
--- a/bin/noisechisel/noisechisel.c
+++ b/bin/noisechisel/noisechisel.c
@@ -28,7 +28,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/fits.h>
 #include <gnuastro/convolve.h>
 
-#include <timing.h>
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
@@ -67,4 +67,7 @@ noisechisel(struct noisechiselparams *p)
 
   /* Do the initial detection: */
   detection_initial(p);
+
+  /* Remove false detections */
+  detection_remove_false(p);
 }
diff --git a/bin/noisechisel/threshold.c b/bin/noisechisel/threshold.c
index 2a58e08..8b97bfa 100644
--- a/bin/noisechisel/threshold.c
+++ b/bin/noisechisel/threshold.c
@@ -34,7 +34,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/statistics.h>
 #include <gnuastro/interpolate.h>
 
-#include <timing.h>
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
@@ -44,6 +44,184 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 
 
+
+
+
+
+
+
+/**********************************************************************/
+/***************        Apply a given threshold.      *****************/
+/**********************************************************************/
+void
+threshold_apply(struct noisechiselparams *p, float *value1, float *value2,
+                int type)
+{
+  size_t tid;
+  void *tarray=NULL;
+  gal_data_t *tile, *tblock=NULL;
+
+  /* Clear the binary array (this is mainly because the input may contain
+     blank values and we won't be doing the thresholding no those
+     pixels. */
+  memset(p->binary->array, 0, p->binary->size);
+
+  /* Go over all the tiles. */
+  for(tid=0; tid<p->cp.tl.tottiles; ++tid)
+    {
+      /* For easy reading. */
+      tile=&p->cp.tl.tiles[tid];
+
+      switch(type)
+        {
+
+        /* This is a quantile threshold. */
+        case THRESHOLD_QUANTILES:
+          /* Correct the tile's pointers to apply the threshold on the
+             convolved image. */
+          if(p->conv)
+            {
+              tarray=tile->array; tblock=tile->block;
+              tile->array=gal_tile_block_relative_to_other(tile, p->conv);
+              tile->block=p->conv;
+            }
+
+          /* Apply the threshold. */
+          GAL_TILE_PARSE_OPERATE({
+              *o = ( *i > value1[tid]
+                     ? ( *i > value2[tid] ? THRESHOLD_NO_ERODE_VALUE : 1 )
+                     : 0 );
+            }, tile, p->binary, 1, 1);
+
+          /* Revert the tile's pointers back to what they were. */
+          if(p->conv) { tile->array=tarray; tile->block=tblock; }
+          break;
+
+
+        /* This is a Sky and Sky STD threshold. */
+        case THRESHOLD_SKY_STD:
+
+          /* The threshold is always low. So for the majority of non-NaN
+             pixels in the image, the condition above will be true. If we
+             come over a NaN pixel, then by definition of NaN, all
+             conditionals will fail.
+
+             If an image doesn't have any NaN pixels, only the pixels below
+             the threshold have to be checked for a NaN which are by
+             definition a very small fraction of the total pixels. And if
+             there are NaN pixels in the image. */
+          GAL_TILE_PARSE_OPERATE({
+              *o = ( ( *i - value1[tid] > p->dthresh * value2[tid] )
+                     ? 1 : *i==*i ? 0 : GAL_BLANK_UINT8 );
+            }, tile, p->binary, 1, 1);
+          break;
+
+
+        default:
+          error(EXIT_FAILURE, 0, "a bug! please contact us at %s so we can "
+                "address the problem. For some reason a value of %d had "
+                "been given to `type' in `threshold_apply'",
+                PACKAGE_BUGREPORT, type);
+        }
+    }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**********************************************************************/
+/***************     Interpolation and smoothing      *****************/
+/**********************************************************************/
+/* Interpolate and smooth the values for each tile over the whole image. */
+static void
+threshold_interp_smooth(struct noisechiselparams *p, gal_data_t **first,
+                        gal_data_t **second, char *filename)
+{
+  gal_data_t *tmp;
+  struct gal_options_common_params *cp=&p->cp;
+  struct gal_tile_two_layer_params *tl=&cp->tl;
+
+  /* A small sanity check. */
+  if( (*first)->next )
+    error(EXIT_FAILURE, 0, "the `first' argument to "
+          "`threshold_interp_smooth' must not have any `next' pointer.");
+
+
+  /* Do the interpolation of both arrays. */
+  (*first)->next = *second;
+  tmp=gal_interpolate_close_neighbors(*first, tl, cp->interpnumngb,
+                                      cp->numthreads, cp->interponlyblank, 1);
+  gal_data_free(*first);
+  gal_data_free(*second);
+  *first=tmp;
+  *second=tmp->next;
+  (*first)->next=(*second)->next=NULL;
+  if(filename)
+    {
+      gal_tile_full_values_write(*first, tl, filename, PROGRAM_STRING);
+      gal_tile_full_values_write(*second, tl, filename, PROGRAM_STRING);
+    }
+
+
+  /* Smooth the threshold if requested. */
+  if(p->smoothwidth>1)
+    {
+      /* Smooth the first. */
+      tmp=gal_tile_full_values_smooth(*first, tl, p->smoothwidth,
+                                      p->cp.numthreads);
+      gal_data_free(*first);
+      *first=tmp;
+
+      /* Smooth the second */
+      tmp=gal_tile_full_values_smooth(*second, tl, p->smoothwidth,
+                                      p->cp.numthreads);
+      gal_data_free(*second);
+      *second=tmp;
+
+      /* Add them to the check image. */
+      if(filename)
+        {
+          gal_tile_full_values_write(*first, tl, filename, PROGRAM_STRING);
+          gal_tile_full_values_write(*second, tl, filename, PROGRAM_STRING);
+        }
+    }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 /****************************************************************
  ************           Quantile threshold           ************
  ****************************************************************/
@@ -89,16 +267,14 @@ qthresh_on_tile(void *in_prm)
       memcpy(usage->dsize, p->maxtsize, ndim*sizeof *p->maxtsize);
 
 
-      /* Copy the tile's contents into the pre-allocated space. Note that
-         we have to initialize the `dsize' and `size' elements of
-         `contents', since they can be changed and the size is
-         important. Recall that this is a 1D array. */
+      /* For easy reading. */
       tind = tprm->indexs[i];
       tile = &p->cp.tl.tiles[tind];
 
 
       /* If we have a convolved image, temporarily change the tile's
-         pointers so we can do the work on the convolved image. */
+         pointers so we can do the work on the convolved image, then copy
+         the desired contents into the already allocated `usage' array. */
       if(p->conv)
         {
           tarray=tile->array; tblock=tile->block;
@@ -130,7 +306,7 @@ qthresh_on_tile(void *in_prm)
           gal_data_free(qvalue);
 
           /* Do the same for the no-erode quantile. */
-          qvalue=gal_statistics_quantile(tile, p->noerodequant, 1);
+          qvalue=gal_statistics_quantile(usage, p->noerodequant, 1);
           memcpy(gal_data_ptr_increment(qprm->noerode_th->array, tind, type),
                  qvalue->array, twidth);
           gal_data_free(qvalue);
@@ -158,61 +334,10 @@ qthresh_on_tile(void *in_prm)
 
 
 
-static void
-apply_quantile_threshold(struct qthreshparams *qprm)
-{
-  size_t tid;
-  void *tarray=NULL;
-  gal_data_t *tile, *tblock=NULL;
-  struct noisechiselparams *p=qprm->p;
-  float *erode_th=qprm->erode_th->array, *noerode_th=qprm->noerode_th->array;
-
-  /* A small sanity check. */
-  if(qprm->erode_th->type!=GAL_TYPE_FLOAT32)
-    error(EXIT_FAILURE, 0, "`apply_quantile_threshold' currently only "
-          "supports float arrays.");
-
-  /* Clear the binary array (this is mainly because the input may contain
-     blank values and we won't be doing the thresholding no those
-     pixels. */
-  memset(p->binary->array, 0, p->binary->size);
-
-  /* Go over all the tiles. */
-  for(tid=0; tid<p->cp.tl.tottiles;++tid)
-    {
-      /* For easy reading. */
-      tile=&p->cp.tl.tiles[tid];
-
-      /* Correct the tile's pointers to apply the threshold on the
-         convolved image. */
-      if(p->conv)
-        {
-          tarray=tile->array; tblock=tile->block;
-          tile->array=gal_tile_block_relative_to_other(tile, p->conv);
-          tile->block=p->conv;
-        }
-
-      /* Apply the threshold. */
-      GAL_TILE_PARSE_OPERATE({
-          *o = ( *i > erode_th[tid]
-                 ? ( *i > noerode_th[tid] ? THRESHOLD_NO_ERODE_VALUE : 1 )
-                 : 0 );
-        }, tile, p->binary, 1, 1);
-
-      /* Revert the tile's pointers back to what they were. */
-      if(p->conv) { tile->array=tarray; tile->block=tblock; }
-    }
-}
-
-
-
-
-
 void
 threshold_quantile_find_apply(struct noisechiselparams *p)
 {
   char *msg;
-  gal_data_t *tmp;
   struct timeval t1;
   struct qthreshparams qprm;
   struct gal_options_common_params *cp=&p->cp;
@@ -258,53 +383,14 @@ threshold_quantile_find_apply(struct noisechiselparams *p)
   free(qprm.usage);
 
 
-  /* Interpolate over the blank tiles. */
-  qprm.erode_th->next = qprm.noerode_th;
-  tmp=gal_interpolate_close_neighbors(qprm.erode_th, tl, cp->interpnumngb,
-                                      cp->numthreads, cp->interponlyblank, 1);
-  gal_data_free(qprm.erode_th);
-  gal_data_free(qprm.noerode_th);
-  qprm.erode_th=tmp;
-  qprm.noerode_th=tmp->next;
-  qprm.erode_th->next=qprm.noerode_th->next=NULL;
-  if(p->qthreshname)
-    {
-      gal_tile_full_values_write(qprm.erode_th, tl, p->qthreshname,
-                                 PROGRAM_STRING);
-      gal_tile_full_values_write(qprm.noerode_th, tl, p->qthreshname,
-                                 PROGRAM_STRING);
-    }
-
-
-  /* Smooth the threshold if requested. */
-  if(p->smoothwidth>1)
-    {
-      /* Do the smoothing on the erosion quantile. */
-      if(!cp->quiet) gettimeofday(&t1, NULL);
-      tmp=gal_tile_full_values_smooth(qprm.erode_th, tl, p->smoothwidth,
-                                      p->cp.numthreads);
-      gal_data_free(qprm.erode_th);
-      qprm.erode_th=tmp;
-
-      /* Same for the no-erosion quantile. */
-      tmp=gal_tile_full_values_smooth(qprm.noerode_th, tl, p->smoothwidth,
-                                      p->cp.numthreads);
-      gal_data_free(qprm.noerode_th);
-      qprm.noerode_th=tmp;
-
-      /* Add them to the check image. */
-      if(p->qthreshname)
-        {
-          gal_tile_full_values_write(qprm.erode_th, tl, p->qthreshname,
-                                     PROGRAM_STRING);
-          gal_tile_full_values_write(qprm.noerode_th, tl, p->qthreshname,
-                                     PROGRAM_STRING);
-        }
-    }
+  /* Interpolate and smooth the derived values. */
+  threshold_interp_smooth(p, &qprm.erode_th, &qprm.noerode_th,
+                          p->qthreshname);
 
 
-  /* The quantile threshold is found, now apply it. */
-  apply_quantile_threshold(&qprm);
+  /* We now have a threshold for all tiles, apply it. */
+  threshold_apply(p, qprm.erode_th->array, qprm.noerode_th->array,
+                  THRESHOLD_QUANTILES);
 
 
   /* Write the binary image if check is requested. */
@@ -317,8 +403,8 @@ threshold_quantile_find_apply(struct noisechiselparams *p)
   gal_data_free(qprm.noerode_th);
   if(!p->cp.quiet)
     {
-      asprintf(&msg, "%.2f quantile threshold found and applied.",
-               p->qthresh);
+      asprintf(&msg, "%.2f & %0.2f quantile thresholds applied.",
+               p->qthresh, p->noerodequant);
       gal_timing_report(&t1, msg, 2);
     }
 
@@ -328,3 +414,152 @@ threshold_quantile_find_apply(struct noisechiselparams *p)
   if(p->qthreshname && !p->continueaftercheck)
     ui_abort_after_check(p, p->qthreshname, "quantile threshold check");
 }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/****************************************************************
+ ************       Mean and STD of undetected       ************
+ ****************************************************************/
+static void *
+threshold_mean_std_undetected(void *in_prm)
+{
+  struct gal_threads_params *tprm=(struct gal_threads_params *)in_prm;
+  struct noisechiselparams *p=(struct noisechiselparams *)tprm->params;
+
+  double *darr, s, s2;
+  int type=p->sky->type;
+  size_t i, tind, numsky, dsize=2;
+  gal_data_t *tile, *meanstd_d, *meanstd, *bintile;
+
+
+  /* A dataset to keep the mean and STD in double type. */
+  meanstd_d=gal_data_alloc(NULL, GAL_TYPE_FLOAT64, 1, &dsize,
+                           NULL, 0, -1, NULL, NULL, NULL);
+  darr=meanstd_d->array;
+
+
+  /* An empty dataset to replicate a tile on the binary array. */
+  bintile=gal_data_alloc(NULL, GAL_TYPE_UINT8, 1, &dsize,
+                         NULL, 0, -1, NULL, NULL, NULL);
+  free(bintile->array);
+  free(bintile->dsize);
+  bintile->block=p->binary;
+  bintile->ndim=p->binary->ndim;
+
+
+  /* Go over all the tiles given to this thread. */
+  for(i=0; tprm->indexs[i] != GAL_THREADS_NON_THRD_INDEX; ++i)
+    {
+      /* Basic definitions */
+      numsky=0;
+      tind = tprm->indexs[i];
+      tile = &p->cp.tl.tiles[tind];
+
+      /* Correct the fake binary tile's properties to be the same as this
+         one, then count the number of zero valued elements in it. */
+      bintile->size=tile->size;
+      bintile->dsize=tile->dsize;
+      bintile->array=gal_tile_block_relative_to_other(tile, p->binary);
+      GAL_TILE_PARSE_OPERATE({if(!*i) numsky++;}, bintile, NULL, 0, 0);
+
+      /* Only continue, if the fraction of Sky values are less than the
+         requested fraction. */
+      if( (float)(numsky)/(float)(tile->size) > p->minbfrac)
+        {
+          /* Calculate the mean and STD over this tile. */
+          s=s2=0.0f;
+          GAL_TILE_PARSE_OPERATE({ if(!*o) {s += *i; s2 += *i * *i;} },
+                                 tile, bintile, 1, 1);
+          darr[0]=s/numsky;
+          darr[1]=sqrt( (s2-s*s/numsky)/numsky );
+
+          /* Convert the mean and std into the same type as the sky and std
+             arrays. */
+          meanstd=gal_data_copy_to_new_type(meanstd_d, type);
+
+          /* Copy the mean and STD to their respective places in the tile
+             arrays. */
+          memcpy(gal_data_ptr_increment(p->sky->array, tind, type),
+                 meanstd->array, gal_type_sizeof(type));
+          memcpy(gal_data_ptr_increment(p->std->array, tind, type),
+                 gal_data_ptr_increment(meanstd->array, 1, type),
+                 gal_type_sizeof(type));
+        }
+      else
+        {
+          gal_blank_write(gal_data_ptr_increment(p->sky->array, tind, type),
+                          type);
+          gal_blank_write(gal_data_ptr_increment(p->std->array, tind, type),
+                          type);
+        }
+    }
+
+  /* Clean up and wait for other threads to finish and abort. */
+  bintile->array=NULL;
+  bintile->dsize=NULL;
+  gal_data_free(bintile);
+  gal_data_free(meanstd_d);
+  if(tprm->b) pthread_barrier_wait(tprm->b);
+  return NULL;
+}
+
+
+
+
+
+void
+threshold_sky_and_std(struct noisechiselparams *p)
+{
+  struct gal_options_common_params *cp=&p->cp;
+  struct gal_tile_two_layer_params *tl=&cp->tl;
+
+
+  /* When the check image has the same resolution as the input, write the
+     binary array as a reference to help in the comparison. */
+  if(p->detskyname && !tl->oneelempertile)
+    gal_fits_img_write(p->binary, p->detskyname, NULL, PROGRAM_STRING);
+
+
+  /* Allocate space for the mean and standard deviation. */
+  p->sky=gal_data_alloc(NULL, p->input->type, p->input->ndim, tl->numtiles,
+                        NULL, 0, cp->minmapsize, "SKY", p->input->unit, NULL);
+  p->std=gal_data_alloc(NULL, p->input->type, p->input->ndim, tl->numtiles,
+                        NULL, 0, cp->minmapsize, "STD", p->input->unit, NULL);
+
+
+  /* Find the Sky and its STD on proper tiles. */
+  gal_threads_spin_off(threshold_mean_std_undetected, p, tl->tottiles,
+                       cp->numthreads);
+  if(p->detskyname)
+    {
+      gal_tile_full_values_write(p->sky, tl, p->detskyname, PROGRAM_STRING);
+      gal_tile_full_values_write(p->std, tl, p->detskyname, PROGRAM_STRING);
+    }
+
+
+  /* Interpolate and smooth the derived values. */
+  threshold_interp_smooth(p, &p->sky, &p->std, p->detskyname);
+
+
+  /* If a check was requested, abort NoiseChisel. */
+  if(p->detskyname && !p->continueaftercheck)
+    ui_abort_after_check(p, p->detskyname, "showing derivation of Sky value"
+                         "and its standard deviation, or STD");
+}
diff --git a/bin/noisechisel/threshold.h b/bin/noisechisel/threshold.h
index 2ffaceb..9c9a1fb 100644
--- a/bin/noisechisel/threshold.h
+++ b/bin/noisechisel/threshold.h
@@ -25,7 +25,25 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 #define THRESHOLD_NO_ERODE_VALUE 2
 
+
+enum threshold_type
+  {
+    THRESHOLD_QUANTILES,
+    THRESHOLD_SKY_STD,
+  };
+
+
 void
 threshold_quantile_find_apply(struct noisechiselparams *p);
 
+
+void
+threshold_sky_and_std(struct noisechiselparams *p);
+
+
+void
+threshold_apply(struct noisechiselparams *p, float *value1, float *value2,
+                int type);
+
+
 #endif
diff --git a/bin/noisechisel/ui.c b/bin/noisechisel/ui.c
index 9f59689..7d8f413 100644
--- a/bin/noisechisel/ui.c
+++ b/bin/noisechisel/ui.c
@@ -33,10 +33,10 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/threads.h>
 #include <gnuastro/dimension.h>
 
-#include <timing.h>
-#include <options.h>
-#include <checkset.h>
-#include <fixedstringmacros.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/options.h>
+#include <gnuastro-internal/checkset.h>
+#include <gnuastro-internal/fixedstringmacros.h>
 
 #include "main.h"
 
@@ -523,7 +523,7 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
noisechiselparams *p)
      those headers which make them hard to read and modify. This also helps
      in having a clean environment: everything in those headers is only
      available within the scope of this function. */
-#include <commonopts.h>
+#include <gnuastro-internal/commonopts.h>
 #include "args.h"
 
 
diff --git a/bin/statistics/main.c b/bin/statistics/main.c
index eb3df66..1bf4f9a 100644
--- a/bin/statistics/main.c
+++ b/bin/statistics/main.c
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <timing.h>
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
diff --git a/bin/statistics/main.h b/bin/statistics/main.h
index 057541b..8761a9b 100644
--- a/bin/statistics/main.h
+++ b/bin/statistics/main.h
@@ -26,7 +26,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /* Include necessary headers */
 #include <gnuastro/data.h>
 
-#include <options.h>
+#include <gnuastro-internal/options.h>
 
 /* Progarm names.  */
 #define PROGRAM_NAME   "Statistics"    /* Program full name.       */
diff --git a/bin/statistics/sky.c b/bin/statistics/sky.c
index 0eb54c8..f4baed7 100644
--- a/bin/statistics/sky.c
+++ b/bin/statistics/sky.c
@@ -37,8 +37,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/statistics.h>
 #include <gnuastro/interpolate.h>
 
-#include <timing.h>
-#include <checkset.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/checkset.h>
 
 #include "main.h"
 
diff --git a/bin/statistics/statistics.c b/bin/statistics/statistics.c
index f1d0d48..8022a44 100644
--- a/bin/statistics/statistics.c
+++ b/bin/statistics/statistics.c
@@ -39,8 +39,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/interpolate.h>
 #include <gnuastro/permutation.h>
 
-#include <timing.h>
-#include <checkset.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/checkset.h>
 
 #include "main.h"
 
diff --git a/bin/statistics/ui.c b/bin/statistics/ui.c
index 7813f23..ca8a6f0 100644
--- a/bin/statistics/ui.c
+++ b/bin/statistics/ui.c
@@ -38,10 +38,10 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/linkedlist.h>
 #include <gnuastro/statistics.h>
 
-#include <timing.h>
-#include <options.h>
-#include <checkset.h>
-#include <fixedstringmacros.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/options.h>
+#include <gnuastro-internal/checkset.h>
+#include <gnuastro-internal/fixedstringmacros.h>
 
 #include "main.h"
 
@@ -892,7 +892,7 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
statisticsparams *p)
      those headers which make them hard to read and modify. This also helps
      in having a clean environment: everything in those headers is only
      available within the scope of this function. */
-#include <commonopts.h>
+#include <gnuastro-internal/commonopts.h>
 #include "args.h"
 
 
diff --git a/bin/table/main.c b/bin/table/main.c
index d896bbb..5c374ca 100644
--- a/bin/table/main.c
+++ b/bin/table/main.c
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <timing.h>             /* Includes time.h and sys/time.h */
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
diff --git a/bin/table/main.h b/bin/table/main.h
index b46c09d..9bbbf42 100644
--- a/bin/table/main.h
+++ b/bin/table/main.h
@@ -26,7 +26,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /* Include necessary headers */
 #include <gnuastro/data.h>
 
-#include <options.h>
+#include <gnuastro-internal/options.h>
 
 /* Progarm names.  */
 #define PROGRAM_NAME   "Table"         /* Program full name.       */
diff --git a/bin/table/ui.c b/bin/table/ui.c
index e859934..00c2167 100644
--- a/bin/table/ui.c
+++ b/bin/table/ui.c
@@ -31,10 +31,10 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/table.h>
 #include <gnuastro/linkedlist.h>
 
-#include <timing.h>
-#include <options.h>
-#include <checkset.h>
-#include <fixedstringmacros.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/options.h>
+#include <gnuastro-internal/checkset.h>
+#include <gnuastro-internal/fixedstringmacros.h>
 
 #include "main.h"
 
@@ -375,7 +375,7 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
tableparams *p)
      those headers which make them hard to read and modify. This also helps
      in having a clean environment: everything in those headers is only
      available within the scope of this function. */
-#include <commonopts.h>
+#include <gnuastro-internal/commonopts.h>
 #include "args.h"
 
 
diff --git a/bin/warp/main.c b/bin/warp/main.c
index c999657..ef9f260 100644
--- a/bin/warp/main.c
+++ b/bin/warp/main.c
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <timing.h>
+#include <gnuastro-internal/timing.h>
 
 #include "main.h"
 
diff --git a/bin/warp/main.h b/bin/warp/main.h
index ca224fd..2d8c75e 100644
--- a/bin/warp/main.h
+++ b/bin/warp/main.h
@@ -26,7 +26,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /* Include necessary headers */
 #include <gnuastro/data.h>
 
-#include <options.h>
+#include <gnuastro-internal/options.h>
 
 /* Progarm names.  */
 #define PROGRAM_NAME   "Warp"        /* Program full name.       */
diff --git a/bin/warp/ui.c b/bin/warp/ui.c
index eadef37..7904a88 100644
--- a/bin/warp/ui.c
+++ b/bin/warp/ui.c
@@ -34,10 +34,10 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/threads.h>
 #include <gnuastro/linkedlist.h>
 
-#include <timing.h>
-#include <options.h>
-#include <checkset.h>
-#include <fixedstringmacros.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/options.h>
+#include <gnuastro-internal/checkset.h>
+#include <gnuastro-internal/fixedstringmacros.h>
 
 #include "main.h"
 
@@ -906,7 +906,7 @@ ui_read_check_inputs_setup(int argc, char *argv[], struct 
warpparams *p)
      those headers which make them hard to read and modify. This also helps
      in having a clean environment: everything in those headers is only
      available within the scope of this function. */
-#include <commonopts.h>
+#include <gnuastro-internal/commonopts.h>
 #include "args.h"
 
 
diff --git a/doc/Makefile.am b/doc/Makefile.am
index f764c77..90f54fb 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -144,7 +144,7 @@ endif
 # it. Unfortunately as far as I know, pattern rules are not portable in all
 # implementations of Make, so we have to list all the utilities manually.
 toputildir=$(top_builddir)/bin
-ALLMANSDEP = $(top_srcdir)/lib/commonopts.h
+ALLMANSDEP = $(top_srcdir)/lib/gnuastro-internal/options.h
 man/astarithmetic.1: $(top_srcdir)/bin/arithmetic/args.h  $(ALLMANSDEP)
        $(MAYBE_HELP2MAN) -n "arithmetic operations on images and numbers" \
                          --libtool $(toputildir)/arithmetic/astarithmetic
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 222d6c6..93c5d0b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -85,9 +85,12 @@ pkginclude_HEADERS = gnuastro/config.h 
$(headersdir)/arithmetic.h        \
 # and if they are not explicitly mentioned somewhere in the Makefile, they
 # will not distributed, so we need to explicitly tell Automake to
 # distribute them here.
-EXTRA_DIST = $(headersdir)/README gnuastro.pc.in arithmetic-binary.h    \
-  arithmetic-onlyint.h arithmetic-other.h config.h.in checkset.h        \
-  fixedstringmacros.h options.h timing.h
+internaldir=$(top_srcdir)/lib/gnuastro-internal
+EXTRA_DIST = gnuastro.pc.in $(headersdir)/README                        \
+  $(internaldir)/arithmetic-binary.h $(internaldir)/arithmetic-onlyint.h \
+  $(internaldir)/arithmetic-other.h $(internaldir)/config.h.in          \
+  $(internaldir)/checkset.h $(internaldir)/fixedstringmacros.h          \
+  $(internaldir)/options.h $(internaldir)/timing.h
 
 
 
@@ -105,7 +108,7 @@ CLEANFILES = gnuastro.pc gnuastro/config.h
 
 # Build `gnuastro/config.h' based on the information in the Makefile after
 # the Makefile has been built.
-gnuastro/config.h: Makefile config.h.in
+gnuastro/config.h: Makefile $(internaldir)/config.h.in
        rm -f $@ address@hidden
        $(MKDIR_P) gnuastro
        $(SED) -e 's|@address@hidden|$(VERSION)|g'                            \
@@ -123,7 +126,7 @@ gnuastro/config.h: Makefile config.h.in
               -e 's|@address@hidden|$(HAVE_BIN_OP_FLOAT32)|g'    \
               -e 's|@address@hidden|$(HAVE_BIN_OP_FLOAT64)|g'    \
               -e 's|@address@hidden|$(SIZEOF_SIZE_T)|g'                \
-               $(srcdir)/config.h.in >> address@hidden
+               $(internaldir)/config.h.in >> address@hidden
        chmod a-w address@hidden
        mv address@hidden $@
 
diff --git a/lib/arithmetic-onlyint.c b/lib/arithmetic-onlyint.c
index 0437866..028385f 100644
--- a/lib/arithmetic-onlyint.c
+++ b/lib/arithmetic-onlyint.c
@@ -29,7 +29,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 #include <gnuastro/arithmetic.h>
 
-#include <arithmetic-onlyint.h>
+#include <gnuastro-internal/arithmetic-onlyint.h>
 
 
 
diff --git a/lib/arithmetic.c b/lib/arithmetic.c
index 112076b..f1b92c6 100644
--- a/lib/arithmetic.c
+++ b/lib/arithmetic.c
@@ -33,8 +33,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/statistics.h>
 #include <gnuastro/arithmetic.h>
 
-#include <arithmetic-binary.h>
-#include <arithmetic-onlyint.h>
+#include <gnuastro-internal/arithmetic-binary.h>
+#include <gnuastro-internal/arithmetic-onlyint.h>
 
 
 
diff --git a/lib/binary.c b/lib/binary.c
index 263e2ec..faac02f 100644
--- a/lib/binary.c
+++ b/lib/binary.c
@@ -439,3 +439,35 @@ gal_binary_connected_components(gal_data_t *binary, 
gal_data_t **out,
   free(dinc);
   return curlab-1;
 }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************/
+/*****************            Fill holes          ********************/
+/*********************************************************************/
+void
+gal_binary_fill_holes(gal_data_t *input)
+{
+  /* A small sanity check. */
+  if( input->type != GAL_TYPE_UINT8 )
+    error(EXIT_FAILURE, 0, "input to `gal_binary_fill_holes' must have "
+          "`uint8' type, but its input dataset has `%s' type",
+          gal_type_to_string(input->type, 1));
+}
diff --git a/lib/blank.c b/lib/blank.c
index b675ac9..ee6351a 100644
--- a/lib/blank.c
+++ b/lib/blank.c
@@ -32,7 +32,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/tile.h>
 #include <gnuastro/blank.h>
 
-#include <checkset.h>
+#include <gnuastro-internal/checkset.h>
 
 
 
diff --git a/lib/checkset.c b/lib/checkset.c
index 8ceec6b..24de5aa 100644
--- a/lib/checkset.c
+++ b/lib/checkset.c
@@ -34,7 +34,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 #include <gnuastro/data.h>
 
-#include "checkset.h"
+#include <gnuastro-internal/checkset.h>
 
 
 
diff --git a/lib/config.h.in b/lib/config.h.in
deleted file mode 100644
index 0a094c9..0000000
--- a/lib/config.h.in
+++ /dev/null
@@ -1,78 +0,0 @@
-/*********************************************************************
-Functions dealing with general aspects of all Gnuastro.
-
-Original author:
-     Mohammad Akhlaghi <address@hidden>
-Contributing author(s):
-Copyright (C) 2016, Free Software Foundation, Inc.
-
-Gnuastro is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation, either version 3 of the License, or (at your
-option) any later version.
-
-Gnuastro is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
-**********************************************************************/
-#ifndef __GAL_CONFIG_H__
-#define __GAL_CONFIG_H__
-
-/* Include other headers if necessary here. Note that other header files
-   must be included before the C++ preparations below */
-
-
-
-/* Configuration macros: */
-
-#define GAL_CONFIG_VERSION              "@VERSION@"
-
-#define GAL_CONFIG_HAVE_LIBGIT2         @HAVE_LIBGIT2@
-
-#define GAL_CONFIG_HAVE_WCSLIB_VERSION  @HAVE_WCSLIB_VERSION@
-
-#define GAL_CONFIG_HAVE_PTHREAD_BARRIER @HAVE_PTHREAD_BARRIER@
-
-#define GAL_CONFIG_BIN_OP_UINT8         @HAVE_BIN_OP_UINT8@
-#define GAL_CONFIG_BIN_OP_INT8          @HAVE_BIN_OP_INT8@
-#define GAL_CONFIG_BIN_OP_UINT16        @HAVE_BIN_OP_UINT16@
-#define GAL_CONFIG_BIN_OP_INT16         @HAVE_BIN_OP_INT16@
-#define GAL_CONFIG_BIN_OP_UINT32        @HAVE_BIN_OP_UINT32@
-#define GAL_CONFIG_BIN_OP_INT32         @HAVE_BIN_OP_INT32@
-#define GAL_CONFIG_BIN_OP_UINT64        @HAVE_BIN_OP_UINT64@
-#define GAL_CONFIG_BIN_OP_INT64         @HAVE_BIN_OP_INT64@
-#define GAL_CONFIG_BIN_OP_FLOAT32       @HAVE_BIN_OP_FLOAT32@
-#define GAL_CONFIG_BIN_OP_FLOAT64       @HAVE_BIN_OP_FLOAT64@
-
-#define GAL_CONFIG_SIZEOF_SIZE_T        @SIZEOF_SIZE_T@
-
-
-/* C++ Preparations */
-#undef __BEGIN_C_DECLS
-#undef __END_C_DECLS
-#ifdef __cplusplus
-# define __BEGIN_C_DECLS extern "C" {
-# define __END_C_DECLS }
-#else
-# define __BEGIN_C_DECLS                /* empty */
-# define __END_C_DECLS                  /* empty */
-#endif
-/* End of C++ preparations */
-
-
-
-/* Actual header contants (the above were for the Pre-processor). */
-__BEGIN_C_DECLS  /* From C++ preparations */
-
-
-
-
-
-
-__END_C_DECLS    /* From C++ preparations */
-
-#endif           /* __GAL_CONFIG_H__ */
diff --git a/lib/convolve.c b/lib/convolve.c
index 8d53fc0..87e00f9 100644
--- a/lib/convolve.c
+++ b/lib/convolve.c
@@ -33,7 +33,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/convolve.h>
 #include <gnuastro/dimension.h>
 
-#include <checkset.h>
+#include <gnuastro-internal/checkset.h>
 
 
 
diff --git a/lib/data.c b/lib/data.c
index 4553f9a..59831bf 100644
--- a/lib/data.c
+++ b/lib/data.c
@@ -40,7 +40,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/table.h>
 #include <gnuastro/linkedlist.h>
 
-#include <checkset.h>
+#include <gnuastro-internal/checkset.h>
 
 
 
diff --git a/lib/fits.c b/lib/fits.c
index 3869a5b..a456b3f 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -39,8 +39,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/tile.h>
 #include <gnuastro/blank.h>
 
-#include "checkset.h"
-#include "fixedstringmacros.h"
+#include <gnuastro-internal/checkset.h>
+#include <gnuastro-internal/fixedstringmacros.h>
 
 
 
diff --git a/lib/gnuastro-internal/README b/lib/gnuastro-internal/README
new file mode 100644
index 0000000..d9c87b9
--- /dev/null
+++ b/lib/gnuastro-internal/README
@@ -0,0 +1,9 @@
+GNU Astronomy Utilities internal header files
+---------------------------------------------
+
+The `.h' files in this directory are headers to Gnuastro's internal
+libraries: libraries that are only available to Gnuastro's programs. These
+are functions that are mainly to do with running a program, for example the
+common options to all the programs, functions to manage options and
+configuration files, timing and etc (the names are hopefully descriptive
+enough).
\ No newline at end of file
diff --git a/lib/arithmetic-binary.h b/lib/gnuastro-internal/arithmetic-binary.h
similarity index 100%
rename from lib/arithmetic-binary.h
rename to lib/gnuastro-internal/arithmetic-binary.h
diff --git a/lib/arithmetic-onlyint.h 
b/lib/gnuastro-internal/arithmetic-onlyint.h
similarity index 100%
rename from lib/arithmetic-onlyint.h
rename to lib/gnuastro-internal/arithmetic-onlyint.h
diff --git a/lib/checkset.h b/lib/gnuastro-internal/checkset.h
similarity index 98%
rename from lib/checkset.h
rename to lib/gnuastro-internal/checkset.h
index ec45dfd..43a6ed6 100644
--- a/lib/checkset.h
+++ b/lib/gnuastro-internal/checkset.h
@@ -27,7 +27,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
    must be included before the C++ preparations below */
 #include <math.h>
 #include <fitsio.h>
-#include <options.h>
+#include <gnuastro-internal/options.h>
 
 /* C++ Preparations */
 #undef __BEGIN_C_DECLS
diff --git a/lib/commonopts.h b/lib/gnuastro-internal/commonopts.h
similarity index 100%
rename from lib/commonopts.h
rename to lib/gnuastro-internal/commonopts.h
diff --git a/lib/fixedstringmacros.h b/lib/gnuastro-internal/fixedstringmacros.h
similarity index 100%
rename from lib/fixedstringmacros.h
rename to lib/gnuastro-internal/fixedstringmacros.h
diff --git a/lib/options.h b/lib/gnuastro-internal/options.h
similarity index 100%
rename from lib/options.h
rename to lib/gnuastro-internal/options.h
diff --git a/lib/timing.h b/lib/gnuastro-internal/timing.h
similarity index 100%
rename from lib/timing.h
rename to lib/gnuastro-internal/timing.h
diff --git a/lib/gnuastro/binary.h b/lib/gnuastro/binary.h
index f5e24d8..b06cb5e 100644
--- a/lib/gnuastro/binary.h
+++ b/lib/gnuastro/binary.h
@@ -93,6 +93,12 @@ gal_binary_connected_components(gal_data_t *binary, 
gal_data_t **out,
 
 
 
+/*********************************************************************/
+/*****************            Fill holes          ********************/
+/*********************************************************************/
+void
+gal_binary_fill_holes(gal_data_t *input);
+
 
 
 __END_C_DECLS    /* From C++ preparations */
diff --git a/lib/gnuastro/tile.h b/lib/gnuastro/tile.h
index 1db7e26..9b5c829 100644
--- a/lib/gnuastro/tile.h
+++ b/lib/gnuastro/tile.h
@@ -300,6 +300,55 @@ gal_tile_full_free_contents(struct 
gal_tile_two_layer_params *tl);
       `b': blank value in input't type.
 
    See `lib/statistics.c' for some example applications of this function.
+
+  -----------
+  TIPS/TRICKS
+  -----------
+
+  You can use a given tile on a dataset that it was not initialized with
+  (but has the same size). You can do that like this:
+
+     void *tarray;
+     gal_data_t *tblock;
+
+     tarray=tile->array;
+     tblock=tile->block;
+     tile->array=gal_tile_block_relative_to_other(tile, THE_OTHER_DATASET);
+     tile->block=THE_OTHER_DATASET;  <<-- `tile->block' must corrected
+                                          AFTER `tile->array'.
+     GAL_TILE_PARSE_OPERATE(...)
+
+     tile->array=tarray;
+     tile->block=tblock;
+
+  You can work on one other array while working on the one that tile
+  actually points to. To do that, you can make a fake tile and pass that as
+  the `OUT' argument to this macro. While the name is `OUT' it can be used
+  in any manner you like. To do this, you can take the following steps. In
+  this example, `tile' is the actual tile that you have.
+
+     gal_data_t *faketile;
+
+     // These can be done outside a loop.
+     faketile=gal_data_alloc(NULL, OTHER_DATASET->type, 1, &dsize,
+                            NULL, 0, -1, NULL, NULL, NULL);
+     free(faketile->array);
+     free(faketile->dsize);
+     faketile->block=OTHER_DATASET;
+     faketile->ndim=OTHER_DATASET->ndim;
+
+     // These can be done in the loop over tiles.
+     faketile->size=tile->size;
+     faketile->dsize=tile->dsize;
+     faketile->array=gal_tile_block_relative_to_other(tile, OTHER_DATASET);
+
+     // Do your processing....
+     GAL_TILE_PARSE_OPERATE(PROCESSING, tile, faketile, 1, 1);
+
+     // Clean up.
+     bintile->array=NULL;
+     bintile->dsize=NULL;
+     gal_data_free(bintile);
 */
 #define GAL_TILE_PARSE_OPERATE(OP, IN, OUT, PARSE_OUT, CHECK_BLANK) {   \
     int parse_out=(OUT && PARSE_OUT);                                   \
diff --git a/lib/interpolate.c b/lib/interpolate.c
index 8323ff9..eba3fbd 100644
--- a/lib/interpolate.c
+++ b/lib/interpolate.c
@@ -37,7 +37,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/interpolate.h>
 #include <gnuastro/permutation.h>
 
-#include <checkset.h>
+#include <gnuastro-internal/checkset.h>
 
 
 
diff --git a/lib/linkedlist.c b/lib/linkedlist.c
index 30193fe..cdba40a 100644
--- a/lib/linkedlist.c
+++ b/lib/linkedlist.c
@@ -30,7 +30,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 #include <gnuastro/linkedlist.h>
 
-#include <checkset.h>
+#include <gnuastro-internal/checkset.h>
 
 
 
diff --git a/lib/options.c b/lib/options.c
index 8e634ec..84db9d8 100644
--- a/lib/options.c
+++ b/lib/options.c
@@ -35,9 +35,9 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/arithmetic.h>
 #include <gnuastro/linkedlist.h>
 
-#include <timing.h>
-#include <options.h>
-#include <checkset.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/options.h>
+#include <gnuastro-internal/checkset.h>
 
 
 
diff --git a/lib/statistics.c b/lib/statistics.c
index a7f1acf..33f6996 100644
--- a/lib/statistics.c
+++ b/lib/statistics.c
@@ -38,7 +38,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/arithmetic.h>
 #include <gnuastro/statistics.h>
 
-#include <checkset.h>
+#include <gnuastro-internal/checkset.h>
 
 
 
diff --git a/lib/table.c b/lib/table.c
index 6ca7f29..a862a1a 100644
--- a/lib/table.c
+++ b/lib/table.c
@@ -34,8 +34,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/blank.h>
 #include <gnuastro/table.h>
 
-#include <timing.h>
-#include <checkset.h>
+#include <gnuastro-internal/timing.h>
+#include <gnuastro-internal/checkset.h>
 
 
 
diff --git a/lib/tile.c b/lib/tile.c
index d4671a9..4fe885d 100644
--- a/lib/tile.c
+++ b/lib/tile.c
@@ -37,7 +37,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/interpolate.h>
 #include <gnuastro/permutation.h>
 
-#include "checkset.h"
+#include <gnuastro-internal/checkset.h>
 
 
 
diff --git a/lib/timing.c b/lib/timing.c
index 970461e..98f1228 100644
--- a/lib/timing.c
+++ b/lib/timing.c
@@ -25,7 +25,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <stdint.h>
 
-#include "timing.h"
+#include <gnuastro-internal/timing.h>
 
 
 
diff --git a/lib/txt.c b/lib/txt.c
index 3d50116..8d4df11 100644
--- a/lib/txt.c
+++ b/lib/txt.c
@@ -34,7 +34,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <gnuastro/blank.h>
 #include <gnuastro/table.h>
 
-#include <checkset.h>
+#include <gnuastro-internal/checkset.h>
 
 
 
diff --git a/tmpfs-config-make b/tmpfs-config-make
index 09ab2df..0eacca9 100755
--- a/tmpfs-config-make
+++ b/tmpfs-config-make
@@ -134,7 +134,8 @@ if [ ! -f Makefile ]; then
                  --enable-arithmetic --enable-convertt   --enable-convolve    \
                  --enable-cosmiccal  --enable-crop       --enable-fits        \
                  --enable-mknoise    --enable-mkprof     --enable-noisechisel \
-                 --enable-statistics --enable-table      --enable-warp
+                 --enable-statistics --enable-table      --enable-warp        \
+                 CFLAGS="-g -O0" --disable-shared
 fi
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]