| TUgridFilter | TCL UTILITIES USER MANUAL | TUgridFilter |
|---|
| set |
[TUgridFilter  |
|
| fType | - | The filter type.
|
|||||||||||||||||||||||||||||||||||||||||||||
| Grid | - | A 2D data grid generated through a call to TUdataGrid. | |||||||||||||||||||||||||||||||||||||||||||||
| gInfo | - | The grid information array. | |||||||||||||||||||||||||||||||||||||||||||||
| fOps | - | An array of filter options. The
option definitions depend on the fiter type selected in
fType.
|
|||||||||||||||||||||||||||||||||||||||||||||
| Filter | - | Optional array input. When fType is set to 2DFILTER you can use the Filter array to enter an external matrix filter to operate on the data grid. The filter must be square (NxN). If present this filter will be used over any of the build in filters regardless of how fOps(0) is set. |
| Will return 1 if no errors or -1 if the procedure detects a non-square matrix passed in through the Filter variable. |
# 2D FILTER Examples
# SET up a data set of four Gaussians centered at (-3,-3) and one at (-3, 3)
# (3,-3) and (3, 3). Each has a different intensity. Add 20% noise to
# form a noisy version of the data set.
set nP 0
for { set X -6.0 } { $X <= 6.0 } { set X [expr $X + .1] } {
for { set Y -6.0 } { $Y <= 6.0 } { set Y [expr $Y + .1] } {
set Xx($nP) $X
set Yy($nP) $Y
set R [expr ($X - 3.0) * ($X - 3.0) + ($Y - 3.0) * ($Y - 3.0)]
set A [expr exp(-$R / 6.0)]
set R [expr ($X - 3.0) * ($X - 3.0) + ($Y + 3.0) * ($Y + 3.0)]
set B [expr 3.0 * exp(-$R / 6.0)]
set R [expr ($X + 3.0) * ($X + 3.0) + ($Y - 3.0) * ($Y - 3.0)]
set C [expr 4.0 * exp(-$R / 6.0)]
set R [expr ($X + 3.0) * ($X + 3.0) + ($Y + 3.0) * ($Y + 3.0)]
set D [expr 2.0 * exp(-$R / 6.0)]
set Vv($nP) [expr $A + $B + $C + $D]
set Vn($nP) [expr $Vv($nP) * ( 1.0 + [TUdataRnd1 DuM 1 NP .2])]
incr nP
}
}
# SET up the grid information array.
set gInfo(0) -6.0
set gInfo(1) 6.0
set gInfo(2) -6.0
set gInfo(3) 6.0
set gInfo(4) 100
set gInfo(5) 100
set gInfo(6) POINT
set gInfo(7) POINT
set gInfo(8) COLUMN
set gInfo(9) IGNORE
set gInfo(10) NEW:ADD:END
set gInfo(11) -1
set gInfo(12) -5
set gInfo(13) -1.0e30
set gInfo(14) 1.0e30
set gInfo(15) NO
set gInfo(16) NO
# GRID the clean data set and 5 versions of the noisy data set for
# filtering
TUdataGrid $nP 1 Xx Xx 1 Yy Yy Vv gCl Norm gInfo
TUdataGrid $nP 1 Xx Xx 1 Yy Yy Vn gNsA Norm gInfo
TUdataGrid $nP 1 Xx Xx 1 Yy Yy Vn gNsB Norm gInfo
TUdataGrid $nP 1 Xx Xx 1 Yy Yy Vn gNsC Norm gInfo
TUdataGrid $nP 1 Xx Xx 1 Yy Yy Vn gNsD Norm gInfo
TUdataGrid $nP 1 Xx Xx 1 Yy Yy Vn gNsE Norm gInfo
# SET up the plot basics. There are a total of 6 plots defined here.
set GphInfo(xScrL) 500
set GphInfo(yScrL) 760
GraphicsOn TK ETones SWAP
GenWindow 1 0.0 0.0 0.0 1.0 1.0 0.0 0. 0. 0. 1. 1. 0. XY
set WinInfo(2,corFmt) 1
RelWindow 2 1 75.0 515.0 0. 275. 715. 0. -6. -6. 0. 6. 6. 0.
DefinePlot 2 2 $gInfo(4) $gInfo(5)
set WinInfo(3,corFmt) 1
RelWindow 3 1 280.0 515.0 0. 480. 715. 0. -6. -6. 0. 6. 6. 0.
DefinePlot 3 3 $gInfo(4) $gInfo(5)
set WinInfo(4,corFmt) 1
RelWindow 4 1 75.0 290.0 0. 275. 490. 0. -6. -6. 0. 6. 6. 0.
DefinePlot 4 4 $gInfo(4) $gInfo(5)
set WinInfo(5,corFmt) 1
RelWindow 5 1 280.0 290.0 0. 480. 490. 0. -6. -6. 0. 6. 6. 0.
DefinePlot 5 5 $gInfo(4) $gInfo(5)
set WinInfo(6,corFmt) 1
RelWindow 6 1 75.0 65.0 0. 275. 265. 0. -6. -6. 0. 6. 6. 0.
DefinePlot 6 6 $gInfo(4) $gInfo(5)
set WinInfo(7,corFmt) 1
RelWindow 7 1 280.0 65.0 0. 480. 265. 0. -6. -6. 0. 6. 6. 0.
DefinePlot 7 7 $gInfo(4) $gInfo(5)
# SET up the color map to run from 0 to 4.5
PLTcolorMap 0.0 4.5 LINEAR 0 cA
# PLOT the noiseless data set in upper left plot
Plot3D 2 Xb Yb Dummy Dummy gCl AUTO Dummy cA
# PLOT the noisey data set in upper right plot
Plot3D 3 Xb Yb Dummy Dummy gNsA AUTO Dummy cA
# SET up a Savitzky-Golay Filter. Filter first along the columns and
# then along the rows. This is a two step process. Put the results
# in the middle left-hand plot
set fOps(0) COLUMN
set fOps(1) NO
set fOps(2) NO
set fOps(3) 3
set fOps(4) 3
set fOps(5) 1
set fOps(6) YES
TUgridFilter SAVITZKYGOLAY gNsB gInfo fOps DUMMY
set fOps(0) ROW
TUgridFilter SAVITZKYGOLAY gNsB gInfo fOps DUMMY
set fOps(0) 0
Plot3D 4 Xb Yb Dummy Dummy gNsB AUTO Dummy cA
# DO a 3x3 Low Pass filter on the grid. Plot the results in the middle
# right-hand plot
set fOps(0) 0
TUgridFilter 2DFILTER gNsC gInfo fOps
Plot3D 5 Xb Yb Dummy Dummy gNsC AUTO Dummy cA
# DO a 3x3 High Pass filter on the grid. Plot the results in the lower
# right-hand plot
set fOps(0) 2
TUgridFilter 2DFILTER gNsD gInfo fOps
Plot3D 6 Xb Yb Dummy Dummy gNsD AUTO Dummy cA
# DO a 3x3 Laplacian Pass filter on the grid. Plot the results in the lower
# right-hand plot
set fOps(0) 4
TUgridFilter 2DFILTER gNsE gInfo fOps
Plot3D 7 Xb Yb Dummy Dummy gNsE AUTO Dummy cA
# THROW up the axis. Only annotate lower left-hand plot
PlotOutlines 2 [list "" 1.0 "" 1.0] [list NONE NONE BOTH BOTH]
PlotOutlines 3 [list "" 1.0 "" 1.0] [list NONE NONE BOTH BOTH]
PlotOutlines 4 [list "" 1.0 "" 1.0] [list NONE NONE BOTH BOTH]
PlotOutlines 5 [list "" 1.0 "" 1.0] [list NONE NONE BOTH BOTH]
PlotOutlines 6 [list "X" 1.0 "Y" 1.0] [list BOT BOT BOTH BOTH]
PlotOutlines 7 [list "" 1.0 "" 1.0] [list NONE NONE BOTH BOTH]
update
# LABEL the plots
TextProp 12 HOLD HOLD
WinClip 2 0
TexT 2 0.0 6.50 0.0 center "ORIGINAL" $GphInfo(White)
WinClip 3 0
TexT 3 0.0 6.50 0.0 center "NOISY" $GphInfo(White)
WinClip 4 0
TexT 4 0.0 6.50 0.0 center "SAVITZKY-GOLAY" $GphInfo(White)
WinClip 5 0
TexT 5 0.0 6.50 0.0 center "3x3 LOW PASS" $GphInfo(White)
WinClip 6 0
TexT 6 0.0 6.50 0.0 center "3x3 HIGH PASS" $GphInfo(White)
WinClip 7 0
TexT 7 0.0 6.50 0.0 center "3x3 LAPLACIAN" $GphInfo(White)
| Sept 22, 2006 |
|---|