[GRASS-SVN] r30500 - grass-addons/imagery/i.landsat.dehaze
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 7 12:53:59 EST 2008
Author: neteler
Date: 2008-03-07 12:53:58 -0500 (Fri, 07 Mar 2008)
New Revision: 30500
Modified:
grass-addons/imagery/i.landsat.dehaze/description.html
grass-addons/imagery/i.landsat.dehaze/i.landsat.dehaze
Log:
i.landsat.dehaze is working again (more tests needed)
Modified: grass-addons/imagery/i.landsat.dehaze/description.html
===================================================================
--- grass-addons/imagery/i.landsat.dehaze/description.html 2008-03-07 17:28:43 UTC (rev 30499)
+++ grass-addons/imagery/i.landsat.dehaze/description.html 2008-03-07 17:53:58 UTC (rev 30500)
@@ -14,20 +14,33 @@
<div class="code"><pre>
# preparation of Tasseled Cap "haze" map
-i.tasscap -7 band1=tm.10 band2=tm.20 band3=tm.30 band4=tm.40 band5=tm.50 band7=tm.70 out=tasscap
+i.tasscap -7 band1=tm.10 band2=tm.20 band3=tm.30 band4=tm.40 \
+ band5=tm.50 band7=tm.70 out=tasscap
# De-hazing
-i.landsat.dehaze band1=tm.10 band2=tm.20 band3=tm.30 band4=tm.40 band5=tm.50 band7=tm.70 tasscap4=tasscap.4
+i.landsat.dehaze band1=tm.10 band2=tm.20 band3=tm.30 band4=tm.40 \
+ band5=tm.50 band7=tm.70 tasscap4=tasscap.4 outprefix=dehaze
+
+# color-balanced grey scales:
+i.landsat.rgb blue=dehaze.1 green=dehaze.2 red=dehaze.3
+
+# display as RGB composite
+d.mon x0
+d.rgb blue=dehaze.1 green=dehaze.2 red=dehaze.3
</pre></div>
<H2>SEE ALSO</H2>
-<EM><A HREF="d.rgb.html">d.rgb</A></EM>,
-<EM><A HREF="g.region.html">g.region</A></EM>,
-<EM><A HREF="i.tasscap.html">i.tasscap</A></EM>,
-<EM><A HREF="r.colors.html">r.colors</A></EM>,
-<EM><A HREF="r.composite.html">r.composite</A></EM>
+<EM>
+<A HREF="d.rgb.html">d.rgb</A>,
+<A HREF="g.region.html">g.region</A>,
+<A HREF="i.landsat.rgb.html">i.landsat.rgb</A>,
+<A HREF="i.tasscap.html">i.tasscap</A>,
+<A HREF="r.colors.html">r.colors</A>,
+<A HREF="r.composite.html">r.composite</A>,
+<A HREF="r.regression.line.html">r.regression.line</A>
+</EM>
<H2>AUTHOR</H2>
Modified: grass-addons/imagery/i.landsat.dehaze/i.landsat.dehaze
===================================================================
--- grass-addons/imagery/i.landsat.dehaze/i.landsat.dehaze 2008-03-07 17:28:43 UTC (rev 30499)
+++ grass-addons/imagery/i.landsat.dehaze/i.landsat.dehaze 2008-03-07 17:53:58 UTC (rev 30500)
@@ -1,9 +1,17 @@
#!/bin/sh
-# $Id: i.tm.dehaze,v 1.5 2002/10/30 08:51:49 markus Exp $
-# copyright Markus Neteler <neteler geog.uni-hannover.de| neteler itc.it>
-# License: GNU GPL
+############################################################################
#
+# MODULE: i.landsat.dehaze
+# AUTHOR(S): Markus Neteler. neteler geog.uni-hannover.de | neteler itc.it
+# PURPOSE: bandwise haze correction using tasscap4 (haze) and linear regression
+# COPYRIGHT: (C) 1997-2008 by 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.
+#############################################################################
+#
# Methodology:
# Bandwise correction using tasscap4 (haze) and linear regression.
# (Crippen 1987 approach)
@@ -89,6 +97,13 @@
#% description: Tasseled Cap 4 haze map
#% gisprompt: old,cell,raster
#%End
+#%Option
+#% key: outprefix
+#% type: string
+#% gisprompt: new,cell,raster
+#% description: raster output dehazed maps prefix
+#% required : yes
+#%End
if [ -z "$GISBASE" ] ; then
echo "You must be in GRASS GIS to run this program." 1>&2
@@ -131,20 +146,19 @@
#get the stats:
getstats()
{
- r.stats -1 $tasscap,$1 > $2
- r.linear.regression in=$2 out=$3
+ # y = a + b*x
+ # a=78.86 b=1.51 R=0.24 N=250325 F=-0.058 medX=12.37 sdX=6.0 medY=97.5 sdY=37.43
+ result="`r.regression.line -g map1=$tasscap map2=$1 | grep '^a=\|^b=' | cut -d'=' -f2 | tr '\n' ' '`"
if [ $? -eq 1 ] ; then
echo "An error occurred. Stop."
exit
fi
-# result="`tail $3 | grep a\[1\] | cut -d' ' -f2,3 | tr -s '=' ' '`"
- result="`tail $3 | grep "a\[1\]" | tr -s '=' ' '`"
}
getstats $tm1 $tasscap.plot1 $tasscap.regress1
slope_tm1=`echo $result | cut -d' ' -f2`
-intercept_tm1=`echo $result | cut -d' ' -f4`
+intercept_tm1=`echo $result | cut -d' ' -f1`
# clean up the tmp stuff:
rm -f $tasscap.plot1 $tasscap.regress1
echo "Result for channel $tm1: sl:$slope_tm1 i:$intercept_tm1"
@@ -152,7 +166,7 @@
getstats $tm2 $tasscap.plot2 $tasscap.regress2
slope_tm2=`echo $result | cut -d' ' -f2`
-intercept_tm2=`echo $result | cut -d' ' -f4`
+intercept_tm2=`echo $result | cut -d' ' -f1`
# clean up the tmp stuff:
rm -f $tasscap.plot2 $tasscap.regress2
echo "Result for channel $tm2: $slope_tm2 i:$intercept_tm2"
@@ -160,7 +174,7 @@
getstats $tm3 $tasscap.plot3 $tasscap.regress3
slope_tm3=`echo $result | cut -d' ' -f2`
-intercept_tm3=`echo $result | cut -d' ' -f4`
+intercept_tm3=`echo $result | cut -d' ' -f1`
# clean up the tmp stuff:
rm -f $tasscap.plot3 $tasscap.regress3
echo "Result for channel $tm3: $slope_tm3 i:$intercept_tm3"
@@ -168,7 +182,7 @@
getstats $tm4 $tasscap.plot4 $tasscap.regress4
slope_tm4=`echo $result | cut -d' ' -f2`
-intercept_tm4=`echo $result | cut -d' ' -f4`
+intercept_tm4=`echo $result | cut -d' ' -f1`
# clean up the tmp stuff:
rm -f $tasscap.plot4 $tasscap.regress4
echo "Result for channel $tm4: $slope_tm4 i:$intercept_tm4"
@@ -176,7 +190,7 @@
getstats $tm5 $tasscap.plot5 $tasscap.regress5
slope_tm5=`echo $result | cut -d' ' -f2`
-intercept_tm5=`echo $result | cut -d' ' -f4`
+intercept_tm5=`echo $result | cut -d' ' -f1`
# clean up the tmp stuff:
rm -f $tasscap.plot5 $tasscap.regress5
echo "Result for channel $tm5: $slope_tm5 i:$intercept_tm5"
@@ -186,13 +200,14 @@
echo "Running the dehaze formula: tm.dehaze = tm - [ (tass4 - tm_i) * tm_s]"
echo " with internally calculated i:intercept, s: slope"
-r.mapcalc $tm1.dehaze="$tm1 - ( ($tasscap - $intercept_tm1) * $slope_tm1)"
-r.mapcalc $tm2.dehaze="$tm2 - ( ($tasscap - $intercept_tm2) * $slope_tm2)"
-r.mapcalc $tm3.dehaze="$tm3 - ( ($tasscap - $intercept_tm3) * $slope_tm3)"
-r.mapcalc $tm4.dehaze="$tm4 - ( ($tasscap - $intercept_tm4) * $slope_tm4)"
-r.mapcalc $tm5.dehaze="$tm5 - ( ($tasscap - $intercept_tm5) * $slope_tm5)"
+r.mapcalc $GIS_OPT_OUTPREFIX.1="$tm1 - ( ($tasscap - $intercept_tm1) * $slope_tm1)"
+r.mapcalc $GIS_OPT_OUTPREFIX.2="$tm2 - ( ($tasscap - $intercept_tm2) * $slope_tm2)"
+r.mapcalc $GIS_OPT_OUTPREFIX.3="$tm3 - ( ($tasscap - $intercept_tm3) * $slope_tm3)"
+r.mapcalc $GIS_OPT_OUTPREFIX.4="$tm4 - ( ($tasscap - $intercept_tm4) * $slope_tm4)"
+r.mapcalc $GIS_OPT_OUTPREFIX.5="$tm5 - ( ($tasscap - $intercept_tm5) * $slope_tm5)"
echo ""
echo "The new dehazed bands are: "
-echo "$tm1.dehaze, $tm2.dehaze, $tm3.dehaze, $tm4.dehaze, $tm5.dehaze"
+echo "$GIS_OPT_OUTPREFIX.1 .. $GIS_OPT_OUTPREFIX.5"
echo ""
-echo "Consider to run r.colors or i.grey.scale to set a grey color table"
+echo "Consider to run r.colors or i.landsat.rgb to set grey color tables for each channel"
+
More information about the grass-commit
mailing list