ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkFrequencyDomain1DFilterFunction.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkFrequencyDomain1DFilterFunction_h
19#define itkFrequencyDomain1DFilterFunction_h
20
21#include "itkObject.h"
22#include "itkObjectFactory.h"
23
24namespace itk
25{
39{
40public:
46
47 itkOverrideGetNameOfClassMacro(FrequencyDomain1DFilterFunction);
48 itkNewMacro(Self);
49
50
57 double
59 {
60 if (m_UseCache)
61 {
62 // TODO: Check for out of bounds?
63 return m_Cache[i];
64 }
65 else
66 {
67 return this->EvaluateFrequency(this->GetFrequency(i));
68 }
69 }
70
71 void
73 {
74 if (this->m_SignalSize != size)
75 {
76 this->m_SignalSize = size;
77 if (this->m_UseCache)
78 {
79 this->m_Cache.resize(size);
80 }
81 this->Modified();
82 }
83 }
84
87 {
88 return m_SignalSize;
89 }
90
91 itkSetMacro(UseCache, bool);
92 itkGetMacro(UseCache, bool);
93
99 virtual double
100 EvaluateFrequency(double itkNotUsed(frequency)) const
101 {
102 return 1.0;
103 }
104
105 virtual void
106 Modified() const override
107 {
108 // Force a chache update
109 const_cast<FrequencyDomain1DFilterFunction *>(this)->UpdateCache();
111 }
112
113protected:
114 virtual void
115 PrintSelf(std::ostream & os, Indent indent) const override
116 {
117 Superclass::PrintSelf(os, indent);
118
119 os << indent << "SignalSize: " << m_SignalSize << std::endl;
120 os << indent << "UseCache: " << m_UseCache << std::endl;
121 os << indent << "CacheSize: " << m_Cache.size() << std::endl;
122 }
123
125 {
126 m_UseCache = true;
127 m_SignalSize = 0;
128 }
129
130private:
131 double
133 {
134 double f = (2.0 * i) / m_SignalSize;
135 if (f > 1.0)
136 {
137 f = f - 2.0;
138 }
139 return f;
140 }
141
142 void
144 {
145 if (this->m_UseCache)
146 {
147 for (SizeValueType i = 0; i < m_Cache.size(); i++)
148 {
149 this->m_Cache[i] = this->EvaluateFrequency(this->GetFrequency(i));
150 }
151 }
152 }
153
155 std::vector<double> m_Cache;
157};
158
159} // namespace itk
160#endif // itkFrequencyDomain1DFilterFunction.h
virtual void PrintSelf(std::ostream &os, Indent indent) const override
virtual double EvaluateFrequency(double frequency) const
Control indentation during Print() invocation.
Definition itkIndent.h:53
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void Modified() const
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition itkIntTypes.h:82
#define itkSetMacro(name, type)