[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master ab1452a: Using image naxes[n] when checkcenter
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master ab1452a: Using image naxes[n] when checkcenter is larger |
Date: |
Thu, 19 Jan 2017 21:57:48 +0000 (UTC) |
branch: master
commit ab1452a85c8abfd986e78ef5b735a115dedb33a2
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
Using image naxes[n] when checkcenter is larger
Until now, the width of the region to check for a blank center in ImageCrop
was absolute (value to the `--checkcenter' option). As reported by Lee
Kelvin in bug #50099, this caused a crash when the cropped image size is
smaller than this width.
So with this commit, some checks are added so when the image width (in any
dimension, or value to `naxes[n]') is smaller than the check-center width,
the width (in that dimension) is used, not the value given by the user.
This fixes bug #50099.
---
bin/imgcrop/crop.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/bin/imgcrop/crop.c b/bin/imgcrop/crop.c
index 62b1f93..ee8bfa5 100644
--- a/bin/imgcrop/crop.c
+++ b/bin/imgcrop/crop.c
@@ -151,7 +151,7 @@ sectionparser(char *section, long *naxes, long *fpixel,
long *lpixel)
*/
}
- if(fpixel[0]>=lpixel[0] || fpixel[1]>=lpixel[1])
+ if(fpixel[0]>lpixel[0] || fpixel[1]>lpixel[1])
error(EXIT_FAILURE, 0, "the bottom left corner coordinates "
"cannot be larger or equal to the top right's! Your section "
"string (%s) has been read as: bottom left coordinate "
@@ -834,14 +834,18 @@ iscenterfilled(struct cropparams *crp)
gal_fits_io_error(status, NULL);
/* Get the size and range of the central region to check. The +1 is
- because in FITS, counting begins from 1, not zero. */
- fpixel[0]=(naxes[0]/2+1)-checkcenter/2;
- fpixel[1]=(naxes[1]/2+1)-checkcenter/2;
- lpixel[0]=(naxes[0]/2+1)+checkcenter/2;
- lpixel[1]=(naxes[1]/2+1)+checkcenter/2;
+ because in FITS, counting begins from 1, not zero. It might happen
+ that the image is actually smaller than the width to check the center
+ (for example 1 or 2 pixels wide). In that case, we'll just use the
+ 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];
/* Allocate the array and read in the pixels. */
- size=checkcenter*checkcenter;
array=gal_fits_datatype_alloc(size, gal_fits_bitpix_to_datatype(bitpix) );
if( fits_read_subset(ofp, p->datatype, fpixel, lpixel, inc,
p->bitnul, array, &anynul, &status) )
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master ab1452a: Using image naxes[n] when checkcenter is larger,
Mohammad Akhlaghi <=