[GRASS-SVN] r52671 - grass-addons/grass6/imagery/i.despeckle

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 13 18:52:13 PDT 2012


Author: maning
Date: 2012-08-13 18:52:13 -0700 (Mon, 13 Aug 2012)
New Revision: 52671

Modified:
   grass-addons/grass6/imagery/i.despeckle/i.despeckle
Log:
new filter enhanced lee

Modified: grass-addons/grass6/imagery/i.despeckle/i.despeckle
===================================================================
--- grass-addons/grass6/imagery/i.despeckle/i.despeckle	2012-08-13 20:44:41 UTC (rev 52670)
+++ grass-addons/grass6/imagery/i.despeckle/i.despeckle	2012-08-14 01:52:13 UTC (rev 52671)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh -x
 
 ############################################################################
 #
@@ -6,8 +6,9 @@
 # AUTHOR(S):    Markus Neteler, Maning Sambale
 # PURPOSE:      FGAMMA -- Gamma SAR Speckle Filter, based on
 #               http://web.archive.org/web/20050826071553/http://www.pcigeomatics.com/cgi-bin/pcihlp/M_FGAMMA
-#               http://web.archive.org/web/20070122173456/http://www.pcigeomatics.com/cgi-bin/pcihlp/FLE|ALGORITHM
+#               http://web.archive.org/web/20050425160834/http://www.pcigeomatics.com/cgi-bin/pcihlp/M_FLE
 #               http://web.archive.org/web/20071216181051/http://www.pcigeomatics.com/cgi-bin/pcihlp/FELEE
+#               web.archive.org/web/20050425104814/http://www.pcigeomatics.com/cgi-bin/pcihlp/M_FKUAN
 #               http://web.archive.org/web/20071216081728/http://www.pcigeomatics.com/cgi-bin/pcihlp/FFROST
 #               http://web.archive.org/web/20071216181046/http://www.pcigeomatics.com/cgi-bin/pcihlp/FEFROST
 #
@@ -53,7 +54,7 @@
 #% type: string
 #% required: yes
 #% multiple: no
-#% options: gamma,lee,kuan
+#% options: gamma,lee,kuan,elee
 #% description: Despeckle operation
 #% answer: gamma
 #%End
@@ -70,11 +71,21 @@
 #% type: integer
 #% required: no
 #% multiple: no
-#% description: Number of looks (1: single look)
+#% description: Number of looks (0 <= x <= 100)
 #% answer: 1
 #%End
+#%Option
+#% key: dfactor
+#% type: real
+#% required: no
+#% multiple: no
+#% description: Damping factor (0.0 <= x <= 10.0)
+#% answer: 1.0
+#%End
 
 
+
+
 if [ -z "$GISBASE" ] ; then
     echo "You must be in GRASS GIS to run this program." 1>&2
     exit 1
@@ -95,6 +106,7 @@
 NumberLooks=$GIS_OPT_LOOKS # controls the amount of smoothing applied to image 
 OUTPUT=$GIS_OPT_OUTPUT
 METHOD=$GIS_OPT_METHOD
+DFACTOR=$GIS_OPT_DFACTOR 
 
 #########################
 
@@ -129,7 +141,7 @@
   # Ic  =   center pixel in filter window
   r.mapcalc "$OUTPUT = $MAP * $MAP.W + $MAP.mean * (1.0 - $MAP.W)"
 
-  g.remove --q rast=$MAP.mean,$MAP.stddev,$MAP.rf,$MAP.ci,$MAP.W
+  g.remove --q rast=$MAP.mean,$MAP.stddev,$MAP.ci,$MAP.W
 fi
 
 if [ $METHOD == "kuan" ]
@@ -184,9 +196,42 @@
          ) \\
        ))"
 
-  g.remove --q rast=$MAP.mean,$MAP.stddev,$MAP.rf,$MAP.ci,$MAP.A,$MAP.B,$MAP.D,$MAP.W
+  g.remove --q rast=$MAP.mean,$MAP.stddev,$MAP.rf,$MAP.ci,$MAP.A,$MAP.B,$MAP.D
   
 fi
+
+###
+
+if [ $METHOD == "elee" ]
+then
+  echo "Processing with Enhanced LEE filter"
+
+  # A 7x7 filter usually gives the best results.
+ 
+  # Cmax =  SQRT(1+2/NumberLooks)
+  Cmax="`echo $Cu | awk '{printf "%f", sqrt((1+2) * $1)}'`"
+
+  # W   =   exp (-DampFactor (Ci-Cu)/(Cmax - Ci))
+  r.mapcalc "$MAP.W = exp (((-1 * $DFACTOR) * ($MAP.Ci - $Cu)) / ($Cmax - $MAP.Ci))"
+
+  # Rf  =   Im * W + Ic * (1-W)
+  r.mapcalc "$MAP.rf = $MAP.mean * $MAP.W + $MAP * (1 - $MAP.W)"
+
+  # R = Im                  for Ci <= Cu
+  # Rf = Im * W + Ic * (1-W) for Cu < Ci < Cmax
+  # R = Ic                  for Ci >= Cmax
+ 
+ r.mapcalc "$OUTPUT = eval(r1 = $MAP.mean, r2 = $MAP.rf, r3 = $MAP, \\
+       if($MAP.ci <= $Cu, r1, \\
+         if($MAP.ci > $Cu && $MAP.ci < $Cmax, r2, \\
+           if($MAP.ci >= $Cmax, r3, null() ) \\
+         ) \\
+       ))"
+
+  g.remove --q rast=$MAP.mean,$MAP.stddev,$MAP.rf,$MAP.ci,$MAP.W
+  
+fi
+
 ####################
 
 r.colors $OUTPUT col=grey -e



More information about the grass-commit mailing list