[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 52d3868: MakeProfiles: rounding of sub-pixel c
[gnuastro-commits] master 52d3868: MakeProfiles: rounding of sub-pixel center at 1/1000000 from 1/100
Wed, 17 Jul 2019 16:15:31 -0400 (EDT)
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
MakeProfiles: rounding of sub-pixel center at 1/1000000 from 1/100
Until now, to fix floating point issues (especially when converting from
WCS), we were rounding subpixel, image coordinates to 1/100. As a result,
for example a central pixel value of 2.499 would be rounded to
2.5. However, especially when using large oversampling, such levels of
precision are necessary. We are also dealing with double-precision floating
point types which are accurate to roughly 15 decimals. SO the rounding to
1/100 was not too accurate and could cause unexpected behavior.
To fix this problem, in MakeProfile's `oneprofile_center_oversampled'
function, the rounding is now set as a variable `r', and given a value of
1000000. This is also arbitrary and hard-coded in the source, but
currently, I don't see any need to change it. If we later feel the user
must be able to change it, we can define it as an option.
While inspecting the code, a few typos and edits were also fixed the
comments to make them more clear to read. Also, the name of the
`oneprof_set_prof_params' function was corrected to
`oneprofile_set_prof_params' (which is the correct format!).
This bug was reported by Roberto Baena Gallé.
This fixes bug #56641.
NEWS | 1 +
bin/mkprof/mkprof.c | 18 +++++++++---------
bin/mkprof/oneprofile.c | 7 +++----
bin/mkprof/oneprofile.h | 2 +-
doc/announce-acknowledge.txt | 1 +
5 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/NEWS b/NEWS
index 2d2a501..976b7bd 100644
@@ -135,6 +135,7 @@ See the end of the file for license conditions.
bug #56324: Column metadata not usable when input is from pipe/stdin.
bug #56424: Warp crashes with empty string given to options.
bug #56480: Segfault in statistics library's histogram function.
+ bug #56641: MakeProfile's center position changes based on precision.
diff --git a/bin/mkprof/mkprof.c b/bin/mkprof/mkprof.c
index 17c623b..7612f77 100644
@@ -320,7 +320,7 @@ mkprof_build_single(struct mkonthread *mkp, long *fpixel_i,
overlapping region. */
- /* Note that `fpixel_o' and `lpixel_o' were in the un-oversampled
+ /* Note that `fpixel_i' and `lpixel_o' were in the un-oversampled
image, they are also in the FITS coordinates. */
@@ -465,20 +465,20 @@ mkprof_build(void *inparam)
/* Make each profile that was specified for this thread. */
for(i=0; mkp->indexs[i]!=GAL_BLANK_SIZE_T; ++i)
- /* Create a new builtqueue element with all the information. fbq
- will be used when we want to add ibq to p->bq. It is defined
- so we don't have to waste time traversing the ibq. Its
- characteristic compared to the other elements of ibq is that
- fbq->next==NULL. So to add ibq to p->bq, we just have to set
- fbq->next=p->bq and then set p->bq to ibq.*/
+ /* Create a new builtqueue element with all the information. `fbq'
+ will be used when we want to add `ibq' to `p->bq'. It is defined
+ so we don't have to waste time traversing the `ibq'. Its
+ characteristic compared to the other elements of `ibq' is that
+ `fbq->next==NULL'. So to add ibq to p->bq, we just have to set
+ `fbq->next=p->bq' and then set `p->bq' to `ibq'.*/
- /* Write the necessary parameters for this profile into mkp.*/
+ /* Write the necessary parameters for this profile into `mkp'.*/
/* Find the bounding box size (NOT oversampled). */
diff --git a/bin/mkprof/oneprofile.c b/bin/mkprof/oneprofile.c
index 471fdd4..d01ffa2 100644
@@ -62,19 +62,18 @@ oneprofile_center_oversampled(struct mkonthread *mkp)
struct mkprofparams *p=mkp->p;
- double *dim;
+ double *dim, r=1000000;
size_t i, id=mkp->ibq->id;
double val, pixfrac, intpart;
dim = i==0 ? p->x : p->y;
pixfrac = modf(fabs(dim[id]), &intpart);
val = ( os*(mkp->width[i]/2 + pixfrac)
+ (pixfrac<0.5f ? os/2 : -1*os/2-1) );
- mkp->center[i] = round(val*100)/100;
+ mkp->center[i] = round(val*r)/r;
@@ -515,7 +514,7 @@ oneprofile_ispsf(uint8_t fcode)
/* Prepare all the parameters for any type of profile. */
-oneprof_set_prof_params(struct mkonthread *mkp)
+oneprofile_set_prof_params(struct mkonthread *mkp)
struct mkprofparams *p=mkp->p;
diff --git a/bin/mkprof/oneprofile.h b/bin/mkprof/oneprofile.h
index acc7aea..e38b61e 100644
@@ -29,7 +29,7 @@ int
-oneprof_set_prof_params(struct mkonthread *mkp);
+oneprofile_set_prof_params(struct mkonthread *mkp);
oneprofile_make(struct mkonthread *mkp);
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index 23858a9..241dcec 100644
@@ -1,6 +1,7 @@
Alphabetically ordered list to acknowledge in the next release.
+Roberto Baena Gallé
|[Prev in Thread]
||[Next in Thread]|
- [gnuastro-commits] master 52d3868: MakeProfiles: rounding of sub-pixel center at 1/1000000 from 1/100,
Mohammad Akhlaghi <=