 |
OpendTect
6.6
|
Go to the documentation of this file.
50 static const char*
sKeyWinFunc() {
return "Window function"; }
52 static const char*
sKeyWinLen() {
return "Window length"; }
71 template <
class T>
inline
75 , windowparam_(
mUdf(float) )
82 template <
class T>
inline
86 , windowparam_( b.windowparam_ )
87 , window_( b.window_ )
88 , windowname_( b.windowname_ )
95 template <
class T>
inline
103 template <
class T>
inline
110 template <
class T>
inline
113 return window_.size()==b.
window_.size() &&
119 template <
class T>
inline
132 window_.setSize( length );
133 const double step = 2.0/(length-1);
134 for (
int idx=0; idx<length; idx++ )
135 window_[idx] = wf->
getValue( (
float) (step*idx-1) );
138 windowparam_ = (float) ( wf->
hasVariable() ? param : 1e30 );
144 template <
class T>
inline
147 par.
set( sKeyWinFunc(), windowname_ );
148 if ( !
mIsUdf(windowparam_) )
149 par.
set( sKeyWinParam(), windowparam_ );
150 par.
set( sKeyWinLen(), window_.size() );
154 template <
class T>
inline
158 if ( !par.
get(sKeyWinLen(), sz ) )
161 const char* wn = par.
find( sKeyWinFunc() );
162 float var =
mUdf(
float);
163 par.
get( sKeyWinParam(), var );
165 return setWindow( wn, var, sz );
169 template <
class T>
inline
172 if ( !input_ || !output_ || !window_.size() )
177 for (
int idx=0; idx<size_; idx++ )
179 if ( !
mIsUdf(input_[idx]) )
186 if ( firstdefined_!=-1 )
188 for (
int idx=
mCast(
int,size_-1); idx>=0; idx-- )
190 if ( !
mIsUdf(input_[idx]) )
202 template <
class T>
inline
205 const float* window = window_.arr();
206 const int windowsize = window_.size();
207 const int hwinsize = windowsize/2;
209 for (
int outidx=
mCast(
int,start); outidx<=stop; outidx++, addToNrDone(1) )
211 if ( firstdefined_==-1 || outidx<firstdefined_ || outidx>lastdefined_ )
213 output_[outidx] =
mUdf(T);
217 int sumstart = outidx-hwinsize;
218 int sumstop = outidx+windowsize-hwinsize-1;
222 winstart = -sumstart;
226 if ( sumstop>=size_ )
227 sumstop =
mCast(
int,size_-1);
230 double weightsum = 0;
231 for (
int sumidx=sumstart, winidx=winstart;
232 sumidx<=sumstop; sumidx++, winidx++ )
234 double val = input_[sumidx];
238 sum += val * window[winidx];
239 weightsum += window[winidx];
242 output_[outidx] = (T) (weightsum ? sum/weightsum :
mUdf(
float));
float getWindowParam() const
Definition: smoother1d.h:43
void set(const char *ky, const char *val)
bool get(const char *, short &) const
void setOutput(T *)
Definition: smoother1d.h:104
#define mIsEqual(x, y, eps)
Definition: commondefs.h:67
void setInput(const T *, int sz)
Definition: smoother1d.h:96
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:289
#define od_int64
Definition: plftypes.h:35
int firstdefined_
Definition: smoother1d.h:66
Smoother1D()
Definition: smoother1d.h:72
virtual bool hasVariable() const
Definition: windowfunction.h:30
od_int64 size_
Definition: smoother1d.h:64
const char * getWindowName() const
Definition: smoother1d.h:42
int lastdefined_
Definition: smoother1d.h:67
static const char * sKeyWinLen()
Definition: smoother1d.h:52
float windowparam_
Definition: smoother1d.h:60
TypeSet< T > window_
Definition: smoother1d.h:58
bool setWindow(const char *nm, float param, int lenght)
Definition: smoother1d.h:120
#define mClass(module)
Definition: commondefs.h:181
BufferString windowname_
Definition: smoother1d.h:59
int getWindowLength() const
Definition: smoother1d.h:41
Smoothes a 1d signal with an operator.
Definition: smoother1d.h:28
const T * input_
Definition: smoother1d.h:62
void fillPar(IOPar &) const
Definition: smoother1d.h:145
virtual bool setVariable(float)
Definition: windowfunction.h:32
Generalization of a task that can be run in parallel.
Definition: paralleltask.h:66
bool operator==(const Smoother1D< T > &) const
Definition: smoother1d.h:111
#define mCast(tp, v)
Definition: commondefs.h:137
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
bool usePar(const IOPar &)
Definition: smoother1d.h:155
static const char * sKeyWinParam()
Definition: smoother1d.h:51
const char * find(const char *) const
returns null if not found
virtual RT getValue(PT) const =0
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:274
bool doWork(od_int64 start, od_int64 stop, int)
Definition: smoother1d.h:203
bool doPrepare(int)
Definition: smoother1d.h:170
Smoother1D(const Smoother1D &)
Definition: smoother1d.h:83
od_int64 nrIterations() const
Definition: smoother1d.h:54
T * output_
Definition: smoother1d.h:63
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:55
static const char * sKeyWinFunc()
Definition: smoother1d.h:50
Sets of (small) copyable elements.
Definition: commontypes.h:29
Generated at
for the OpendTect
seismic interpretation project.
Copyright (C): dGB Beheer B.V. 1995-2021