[GRASS-SVN] r69366 - sandbox/alexandris/i.rgb.his
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Sep 4 10:44:57 PDT 2016
Author: nikosa
Date: 2016-09-04 10:44:57 -0700 (Sun, 04 Sep 2016)
New Revision: 69366
Modified:
sandbox/alexandris/i.rgb.his/main.c
sandbox/alexandris/i.rgb.his/rgb2his.c
Log:
i.rgb.his (sandbox): allow for <8-bits, added some debugging messages
Modified: sandbox/alexandris/i.rgb.his/main.c
===================================================================
--- sandbox/alexandris/i.rgb.his/main.c 2016-09-04 16:54:56 UTC (rev 69365)
+++ sandbox/alexandris/i.rgb.his/main.c 2016-09-04 17:44:57 UTC (rev 69366)
@@ -95,7 +95,7 @@
opt_bit_depth->type = TYPE_INTEGER;
opt_bit_depth->required = NO;
opt_bit_depth->answer = "8";
- opt_bit_depth->options = "8-16";
+ opt_bit_depth->options = "2-16";
opt_bit_depth->description = _("Bit depth of input maps");
if (G_parser(argc, argv))
@@ -118,8 +118,8 @@
/* open files */
openfiles(opt_red->answer, opt_green->answer, opt_blue->answer,
- opt_hue->answer, opt_saturation->answer, opt_lightness->answer,
- fd_input, fd_output, rowbuffer);
+ opt_hue->answer, opt_saturation->answer, opt_lightness->answer,
+ fd_input, fd_output, rowbuffer);
/* read in maps per row*/
for (row = 0; row < rows; row++) {
@@ -142,7 +142,7 @@
/* close files */
closefiles(opt_hue->answer, opt_saturation->answer, opt_lightness->answer,
- fd_output, rowbuffer);
+ fd_output, rowbuffer);
exit(EXIT_SUCCESS);
}
Modified: sandbox/alexandris/i.rgb.his/rgb2his.c
===================================================================
--- sandbox/alexandris/i.rgb.his/rgb2his.c 2016-09-04 16:54:56 UTC (rev 69365)
+++ sandbox/alexandris/i.rgb.his/rgb2his.c 2016-09-04 17:44:57 UTC (rev 69366)
@@ -70,6 +70,7 @@
if (blue > max)
max = blue;
+
/* min of {r,g,b} */
min = red;
@@ -79,16 +80,20 @@
if (blue < min)
min = blue;
+
+ /* chroma and lightness */
+
chroma = max - min;
lightness = ((max + min) / 2.0);
+
/* if R == G == B, then min == max, which is achromatic */
if (chroma == 0.0) {
saturation = 0.0;
- /* undefined -- (how to) set to NULL? */
+ /* undefined? set to -1, recode later to NULL */
hue = -1;
}
@@ -117,19 +122,26 @@
}
+ G_debug(2, "Maximum level among r, g, b: %f", max);
+ G_debug(2, "Minimum level among r, g, b: %f", min);
+ G_debug(2, "Lightness: %f", lightness);
+
/* HSL output values */
+
+ /* set hue = -1 to NULL */
if (hue == -1.0) {
- Rast_set_d_null_value(&rowbuffer[0][column], 1);
+ Rast_set_d_null_value(&rowbuffer[0][column], 1);
}
else
{
rowbuffer[0][column] = (FCELL)hue;
}
+ /* set saturation, lightness */
rowbuffer[1][column] = (FCELL)saturation;
rowbuffer[2][column] = (FCELL)lightness;
- G_debug(2, "Output rowbuffers 0, 1, 2: %f, %f, %f\n",
+ G_debug(3, "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