gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 4627ddf 021/113: NoiseChisel segmentation work


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 4627ddf 021/113: NoiseChisel segmentation working in 3D, test added
Date: Fri, 16 Apr 2021 10:33:34 -0400 (EDT)

branch: master
commit 4627ddf04fc2da50faca89faba53ddd45585e6e3
Author: Mohammad Akhlaghi <akhlaghi@gnu.org>
Commit: Mohammad Akhlaghi <akhlaghi@gnu.org>

    NoiseChisel segmentation working in 3D, test added
    
    NoiseChisel's segmentation is now also working in 3D. Only a small
    correction was necessary in classifying the edges of the tiles. Also, a
    test was written to run NoiseChisel fully on a noised image created by
    MakeNoise's test.
---
 bin/noisechisel/clumps.c            | 22 +++++++++++-----
 bin/noisechisel/noisechisel.c       |  8 ------
 tests/Makefile.am                   |  4 ++-
 tests/noisechisel/noisechisel-3d.sh | 52 +++++++++++++++++++++++++++++++++++++
 4 files changed, 70 insertions(+), 16 deletions(-)

diff --git a/bin/noisechisel/clumps.c b/bin/noisechisel/clumps.c
index 459b212..dd560f7 100644
--- a/bin/noisechisel/clumps.c
+++ b/bin/noisechisel/clumps.c
@@ -987,10 +987,11 @@ clumps_find_make_sn_table(void *in_prm)
 
   void *tarray;
   double numdet;
+  int pixonedge;
   gal_data_t *tile, *tblock, *tmp;
   uint8_t *binary=p->binary->array;
   struct clumps_thread_params cltprm;
-  size_t i, c, ind, tind, num, numsky, *indarr;
+  size_t i, j, c, ind, tind, num, numsky, *indarr;
   size_t *scoord=gal_data_malloc_array(GAL_TYPE_SIZE_T, ndim, __func__,
                                        "scoord");
   size_t *icoord=gal_data_malloc_array(GAL_TYPE_SIZE_T, ndim, __func__,
@@ -1080,12 +1081,19 @@ clumps_find_make_sn_table(void *in_prm)
               ind = (int32_t *)i - (int32_t *)(p->clabel->array);
               gal_dimension_index_to_coord(ind, ndim, dsize, icoord);
 
-              /* If the pixel is on the tile edge, set it as river and
-                 don't include it in the indexs. */
-              if( icoord[0]==scoord[0]
-                  || icoord[0]==scoord[0]+tile->dsize[0]-1
-                  || icoord[1]==scoord[1]
-                  || icoord[1]==scoord[1]+tile->dsize[1]-1 )
+              /* Check if the pixel is on the tile edge. */
+              pixonedge=0;
+              for(j=0;j<ndim;++j)
+                if( icoord[j]==scoord[j]
+                    || icoord[j]==scoord[j]+tile->dsize[j]-1 )
+                  {
+                    pixonedge=1;
+                    break;
+                  }
+
+              /* If this pixel is on the edge, then it should be a
+                 river. */
+              if(pixonedge)
                 *(int32_t *)i=CLUMPS_RIVER;
 
               /* This pixel is not on the edge, check if it had a value of
diff --git a/bin/noisechisel/noisechisel.c b/bin/noisechisel/noisechisel.c
index 71b808c..e73850b 100644
--- a/bin/noisechisel/noisechisel.c
+++ b/bin/noisechisel/noisechisel.c
@@ -289,14 +289,6 @@ noisechisel(struct noisechiselparams *p)
      images. */
   noisechisel_find_sky_subtract(p);
 
-  /***********************************************/
-  if(p->conv->ndim==3)
-    {
-      printf("\n... end of %s ...\n", __func__);
-      exit(0);
-    }
-  /***********************************************/
-
   /* If the user only wanted detection, ignore the segmentation steps. */
   if(p->onlydetection==0)
     {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bf4e135..cca7d8a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -144,9 +144,11 @@ if COND_MKPROF
   mkprof/clearcanvas.sh: mknoise/addnoise.sh.log
 endif
 if COND_NOISECHISEL
-  MAYBE_NOISECHISEL_TESTS = noisechisel/noisechisel.sh
+  MAYBE_NOISECHISEL_TESTS = noisechisel/noisechisel.sh          \
+  noisechisel/noisechisel-3d.sh
 
   noisechisel/noisechisel.sh: mknoise/addnoise.sh.log
+  noisechisel/noisechisel-3d.sh: mknoise/addnoise-3d.sh.log
 endif
 if COND_STATISTICS
   MAYBE_STATISTICS_TESTS = statistics/basicstats.sh statistics/estimate_sky.sh
diff --git a/tests/noisechisel/noisechisel-3d.sh 
b/tests/noisechisel/noisechisel-3d.sh
new file mode 100755
index 0000000..a08ad5a
--- /dev/null
+++ b/tests/noisechisel/noisechisel-3d.sh
@@ -0,0 +1,52 @@
+# Detect objects and clumps in an image using NoiseChisel.
+#
+# See the Tests subsection of the manual for a complete explanation
+# (in the Installing gnuastro section).
+#
+# Original author:
+#     Mohammad Akhlaghi <akhlaghi@gnu.org>
+# Contributing author(s):
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.  This file is offered as-is,
+# without any warranty.
+
+
+
+
+
+# Preliminaries
+# =============
+#
+# Set the variables (The executable is in the build tree). Do the
+# basic checks to see if the executable is made or if the defaults
+# file exists (basicchecks.sh is in the source tree).
+prog=noisechisel
+img=3d-cat_noised.fits
+execname=../bin/$prog/ast$prog
+
+
+
+
+
+# Skip?
+# =====
+#
+# If the dependencies of the test don't exist, then skip it. There are two
+# types of dependencies:
+#
+#   - The executable was not made (for example due to a configure option),
+#
+#   - The input data was not made (for example the test that created the
+#     data file failed).
+if [ ! -f $execname ]; then echo "$execname not created."; exit 77; fi
+if [ ! -f $img      ]; then echo "$img does not exist.";    exit 77; fi
+
+
+
+
+
+# Actual test script
+# ==================
+$execname $img --config=.gnuastro/astnoisechisel-3d.conf



reply via email to

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