[Top][All Lists]

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

[gnuastro-commits] master 14bba0b: Warp: not allowing --translate and --

From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 14bba0b: Warp: not allowing --translate and --centeroncorner together
Date: Fri, 3 Jul 2020 13:33:48 -0400 (EDT)

branch: master
commit 14bba0b271525a183e482efdc730fd42031ec67b
Author: Mohammad Akhlaghi <>
Commit: Mohammad Akhlaghi <>

    Warp: not allowing --translate and --centeroncorner together
    Until now, just before finding the size of the final warped image, we would
    see if there is a translation element in the matrix. If there was a
    translation, then the size of the output would be adjusted to account for
    the translation. This is required for normal "translations" (so the image
    "moves" compared to the first pixel). However, the '--centeroncorner'
    option is also a translation, but this adjustment is not desired there and
    will result in incorrect output sizes.
    With this commit, when the '--centeroncorner' option is called, the
    adjustment is not made, and to avoid unexpected problems, it won't allow
    calling the '--translate' and '--centeroncorner' options together. Since
    the centering is inherently a translation, a solution is suggested in the
    error message.
    This bug was found by Marjan Akbari.
    This fixes bug #58696.
 NEWS                         |  1 +
 bin/warp/ui.c                | 10 ++++++++++
 bin/warp/warp.c              |  5 +++--
 doc/announce-acknowledge.txt |  1 +
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 043c42d..0d5126b 100644
--- a/NEWS
+++ b/NEWS
@@ -49,6 +49,7 @@ See the end of the file for license conditions.
 ** Bugs fixed
   bug #58434: MakeCatalog crash when ordering is required and no usable pixels.
   bug #58455: Timezone is not portable and uses flag instead of seconds.
+  bug #58696: Warp with --centeroncorner --scale making wrong size.
diff --git a/bin/warp/ui.c b/bin/warp/ui.c
index f821f47..e6a1a11 100644
--- a/bin/warp/ui.c
+++ b/bin/warp/ui.c
@@ -698,6 +698,16 @@ ui_matrix_from_modular(struct warpparams *p)
         case UI_KEY_TRANSLATE:
+          /* Translate cannot be called with '--centeroncorner'. */
+          if(p->centeroncorner)
+            error(EXIT_FAILURE, 0, "'--translate' and '--centeroncorner' "
+                  "(which is a type of translation) cannot be called "
+                  "together. To acheive the effect of --centeroncorner, "
+                  "start the warp steps with a translation of 0.5 to move "
+                  "the coordinate center to the corner of a pixel in each "
+                  "dimension");
+          /* Build the translation matrix. */
           module[0]=1.0f;       module[1]=0.0f;     module[2]=v1;
           module[3]=0.0f;       module[4]=1.0f;     module[5]=v2;
           module[6]=0.0f;       module[7]=0.0f;     module[8]=1.0f;
diff --git a/bin/warp/warp.c b/bin/warp/warp.c
index b67629d..f5f113c 100644
--- a/bin/warp/warp.c
+++ b/bin/warp/warp.c
@@ -336,8 +336,9 @@ warp_preparations(struct warpparams *p)
   /* If we have translation, the 'dsize's and 'outfpixval's should be
-     corrected. */
-  if(matrix[2]!=0.0f || matrix[5]!=0.0f)
+     corrected. Note that centeroncorner is also a translation operation,
+     but in that scenario, we don't want this feature! */
+  if( p->centeroncorner==0 && (matrix[2]!=0.0f || matrix[5]!=0.0f) )
       dsize[1] += abs(matrix[2])+1;
       dsize[0] += abs(matrix[5])+1;
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index b15ccb6..602c6ea 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -1,5 +1,6 @@
 Alphabetically ordered list to acknowledge in the next release.
+Marjan Akbari
 Carlos Allende Prieto
 Alexey Dokuchaev
 Raúl Infante Sainz

reply via email to

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