[GRASS-SVN] r43508 - grass/branches/releasebranch_6_4/imagery/i.his.rgb

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Sep 18 12:11:30 EDT 2010


Author: neteler
Date: 2010-09-18 16:11:29 +0000 (Sat, 18 Sep 2010)
New Revision: 43508

Modified:
   grass/branches/releasebranch_6_4/imagery/i.his.rgb/closefiles.c
   grass/branches/releasebranch_6_4/imagery/i.his.rgb/h2rmain.c
   grass/branches/releasebranch_6_4/imagery/i.his.rgb/his2rgb.c
Log:
backport: metadata and cleanup

Modified: grass/branches/releasebranch_6_4/imagery/i.his.rgb/closefiles.c
===================================================================
--- grass/branches/releasebranch_6_4/imagery/i.his.rgb/closefiles.c	2010-09-18 16:09:43 UTC (rev 43507)
+++ grass/branches/releasebranch_6_4/imagery/i.his.rgb/closefiles.c	2010-09-18 16:11:29 UTC (rev 43508)
@@ -12,6 +12,7 @@
     int i;
     struct Colors colors;
     struct Range range;
+    struct History history;
     CELL min, max;
     char *mapset;
 
@@ -22,6 +23,8 @@
 
     mapset = G_mapset();
 
+    /* write colors */
+    /*   set to 0,max_level instead of min,max ?? */
     G_read_range(r_name, mapset, &range);
     G_get_range_min_max(&range, &min, &max);
     G_make_grey_scale_colors(&colors, min, max);
@@ -37,5 +40,21 @@
     G_make_grey_scale_colors(&colors, min, max);
     G_write_colors(b_name, mapset, &colors);
 
+    /* write metadata */
+    G_short_history(r_name, "raster", &history);
+    G_command_history(&history);
+    G_write_history(r_name, &history);
+    G_put_cell_title(r_name, "Image red");
+
+    G_short_history(g_name, "raster", &history);
+    G_command_history(&history);
+    G_write_history(g_name, &history);
+    G_put_cell_title(g_name, "Image green");
+
+    G_short_history(b_name, "raster", &history);
+    G_command_history(&history);
+    G_write_history(b_name, &history);
+    G_put_cell_title(b_name, "Image blue");
+
     return 0;
 }

Modified: grass/branches/releasebranch_6_4/imagery/i.his.rgb/h2rmain.c
===================================================================
--- grass/branches/releasebranch_6_4/imagery/i.his.rgb/h2rmain.c	2010-09-18 16:09:43 UTC (rev 43507)
+++ grass/branches/releasebranch_6_4/imagery/i.his.rgb/h2rmain.c	2010-09-18 16:11:29 UTC (rev 43508)
@@ -75,6 +75,7 @@
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
+
     /* get dimension of the image */
     rows = G_window_rows();
     cols = G_window_cols();
@@ -91,7 +92,7 @@
 	/* read in a row from each cell map */
 	for (band = 0; band < 3; band++)
 	    if (G_get_map_row(fd_input[band], rowbuffer[band], i) < 0)
-		G_fatal_error(_("Unable to read raster map row %d"), i);
+		G_fatal_error(_("Unable to read raster map row %ld"), i);
 
 	/* process this row of the map */
 	his2rgb(rowbuffer, cols);
@@ -100,9 +101,11 @@
 	for (band = 0; band < 3; band++)
 	    if (G_put_raster_row(fd_output[band], rowbuffer[band], CELL_TYPE)
 		< 0)
-		G_fatal_error(_("Failed writing raster map row %d"), i);
+		G_fatal_error(_("Failed writing raster map row %ld"), i);
     }
+    G_percent(i, rows, 2);
 
+
     closefiles(opt_red->answer, opt_green->answer, opt_blue->answer,
 	       fd_output, rowbuffer);
 

Modified: grass/branches/releasebranch_6_4/imagery/i.his.rgb/his2rgb.c
===================================================================
--- grass/branches/releasebranch_6_4/imagery/i.his.rgb/his2rgb.c	2010-09-18 16:09:43 UTC (rev 43507)
+++ grass/branches/releasebranch_6_4/imagery/i.his.rgb/his2rgb.c	2010-09-18 16:11:29 UTC (rev 43508)
@@ -19,7 +19,7 @@
 #include <grass/gis.h>
 #include "globals.h"
 
-void his2rgb(CELL * rowbuffer[3], int columns)
+void his2rgb(CELL *rowbuffer[3], int columns)
 {
     long sample;		/* sample indicator                          */
     double red;			/* the red band output                       */
@@ -121,16 +121,16 @@
 	else
 	    blue = blue255;
 
-	if (red > 254.5)
-	    red = 254.5;
+	if (red > 255. - 0.5)
+	    red = 255. - 0.5;
 	if (red < 0.0)
 	    red = 0.0;
-	if (green > 254.5)
-	    green = 254.5;
+	if (green > 255. - 0.5)
+	    green = 255. - 0.5;
 	if (green < 0.0)
 	    green = 0.0;
-	if (blue > 254.5)
-	    blue = 254.5;
+	if (blue > 255. - 0.5)
+	    blue = 255. - 0.5;
 	if (blue < 0.0)
 	    blue = 0.0;
 



More information about the grass-commit mailing list