gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master a1fa641: ConvertType: new sls-inverse colormap


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master a1fa641: ConvertType: new sls-inverse colormap, good for printing
Date: Mon, 31 Aug 2020 18:09:28 -0400 (EDT)

branch: master
commit a1fa641fa6fd406b00301ca400b7a1609ab5593f
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    ConvertType: new sls-inverse colormap, good for printing
    
    The SLS colormap is a good color map for viewing on the monitor, but for
    printing and some types of visualizations, its very dark background
    decreases its usefulness.
    
    With this commit, there is now an inverse SLS color map (called
    'sls-inverse') to keep the advantages of SLS, but good for scenarios where
    a white background can help.
---
 NEWS                 | 4 ++++
 bin/convertt/color.c | 7 +++++--
 bin/convertt/main.h  | 1 +
 bin/convertt/ui.c    | 2 ++
 doc/gnuastro.texi    | 9 +++++++--
 5 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index 9a16024..c7d590d 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,10 @@ See the end of the file for license conditions.
      will be read as floating point. This also applies to column arithmetic
      in Table.
 
+  ConvertType:
+   - New colormap: 'sls-inverse' is the inverse of the SLS color, good for
+     printing because of a white background.
+
   CosmicCalculator:
    --velocity: Velocity (in km/s) to use instead of input redshift.
    --usedvelocity: Print the velocity (in km/s) at input redshift.
diff --git a/bin/convertt/color.c b/bin/convertt/color.c
index f7194cf..d736a25 100644
--- a/bin/convertt/color.c
+++ b/bin/convertt/color.c
@@ -206,7 +206,9 @@ color_from_mono_sls(struct converttparams *p)
       if(isnan(*f))
         *r=*g=*b=0.0;
       else
-        switch( (int)((*f-min)/(max-min)*200) )
+        switch( p->colormap->status==COLOR_SLS
+                ? (int)((*f-min)/(max-min)*200)
+                : 200 - (int)((*f-min)/(max-min)*200) )
           {
           case 0:   *r=0.000000; *g=0.000000; *b=0.000000; break;
           case 1:   *r=0.043442; *g=0.000000; *b=0.052883; break;
@@ -764,9 +766,10 @@ color_map_prepare(struct converttparams *p)
   switch(p->colormap->status)
     {
     case COLOR_HSV:          color_from_mono_hsv(p); break;
-    case COLOR_SLS:          color_from_mono_sls(p); break;
     case COLOR_VIRIDIS:      color_from_mono_viridis(p); break;
     case COLOR_GRAY:         convertt_scale_to_uchar(p); break;
+    case COLOR_SLS:
+    case COLOR_SLS_INVERSE:  color_from_mono_sls(p); break;
     default:
       error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
             "the problem. The value %d is not a recognized color-space "
diff --git a/bin/convertt/main.h b/bin/convertt/main.h
index f7e1953..ba82add 100644
--- a/bin/convertt/main.h
+++ b/bin/convertt/main.h
@@ -56,6 +56,7 @@ enum colorspace_names
   COLOR_RGB,
   COLOR_HSV,
   COLOR_SLS,
+  COLOR_SLS_INVERSE,
   COLOR_VIRIDIS,
   COLOR_GRAY,
 };
diff --git a/bin/convertt/ui.c b/bin/convertt/ui.c
index 4600d77..4ed1778 100644
--- a/bin/convertt/ui.c
+++ b/bin/convertt/ui.c
@@ -242,6 +242,8 @@ ui_colormap_sanity_check(struct converttparams *p)
   else if( !strcmp(strarr[0],"viridis")) { ccode=COLOR_VIRIDIS; nparams=0; }
   else if( !strcmp(strarr[0],"gray") || !strcmp(strarr[0],"grey"))
                                       { ccode=COLOR_GRAY; nparams=0; }
+  else if( !strcmp(strarr[0],"sls-inverse"))
+    { ccode=COLOR_SLS_INVERSE; nparams=0; }
   else
     error(EXIT_FAILURE, 0, "'%s' not recognized as a colormap given "
           "to '--colormap'", strarr[0]);
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index c683ccc..4fbff9f 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -9220,8 +9220,13 @@ Viridis is the default colormap of the popular 
Matplotlib module of Python and a
 @cindex SLS Color
 @cindex Colormap: SLS
 The SLS color range, taken from the commonly used @url{http://ds9.si.edu,SAO 
DS9}.
-The advantage of this color range is that it ranges from black to dark blue, 
and finishes with red and white.
-So unlike the HSV color range, it includes black and white and brighter colors 
(like yellow, red and white) show the larger values.
+The advantage of this color range is that it starts with black, going into 
dark blue and comes to brighter colors, finishings with red and white.
+So unlike the HSV color range, it includes black and white and brighter colors 
(like yellow, red) show the larger values.
+
+@item sls-inverse
+@cindex Colormap: SLS-inverse
+The inverse of the SLS color map (see above), where the lowest value 
corresponds to white and the highest value is black.
+While SLS is good for visualizing on the monitor, SLS-inverse is good for 
printing.
 @end table
 
 @item --rgbtohsv



reply via email to

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