[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 06798a5 035/113: Crop's --checkcenter works on
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 06798a5 035/113: Crop's --checkcenter works on 3D dataset |
Date: |
Fri, 16 Apr 2021 10:33:38 -0400 (EDT) |
branch: master
commit 06798a5d07e53555dd56387cdd5f6a557d32a7c2
Author: Mohammad Akhlaghi <akhlaghi@gnu.org>
Commit: Mohammad Akhlaghi <akhlaghi@gnu.org>
Crop's --checkcenter works on 3D dataset
Surprisingly, the Crop program's `--checkcenter' option wasn't yet
configured for 3D datasets. With this commit, checking the center is now
possible on 3D datasets too.
---
bin/crop/onecrop.c | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/bin/crop/onecrop.c b/bin/crop/onecrop.c
index 5afff2c..c68c405 100644
--- a/bin/crop/onecrop.c
+++ b/bin/crop/onecrop.c
@@ -847,15 +847,24 @@ onecrop_center_filled(struct onecropparams *crp)
fitsfile *ofp=crp->outfits;
int status=0, anynul=0, type;
long checkcenter=p->checkcenter;
- long naxes[2], fpixel[2], lpixel[2], inc[2]={1,1};
+ long naxes[3], fpixel[3], lpixel[3], inc[3]={1,1,1};
/* If checkcenter is zero, then don't check. */
if(checkcenter==0) return GAL_BLANK_UINT8;
/* Get the final size of the output image. */
gal_fits_img_info(ofp, &type, &ndim, &dsize, NULL, NULL);
- naxes[0]=dsize[1];
- naxes[1]=dsize[0];
+ if(ndim==2)
+ {
+ naxes[0]=dsize[1];
+ naxes[1]=dsize[0];
+ }
+ else
+ {
+ naxes[0]=dsize[2];
+ naxes[1]=dsize[1];
+ naxes[2]=dsize[0];
+ }
/* Get the size and range of the central region to check. The +1 is
because in FITS, counting begins from 1, not zero. It might happen
@@ -864,10 +873,23 @@ onecrop_center_filled(struct onecropparams *crp)
full image to check. */
size = ( (naxes[0]>checkcenter ? checkcenter : naxes[0])
* (naxes[1]>checkcenter ? checkcenter : naxes[1]) );
- fpixel[0] = naxes[0]>checkcenter ? (naxes[0]/2+1)-checkcenter/2 : 1;
- fpixel[1] = naxes[1]>checkcenter ? (naxes[1]/2+1)-checkcenter/2 : 1;
- lpixel[0] = naxes[0]>checkcenter ? (naxes[0]/2+1)+checkcenter/2 : naxes[0];
- lpixel[1] = naxes[1]>checkcenter ? (naxes[1]/2+1)+checkcenter/2 : naxes[1];
+ fpixel[0] = naxes[0]>checkcenter ? ((naxes[0]/2+1)-checkcenter/2) : 1;
+ fpixel[1] = naxes[1]>checkcenter ? ((naxes[1]/2+1)-checkcenter/2) : 1;
+ lpixel[0] = ( naxes[0]>checkcenter
+ ? ((naxes[0]/2+1)+checkcenter/2) : naxes[0] );
+ lpixel[1] = ( naxes[1]>checkcenter
+ ? ((naxes[1]/2+1)+checkcenter/2) : naxes[1] );
+
+
+ /* For the third dimension. */
+ if(ndim==3)
+ {
+ size *= (naxes[2]>checkcenter ? checkcenter : naxes[2]);
+ fpixel[2] = naxes[2]>checkcenter ? ((naxes[2]/2+1)-checkcenter/2) : 1;
+ lpixel[2] = ( naxes[2]>checkcenter
+ ? ((naxes[2]/2+1)+checkcenter/2) : naxes[2] );
+ }
+
/* For a check:
printf("naxes: %ld, %ld\nfpixel: (%ld, %ld)\nlpixel: (%ld, %ld)\n"
- [gnuastro-commits] master adeb1c6 016/113: NoiseChisel's convolution step in 3D completed, (continued)
- [gnuastro-commits] master adeb1c6 016/113: NoiseChisel's convolution step in 3D completed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master ace4160 017/113: New --mcolisbrightness option for MakeProfiles, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master f06acc5 018/113: Merged recent work from master, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 61aec7b 019/113: Convolve name and dimensionality checks, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 4627ddf 021/113: NoiseChisel segmentation working in 3D, test added, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 1560a54 022/113: Default NoiseChisel kernel in 3D changed to 1.5 pixels, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 4d2508f 028/113: Fixed NoiseChisel opening and dilation and merged with master, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 4223e60 025/113: Suggestions on viewing/inspecting NoiseChisel's output, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 6086579 031/113: Merged recent work in master (corrected conflicts), Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master b0d5fab 034/113: Merged recent work from master, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 06798a5 035/113: Crop's --checkcenter works on 3D dataset,
Mohammad Akhlaghi <=
- [gnuastro-commits] master fd51c80 050/113: Imported recent work from master, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master a4dbaba 055/113: Recent work in master imported, minor conflict fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 0597cea 058/113: Imported work in master, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master e11098d 053/113: Recent work in master imported, minor conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 0a8324f 059/113: MakeProfiles kernel option can be elongated in 3rd-dimension, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master ec3c102 056/113: Single to conditionally open ds9 for multi-HDU 2D or 3D, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 2491c91 064/113: Imported work in master, minor conflict in book fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 9dda05c 040/113: Merged recent work from the master branch with corrections, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 218a7db 041/113: Brought in recent work from master, corrections made, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 6f4e484 032/113: Merged with recent updates in master, Mohammad Akhlaghi, 2021/04/16