gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 07ebe9a7: psf-stamp: mask the extra objects af


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 07ebe9a7: psf-stamp: mask the extra objects after applying the threshold
Date: Wed, 16 Aug 2023 10:29:16 -0400 (EDT)

branch: master
commit 07ebe9a703b592a08f185be0b155c6930a348681
Author: Sepideh Eskandarlou <sepideh.eskandarlou@gmail.com>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    psf-stamp: mask the extra objects after applying the threshold
    
    Until now, for masking the extra objects, first of all we masked the
    objects (OBJECTS of segment output) that have different values with the
    main object. Then in the object of the main star we just kept clumps
    (CLUMPS of the segment output) of the main star and then masked the other
    clumps. But when the user requested a S/N threshold some pixels with high
    value were not masked.
    
    With this commit, after applying the threshold we masked the extra regions
    that remain and do not touch the main star.
---
 NEWS                    | 12 ++++++++++--
 bin/script/psf-stamp.sh | 25 ++++++++++++++++++++++---
 doc/gnuastro.texi       |  3 +++
 3 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS
index 9be4bb3e..25da8461 100644
--- a/NEWS
+++ b/NEWS
@@ -74,8 +74,8 @@ See the end of the file for license conditions.
 
   astscript-zeropoint:
   --mksrc: use a custom Makefile for estimating the zeropoint, not the
-  default installed Makefile. This is primarily intended for debugging or
-  developing this script, not for normal usage.
+    default installed Makefile. This is primarily intended for debugging or
+    developing this script, not for normal usage.
 
   Library:
   - gal_blank_not_minmax_coords: returns the minimum/maximum coordinates of
@@ -141,6 +141,14 @@ See the end of the file for license conditions.
     value is given to '--sky' it will be subtracted from the input in the
     first extension). Implemented by Sepideh Eskandarlou.
 
+  astscript-psf-stamp:
+  - After applying the signal-to-noise threshold (if it is requested), any
+    extra pixels that are not connected to the central target are also
+    masked. Such pixels can remain in rivers between bright clumps and
+    would cause problem in the final stack and were not removed until now.
+    Implemented by Sepideh Eskandarlou
+
+
 ** Bugs fixed
   bug #64138: Arithmetic's mknoise-poisson only using first pixel value.
               Reported by Irene Pintos Castro.
diff --git a/bin/script/psf-stamp.sh b/bin/script/psf-stamp.sh
index 5d7beec6..388a369d 100644
--- a/bin/script/psf-stamp.sh
+++ b/bin/script/psf-stamp.sh
@@ -656,12 +656,19 @@ EOF
                       1 dilate set-cmask \
                       o o $olab eq 0 where set-omask \
                       i omask cmask or nan where
+
     fi
 
-    # Apply the signal-to-noise threshold if the user provided one.
+    # Apply the signal-to-noise threshold if the user provided one, and
+    # only keep the central object.
     if [ x"$snthresh" != x ]; then
+
+        # Mask all the pixels that are below the threshold based on the
+        # signal to noise value which is obtained form the SKY_STD. Finally
+        # label the separate regions.
        cropsnt=$tmpdir/cropped-snt-$objectid.fits
        cropstd=$tmpdir/cropped-std-$objectid.fits
+        croplab=$tmpdir/cropped-lab-$objectid.fits
        astcrop $segment --hdu=SKY_STD --mode=img \
                 --center=$xcenter,$ycenter \
                 --width=$xwidthinpix,$ywidthinpix \
@@ -670,8 +677,20 @@ EOF
                      $cropstd -h1        set-s \
                      v s /               set-sn \
                      v sn $snthresh lt \
-                     2 dilate nan where -o$cropsnt
-       mv $cropsnt $cropped_masked
+                     2 dilate nan where set-all \
+                      all tofilefree-$cropsnt \
+                      all isnotblank 2 connected-components \
+                      --output=$croplab
+
+        # Extract the id of the main object.
+        id=$(astcrop $croplab -h1 --mode=wcs \
+                     --center=$xcoord,$ycoord \
+                     --widthinpix --width=1 --oneelemstdout -q)
+
+        # Mask all the pixels that does not belong to the main object.
+        msk=$tmpdir/mask-$objectid.fits
+        astarithmetic $cropsnt $croplab $id ne nan where -g1 --output=$msk
+       mv $msk $cropped_masked
     fi
 
 else
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 23828ac1..95ab25dd 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -33085,6 +33085,9 @@ This option is only valid with the @option{--segment} 
option (it will use the @c
 This threshold is applied prior to the possible normalization or centering of 
the stamp.
 After all pixels below the given threshold are masked, the mask is also 
dilated by one level to avoid single pixels above the threshold (which are 
mainly due to noise when the threshold is lower).
 
+After applying the signal-to-noise threshold (if it is requested), any extra 
pixels that are not connected to the central target are also masked.
+Such pixels can remain in rivers between bright clumps and will cause problem 
in the final stack, if they are not masked.
+
 This is useful for increasing the S/N of inner parts of each region of the 
finally stacked PSF.
 As the stars (that are to be stacked) become fainter, the S/N of their outer 
parts (at a fixed radius) decreases.
 The stack of a higher-S/N image with a lower-S/N image will have an S/N that 
is lower than the higher one.



reply via email to

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