Ver código fonte

Add r.rgb

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@35904 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 16 anos atrás
pai
commit
001790e4a2
3 arquivos alterados com 88 adições e 0 exclusões
  1. 7 0
      scripts/r.rgb/Makefile
  2. 20 0
      scripts/r.rgb/r.rgb.html
  3. 61 0
      scripts/r.rgb/r.rgb.py

+ 7 - 0
scripts/r.rgb/Makefile

@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = r.rgb
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script

+ 20 - 0
scripts/r.rgb/r.rgb.html

@@ -0,0 +1,20 @@
+<H2>DESCRIPTION</H2>
+
+<EM>r.rgb</EM> is a script that generates separate red, green and blue
+maps from a raster map and its associated color table.
+
+<H2>SEE ALSO</H2>
+
+<P>
+<EM>
+<A HREF="r.composite.html">r.composite</A>,<br>
+<A HREF="r.blend.html">r.blend</A>,<br>
+<A HREF="r.colors.html">r.colors</A>,<br>
+<A HREF="r.mapcalc.html">r.mapcalc</A>,<br>
+</EM>
+
+<H2>AUTHOR</H2>
+
+Glynn Clements
+
+<p><i>Last changed: $Date: 2008-08-15 07:16:42 +0100 (Fri, 15 Aug 2008) $</i>

+ 61 - 0
scripts/r.rgb/r.rgb.py

@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+
+############################################################################
+#
+# MODULE:       r.rgb
+# AUTHOR(S):	Glynn Clements
+# PURPOSE:	Split a raster map into red, green and blue maps
+# COPYRIGHT:	(C) 2009 Glynn Clements and the GRASS Development Team
+#
+#		This program is free software under the GNU General Public
+#		License (>=v2). Read the file COPYING that comes with GRASS
+#		for details.
+#
+#############################################################################
+
+#% Module
+#%  description: Split a raster map into red, green and blue maps
+#%  keywords: raster
+#% End
+#% option
+#%  key: input
+#%  type: string
+#%  gisprompt: old,cell,raster
+#%  description: Input map
+#%  required : yes
+#% end
+#% option
+#%  key: output
+#%  type: string
+#%  description: Base name for output maps
+#%  required : no
+#% end
+
+import sys
+import os
+import string
+import grass
+
+def main():
+    input = options['input']
+    output = options['output']
+
+    if not grass.find_file(input)['file']:
+	grass.fatal("Map <%s> not found." % input)
+
+    if not output:
+	output = input
+
+    expr = ';'.join(["${output}.r = r#${input}",
+		     "${output}.g = g#${input}",
+		     "${output}.b = b#${input}"])
+    grass.mapcalc(expr, input = input, output = output)
+
+    for ch in ['r', 'g', 'b']:
+	name = "%s.%s" % (output, ch)
+	grass.run_command('r.colors', map = name, color = 'grey255')
+	grass.raster_history(name)
+
+if __name__ == "__main__":
+    options, flags = grass.parser()
+    main()