[GRASS-SVN] r69365 - sandbox/alexandris/i.rgb.his

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Sep 4 09:54:57 PDT 2016


Author: nikosa
Date: 2016-09-04 09:54:56 -0700 (Sun, 04 Sep 2016)
New Revision: 69365

Modified:
   sandbox/alexandris/i.rgb.his/rgb2his.c
Log:
i.rgb.his (sandbox): set hue to NULL if achromatic case is true

Modified: sandbox/alexandris/i.rgb.his/rgb2his.c
===================================================================
--- sandbox/alexandris/i.rgb.his/rgb2his.c	2016-09-04 13:55:49 UTC (rev 69364)
+++ sandbox/alexandris/i.rgb.his/rgb2his.c	2016-09-04 16:54:56 UTC (rev 69365)
@@ -19,8 +19,14 @@
 #include "globals.h"
 #include <math.h>
 
+/*
+ * (input/output) rowbuffer
+ * columns
+ * maximum level of range 2^bit_depth
+ */
 
 void rgb2his(DCELL *rowbuffer[3], int columns, double max_level)
+
 {
     int column;         /* column indicator               */
     double red;         /* the red band output            */
@@ -35,9 +41,9 @@
 
 for (column = 0; column < columns; column++) {
 
-	if (Rast_is_d_null_value(&rowbuffer[0][column]) ||
-	    Rast_is_d_null_value(&rowbuffer[1][column]) ||
-	    Rast_is_d_null_value(&rowbuffer[2][column])) {
+    if (Rast_is_d_null_value(&rowbuffer[0][column]) ||
+        Rast_is_d_null_value(&rowbuffer[1][column]) ||
+        Rast_is_d_null_value(&rowbuffer[2][column])) {
             Rast_set_d_null_value(&rowbuffer[0][column], 1);
             Rast_set_d_null_value(&rowbuffer[1][column], 1);
             Rast_set_d_null_value(&rowbuffer[2][column], 1);
@@ -83,11 +89,8 @@
         saturation = 0.0;
 
         /* undefined -- (how to) set to NULL? */
-        hue = 0.0;
+        hue = -1;
 
-        rowbuffer[0][column] = (FCELL)hue;
-        rowbuffer[1][column] = (FCELL)saturation;
-        rowbuffer[2][column] = (FCELL)lightness;
     }
 
     /*  else chromatic */
@@ -112,12 +115,20 @@
         if (hue < 0.0)
             hue += 360.0;
 
-        /* HSL output values */
+    }
+
+    /* HSL output values */
+    if (hue == -1.0) {
+            Rast_set_d_null_value(&rowbuffer[0][column], 1);
+    }
+    else
+    {
         rowbuffer[0][column] = (FCELL)hue;
-        rowbuffer[1][column] = (FCELL)saturation;
-        rowbuffer[2][column] = (FCELL)lightness;
     }
 
+    rowbuffer[1][column] = (FCELL)saturation;
+    rowbuffer[2][column] = (FCELL)lightness;
+
     G_debug(2, "Output rowbuffers 0, 1, 2: %f, %f, %f\n",
             rowbuffer[0][column], rowbuffer[1][column], rowbuffer[2][column]);
   }



More information about the grass-commit mailing list