[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 6bdc5d6 030/113: Oversegmentation connectivity
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 6bdc5d6 030/113: Oversegmentation connectivity one less for 3D |
Date: |
Fri, 16 Apr 2021 10:33:37 -0400 (EDT) |
branch: master
commit 6bdc5d681d7efddb01fcca9d2f23d809d0d4b26f
Author: Mohammad Akhlaghi <akhlaghi@gnu.org>
Commit: Mohammad Akhlaghi <akhlaghi@gnu.org>
Oversegmentation connectivity one less for 3D
In 2D, when looking at the neighbors, we use the dimensionality for
connectivity (or 8-connected neighbors). In 2D this makes 4-connected
rivers (more pixels as rivers). This is fine in 2D, but in 3D, it can mean
a circumference in each slice. So through this change, we are making the 3D
rivers slightly thinner. This apparently gives better 3D clump results.
In the process of inspecting the clumps, I noticed that in
`clumps_get_raw_info' we are not finding/using the 3rd dimension
information and un-initialized values were being used instead. Now it finds
the clump center in 3D and uses the three values to find the tile to return
the standard deviation.
I also noticed that in `clumps_true_find_sn_thresh', we have to use
`GAL_TYPE_INT32' directly instead of relying on `clprm.snind->type'. This
is because of a recent correction in `clumps_make_sn_table' where we stop
continuing when `cltprm->numinitclumps==0' (so `clprm.snind->type' was not
initialized).
---
bin/noisechisel/clumps.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/bin/noisechisel/clumps.c b/bin/noisechisel/clumps.c
index 5f5fdb9..03df913 100644
--- a/bin/noisechisel/clumps.c
+++ b/bin/noisechisel/clumps.c
@@ -72,6 +72,7 @@ clumps_oversegment(struct clumps_thread_params *cltprm)
float *arr=p->conv->array;
gal_data_t *indexs=cltprm->indexs;
+ int connectivity=ndim==2?ndim:ndim-1;
gal_list_sizet_t *Q=NULL, *cleanup=NULL;
size_t *a, *af, ind, *dsize=p->input->dsize;
size_t *dinc=gal_dimension_increment(ndim, dsize);
@@ -169,7 +170,8 @@ clumps_oversegment(struct clumps_thread_params *cltprm)
/* Look at the neighbors and see if we already have a
label. */
- GAL_DIMENSION_NEIGHBOR_OP(ind, ndim, dsize, ndim, dinc,
+ GAL_DIMENSION_NEIGHBOR_OP(ind, ndim, dsize, connectivity,
+ dinc,
{
/* If it is already decided to be a river, then stop
looking at the neighbors. */
@@ -271,7 +273,7 @@ clumps_oversegment(struct clumps_thread_params *cltprm)
neighboured by more than one label, set it as a river
pixel. Also if it is touching a zero valued pixel (which
does not belong to this object), set it as a river pixel.*/
- GAL_DIMENSION_NEIGHBOR_OP(*a, ndim, dsize, ndim, dinc,
+ GAL_DIMENSION_NEIGHBOR_OP(*a, ndim, dsize, connectivity, dinc,
{
/* When `n1' has already been set as a river, there is no
point in looking at the other neighbors. */
@@ -674,6 +676,7 @@ enum infocols
{
INFO_X, /* Flux weighted X center col, 0 by C std. */
INFO_Y, /* Flux weighted Y center col. */
+ INFO_Z, /* Flux weighted Z center col. */
INFO_NFF, /* Number of non-negative pixels (for X,Y).*/
INFO_INFLUX, /* Tatal flux within clump. */
INFO_INAREA, /* Tatal area within clump. */
@@ -689,8 +692,8 @@ clumps_get_raw_info(struct clumps_thread_params *cltprm)
struct noisechiselparams *p=cltprm->clprm->p;
size_t ndim=p->input->ndim, *dsize=p->input->dsize;
- size_t i, *a, *af, ii, coord[2];
double *row, *info=cltprm->info->array;
+ size_t i, *a, *af, ii, fullid, coord[3];
size_t nngb=gal_dimension_num_neighbors(ndim);
float *arr=p->input->array, *std=p->std->array;
size_t *dinc=gal_dimension_increment(ndim, dsize);
@@ -712,9 +715,12 @@ clumps_get_raw_info(struct clumps_thread_params *cltprm)
info[ lab * INFO_NCOLS + INFO_INFLUX ] += arr[*a];
if( arr[*a]>0.0f )
{
+ gal_dimension_index_to_coord(*a, ndim, dsize, coord);
info[ lab * INFO_NCOLS + INFO_NFF ] += arr[*a];
- info[ lab * INFO_NCOLS + INFO_X ] += arr[*a] * (*a/dsize[1]);
- info[ lab * INFO_NCOLS + INFO_Y ] += arr[*a] * (*a%dsize[1]);
+ info[ lab * INFO_NCOLS + INFO_X ] += arr[*a] * coord[0];
+ info[ lab * INFO_NCOLS + INFO_Y ] += arr[*a] * coord[1];
+ if(ndim==3)
+ info[ lab * INFO_NCOLS + INFO_Z ] += arr[*a] * coord[2];
}
}
@@ -775,10 +781,16 @@ clumps_get_raw_info(struct clumps_thread_params *cltprm)
if( row[INFO_NFF]==0.0f ) row[INFO_INAREA]=0;
else
{
+ /* Find the coordinates of the clump's weighted center. */
coord[0]=GAL_DIMENSION_FLT_TO_INT(row[INFO_X]/row[INFO_NFF]);
coord[1]=GAL_DIMENSION_FLT_TO_INT(row[INFO_Y]/row[INFO_NFF]);
- row[INFO_INSTD] = std[ gal_tile_full_id_from_coord(&p->cp.tl,
- coord) ];
+ if(ndim==3)
+ coord[2]=GAL_DIMENSION_FLT_TO_INT(row[INFO_Z]/row[INFO_NFF]);
+
+ /* Find the corresponding standard deviation. */
+ fullid=gal_tile_full_id_from_coord(&p->cp.tl, coord);
+ row[INFO_INSTD] = std[fullid];
+
/* For a check
printf("---------\n");
printf("\t%f --> %zu\n", row[INFO_Y]/row[INFO_NFF], coord[1]);
@@ -1311,7 +1323,7 @@ clumps_true_find_sn_thresh(struct noisechiselparams *p)
p->cp.minmapsize, "CLUMP_S/N", "ratio",
"Signal-to-noise ratio");
snind = ( p->checkclumpsn
- ? gal_data_alloc(NULL, clprm.snind->type, 1, &numsn, NULL, 0,
+ ? gal_data_alloc(NULL, GAL_TYPE_INT32, 1, &numsn, NULL, 0,
p->cp.minmapsize, "CLUMP_ID", "counter",
"Unique ID for this clump.")
: NULL );
- [gnuastro-commits] master d14384a 007/113: Minor corrections in MakeProfiles manual, (continued)
- [gnuastro-commits] master d14384a 007/113: Minor corrections in MakeProfiles manual, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 5abb468 008/113: Other minor corrections in the documentation, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 3e76e1f 010/113: MakeProfiles --kernel builds 3D kernels also, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 81f3f65 023/113: More --coordcol options acceptable in Crop, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master e47f8db 024/113: Merged recent work in master, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 8fa5ff1 026/113: Minor edit in book (part added in last commit), Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 40f0a56 013/113: Minor corrections to MakeProfiles continued, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 8372486 020/113: NoiseChisel's detection complete in 3D, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 6cc3d25 027/113: No 3D projections in function to inspect NoiseChisel outputs, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master e990860 029/113: Merged recent updates in master, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 6bdc5d6 030/113: Oversegmentation connectivity one less for 3D,
Mohammad Akhlaghi <=
- [gnuastro-commits] master be3bfd8 033/113: NoiseChisel configuration file in 3D updated, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 3b6c15d 036/113: Merged with recent work in master, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master fb3660f 037/113: MakeCatalog works in 3D, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 73fdf0c 006/113: MakeProfiles builds 3D ellipsoids, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 03d73fe 011/113: Some minor corrections in code and comments, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 87ab805 014/113: Identifiers for integer constants in BZERO comparisons, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 1483201 009/113: Noised cube created in make check, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master bdeaba9 012/113: Corrected name of 3D catalog for tarball inclusion, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 6b53c5e 015/113: Bug fixes in master: commits 1ff1c25 and 540af65, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master adeb1c6 016/113: NoiseChisel's convolution step in 3D completed, Mohammad Akhlaghi, 2021/04/16