gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master f8525cc 2/2: NoiseChisel's issue with high gth


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master f8525cc 2/2: NoiseChisel's issue with high gthresh fixed
Date: Sat, 20 May 2017 23:44:26 -0400 (EDT)

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

    NoiseChisel's issue with high gthresh fixed
    
    When a high `--gthresh' value was given, NoiseChisel would free the space
    allocated to keep the diffuse fluxes. However, this space was necessary for
    later filling of the region. So now, it is no longer freed, but the size is
    set to zero. In this way, the adjacency matrix step is ignored, and we can
    directly jump to the final filling of the object.
---
 bin/noisechisel/clumps.c       | 11 -----------
 bin/noisechisel/segmentation.c | 36 ++++++++++++++++++++++++------------
 2 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/bin/noisechisel/clumps.c b/bin/noisechisel/clumps.c
index 03b076e..c16b9d0 100644
--- a/bin/noisechisel/clumps.c
+++ b/bin/noisechisel/clumps.c
@@ -475,17 +475,6 @@ clumps_grow_prepare_initial(struct clumps_thread_params 
*cltprm)
   while(++s<sf);
 
 
-  /* When a user just wants clumps and doesn't want multiple clumps to be
-     considered part of one object, they are going to set an impossibly
-     high `--gthresh', so no growth actually happens. In that case, we
-     don't need the allocated array of indexs. So just free it. */
-  if(ndiffuse==0)
-    {
-      free(cltprm->diffuseindexs->array);
-      cltprm->diffuseindexs->array=NULL;
-    }
-
-
   /* Correct the sizes of the `diffuseindexs' data structure. */
   cltprm->diffuseindexs->size = cltprm->diffuseindexs->dsize[0] = ndiffuse;
 }
diff --git a/bin/noisechisel/segmentation.c b/bin/noisechisel/segmentation.c
index 26db7be..855f3a3 100644
--- a/bin/noisechisel/segmentation.c
+++ b/bin/noisechisel/segmentation.c
@@ -100,13 +100,21 @@ segmentation_relab_to_objects(struct clumps_thread_params 
*cltprm)
   int32_t *ngblabs=gal_data_malloc_array(GAL_TYPE_UINT32, nngb, __func__,
                                          "ngblabs");
 
+  /* If there aren't any diffuse pixels (when a large `--gthresh' was
+     given), then it is just necessary to set two constants. */
+  if(cltprm->diffuseindexs->size==0)
+    {
+      cltprm->clumptoobj=NULL;
+      cltprm->numobjects=cltprm->numtrueclumps;
+      return;
+    }
 
-  /* Go over all the still-unlabeled pixels and see which labels they
-     touch. In the process, get the average value of the river-pixel values
-     and put them in the respective adjacency matrix. Note that at this
-     point, the rivers are also part of the "diffuse" regions. So we don't
-     need to go over all the indexs of this object, only its diffuse
-     indexs. */
+  /* Go over all the still-unlabeled pixels (if they exist) and see which
+     labels they touch. In the process, get the average value of the
+     river-pixel values and put them in the respective adjacency
+     matrix. Note that at this point, the rivers are also part of the
+     "diffuse" regions. So we don't need to go over all the indexs of this
+     object, only its diffuse indexs. */
   sf=(s=cltprm->diffuseindexs->array)+cltprm->diffuseindexs->size;
   do
     /* We only want to work on pixels that have already been identified as
@@ -454,8 +462,8 @@ segmentation_on_threads(void *in_prm)
             }
 
 
-          /* Identify the objects within the grown clumps and correct the
-             grown clump labels into new object labels. */
+          /* Identify the objects in this detection using the grown clumps
+             and correct the grown clump labels into new object labels. */
           segmentation_relab_to_objects(&cltprm);
           if(clprm->step==4)
             {
@@ -484,10 +492,11 @@ segmentation_on_threads(void *in_prm)
 
 
           /* Correct the clump labels. Note that this is only necessary
-             when there is more than object over the detection. When there
-             is only one object over the full detection or if there is only
-             one clump, the existing clump labels are fine.  */
-          if(cltprm.numobjects>1)
+             when there is more than object over the detection or when
+             there were multiple clumps, but no ID conversion was necessary
+             (very high `--gthresh' values). In the latter case,
+             `clumptoobj' will be NULL.*/
+          if(cltprm.numobjects>1 && cltprm.clumptoobj)
             segmentation_relab_clumps_in_objects(&cltprm);
           gal_data_free(cltprm.clumptoobj);
           if(clprm->step==6) {continue;}
@@ -812,6 +821,7 @@ segmentation(struct noisechiselparams *p)
                         1);
     }
 
+
   /* If a check segmentation image was requested, then put in the
      inputs. */
   if(p->segmentationname)
@@ -824,6 +834,7 @@ segmentation(struct noisechiselparams *p)
       p->olabel->name=NULL;
     }
 
+
   /* Allocate the clump labels image. */
   p->clabel=gal_data_alloc(NULL, p->olabel->type, p->olabel->ndim,
                            p->olabel->dsize, p->olabel->wcs, 1,
@@ -859,6 +870,7 @@ segmentation(struct noisechiselparams *p)
       free(msg);
     }
 
+
   /* If the user wanted to check the segmentation and hasn't called
      `continueaftercheck', then stop NoiseChisel. */
   if(p->segmentationname && !p->continueaftercheck)



reply via email to

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