00001
00002 """
00003 A SLIMpy linear operator consists of a dictionary of
00004 values operator_dict and an undefined pipeobject to
00005 be defined upon application to a vector.
00006 """
00007
00008 __copyright__ = """
00009 Copyright 2008 Sean Ross-Ross
00010 """
00011 __license__ = """
00012 This file is part of SLIMpy .
00013
00014 SLIMpy is free software: you can redistribute it and/or modify
00015 it under the terms of the GNU Lesser General Public License as published by
00016 the Free Software Foundation, either version 3 of the License, or
00017 (at your option) any later version.
00018
00019 SLIMpy is distributed in the hope that it will be useful,
00020 but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00022 GNU Lesser General Public License for more details.
00023
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with SLIMpy . If not, see <http://www.gnu.org/licenses/>.
00026 """
00027
00028 from slimpy_base.Core.User.linop.rclinOp import linearop_r as LinearOperatorStruct
00029 from slimpy_base.Core.User.linop.linear_operator import CompoundOperator
00030 from slimpy_base.Core.User.linop.LinearOperatorType import LinearOperatorType
00031 from slimpy_base.Core.Interface.node import Source
00032
00033
00034
00035 class mdwt1( LinearOperatorStruct ):
00036 """
00037 Rice Wavelet Toolboxes' Wavelet transform
00038 """
00039 name = "mdwt1"
00040 def __init__( self, inSpace, h=None, L=2, adj=False, **kparams ):
00041 """
00042 Takes h, L as paramaters. h as source so it creates it.
00043 """
00044 assert h is not None
00045 kparams.update( h=Source(h.getContainer()), L=L, adj=adj )
00046
00047 LinearOperatorStruct.__init__( self, inSpace, **kparams )
00048
00049
00050 class mdwt2( LinearOperatorStruct ):
00051 """
00052 Rice Wavelet Toolboxes' Wavelet transform
00053 """
00054 name = "mdwt1"
00055 def __init__( self, inSpace, h=None, L=2, adj=False, **kparams ):
00056 """
00057 Takes h, L as paramaters. h as source so it creates it.
00058 """
00059 assert h is not None
00060 kparams.update( h=Source(h.getContainer()), L=L, adj=adj )
00061
00062 LinearOperatorStruct.__init__( self, inSpace, **kparams )
00063
00064
00065
00066 class mrdwt1( LinearOperatorStruct ):
00067 """
00068 Rice Wavelet Toolboxes' Redundant Wavelet transform
00069 """
00070 name = "mrdwt1"
00071 def __init__( self, inSpace, h=None, L=2, adj=False, **kparams ):
00072 """
00073 Takes h, L as paramaters. h as source so it creates it.
00074 """
00075 assert h is not None
00076 kparams.update( h=Source(h.getContainer()), L=L, adj=adj )
00077
00078 LinearOperatorStruct.__init__( self, inSpace, **kparams )
00079
00080
00081 class mrdwt2( LinearOperatorStruct ):
00082 """
00083 Rice Wavelet Toolboxes' Redundant Wavelet transform
00084 """
00085 name = "mrdwt1"
00086 def __init__( self, inSpace, h=None, L=2, adj=False, **kparams ):
00087 """
00088 Takes h, L as paramaters. h as source so it creates it.
00089 """
00090 assert h is not None
00091 kparams.update( h=Source(h.getContainer()), L=L, adj=adj )
00092
00093 LinearOperatorStruct.__init__( self, inSpace, **kparams )
00094
00095
00096
00097
00098 class dwt( LinearOperatorStruct ):
00099 """
00100 Wavelet transform on any axis
00101 """
00102 name = "dwt"
00103
00104 def __init__( self, inSpace, axis= 1, type = 'linear', unit=True ):
00105 """
00106 @param unit unitary scaling
00107 @param type wavelet type
00108 """
00109 self.axis = axis
00110 kparams = dict( type = type , adj=False, unit=unit )
00111
00112 LinearOperatorStruct.__init__( self, inSpace, **kparams )
00113
00114
00115 def applyop( self, other ):
00116 """
00117 Apply self to a vector other
00118 """
00119
00120
00121 othertransp = other.transp( a1=1, a2=self.axis )
00122
00123 dwttransp = LinearOperatorStruct.applyop( self, othertransp )
00124
00125 dwtdata = dwttransp.transp( a1=1, a2=self.axis )
00126
00127 return dwtdata
00128
00129
00130
00131 @LinearOperatorType
00132 def dwt2( inSpace, type='linear' ):
00133 """
00134 The Wavelet transform in two dimensions
00135 """
00136 return CompoundOperator( [ dwt( inSpace, type=type ),
00137 dwt( inSpace, axis=2, type=type ) ] )
00138
00139
00140
00141 @LinearOperatorType
00142 def dwt3( inSpace, type='linear' ):
00143 """
00144 The Wavelet transform in three dimensions
00145 """
00146 return CompoundOperator( [dwt( inSpace, type=type ),
00147 dwt( inSpace, axis=2, type=type ),
00148 dwt( inSpace, axis=3, type=type )] )
00149
00150