OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | List of all members
ossimDiscrete3x3HatFilter Class Reference

#include <ossimDiscrete3x3HatFilter.h>

Inheritance diagram for ossimDiscrete3x3HatFilter:
ossimDiscreteConvolutionKernel

Public Member Functions

 ossimDiscrete3x3HatFilter ()
 
virtual void convolve (const float *data, double &result, float nullPixel=OSSIM_DEFAULT_NULL_PIX_FLOAT) const
 
virtual void convolveSubImage (const float *data, long dataWidth, double &result, float nullPixel=OSSIM_DEFAULT_NULL_PIX_FLOAT) const
 
virtual void convolve (const unsigned char *data, double &result, ossim_uint8 nullPixel=OSSIM_DEFAULT_NULL_PIX_UINT8) const
 
virtual void convolveSubImage (const unsigned char *data, long dataWidth, double &result, ossim_uint8 nullPixel=OSSIM_DEFAULT_NULL_PIX_UINT8) const
 
virtual void buildConvolution (double widthPercent, double heightPercent)
 
- Public Member Functions inherited from ossimDiscreteConvolutionKernel
 ossimDiscreteConvolutionKernel (long width, long height, bool doWeightedAverage=true)
 
 ossimDiscreteConvolutionKernel (const NEWMAT::Matrix &kernel, bool doWeightedAverage=true)
 
virtual ~ossimDiscreteConvolutionKernel ()
 
virtual void setKernel (const NEWMAT::Matrix &kernel)
 
virtual void convolve (const double *data, double &result, double nullPixel=OSSIM_DEFAULT_NULL_PIX_DOUBLE) const
 
virtual void convolveSubImage (const double *data, long dataWidth, double &result, double nullPixel=OSSIM_DEFAULT_NULL_PIX_DOUBLE) const
 
virtual void convolve (const short *data, double &result, ossim_sint16 nullPixel=OSSIM_DEFAULT_NULL_PIX_SINT16) const
 
virtual void convolveSubImage (const short *data, long dataWidth, double &result, ossim_sint16 nullPixel=OSSIM_DEFAULT_NULL_PIX_SINT16) const
 
virtual void convolve (const unsigned short *data, double &result, ossim_uint16 nullPixel=OSSIM_DEFAULT_NULL_PIX_UINT16) const
 
virtual void convolveSubImage (const unsigned short *data, long dataWidth, double &result, ossim_uint16 nullPixel=OSSIM_DEFAULT_NULL_PIX_UINT16) const
 
virtual long getWidth () const
 
virtual long getHeight () const
 
const NEWMAT::Matrix & getKernel () const
 

Additional Inherited Members

- Static Public Member Functions inherited from ossimDiscreteConvolutionKernel
static void buildSymmetric (const std::vector< float > &coefficients, NEWMAT::Matrix &result)
 
static void buildSymmetric (float *coefficients, long size, NEWMAT::Matrix &result)
 
- Protected Attributes inherited from ossimDiscreteConvolutionKernel
NEWMAT::Matrix * theKernel
 
long theWidth
 
long theHeight
 
bool theComputeWeightedAverageFlag
 

Detailed Description

Definition at line 14 of file ossimDiscrete3x3HatFilter.h.

Constructor & Destructor Documentation

◆ ossimDiscrete3x3HatFilter()

ossimDiscrete3x3HatFilter::ossimDiscrete3x3HatFilter ( )

Definition at line 12 of file ossimDiscrete3x3HatFilter.cpp.

14 {
15  // make the default be the nearest neighbor
16  (*theKernel)[0][0] = 0;
17  (*theKernel)[0][1] = 0;
18  (*theKernel)[0][2] = 0;
19 
20  (*theKernel)[1][0] = 0;
21  (*theKernel)[1][1] = 1;
22  (*theKernel)[1][2] = 0;
23 
24  (*theKernel)[2][0] = 0;
25  (*theKernel)[2][1] = 0;
26  (*theKernel)[2][2] = 0;
27 }
ossimDiscreteConvolutionKernel(long width, long height, bool doWeightedAverage=true)

Member Function Documentation

◆ buildConvolution()

void ossimDiscrete3x3HatFilter::buildConvolution ( double  ,
double   
)
virtual

This is used to allow me to continually adjust a convolution kernel based on where it center lies on a pixel. The xLocation and yLocation are all from the center of pixel. If I am convolving at full resolution then xLocation and yLocation should both be 0. Let's pretend that we contract an image by .5 scale factor or zooming out by a factor of 2. Then we actually of it .5 off from cneter of pixel in both the x and y direction. This information can be used to allow a kernel to adjust it's waits accordingly.

Typically if the xLocation and yLocation is directly on the center indicated by 0 vor both then the kernel defaults to 1 in the middle and all other weights are zero.

Reimplemented from ossimDiscreteConvolutionKernel.

Definition at line 274 of file ossimDiscrete3x3HatFilter.cpp.

References abs.

276 {
277  NEWMAT::RowVector row(3);
278  NEWMAT::ColumnVector col(3);
279 
280  row[0] = std::abs(xLocation);
281  row[1] = 1;
282  row[2] = std::abs(xLocation);
283  col[0] = std::abs(yLocation);
284  col[1] = 1;
285  col[2] = std::abs(yLocation);
286 
287  (*theKernel) = col*row;
288 }
#define abs(a)
Definition: auxiliary.h:74

◆ convolve() [1/2]

void ossimDiscrete3x3HatFilter::convolve ( const float *  data,
double &  result,
float  nullPixel = OSSIM_DEFAULT_NULL_PIX_FLOAT 
) const
virtual

Will expect a data buffer of size width*height and is row ordered.

Reimplemented from ossimDiscreteConvolutionKernel.

Definition at line 29 of file ossimDiscrete3x3HatFilter.cpp.

32 {
33  double divisor = 0;
34  result = 0;
35 
36  if(data[0] != nullPixel)
37  {
38  divisor += (*theKernel)[0][0];
39  result += (*theKernel)[0][0] * data[0];
40  }
41  if(data[1] != nullPixel)
42  {
43  divisor += (*theKernel)[0][1];
44  result += (*theKernel)[0][1] * data[1];
45  }
46  if(data[2] != nullPixel)
47  {
48  divisor += (*theKernel)[0][2];
49  result += (*theKernel)[0][2] * data[2];
50  }
51  if(data[3] != nullPixel)
52  {
53  divisor += (*theKernel)[1][0];
54  result += (*theKernel)[1][0] * data[3];
55  }
56  if(data[4] != nullPixel)
57  {
58  divisor += (*theKernel)[1][1];
59  result += (*theKernel)[1][1] * data[4];
60  }
61  if(data[5] != nullPixel)
62  {
63  divisor += (*theKernel)[1][2];
64  result += (*theKernel)[1][2] * data[5];
65  }
66  if(data[6] != nullPixel)
67  {
68  divisor += (*theKernel)[2][0];
69  result += (*theKernel)[2][0] * data[6];
70  }
71  if(data[7] != nullPixel)
72  {
73  divisor += (*theKernel)[2][1];
74  result += (*theKernel)[2][1] * data[7];
75  }
76  if(data[8] != nullPixel)
77  {
78  divisor += (*theKernel)[2][2];
79  result += (*theKernel)[2][2] * data[8];
80  }
81 
82 
83  if(divisor > 0)
84  result /= divisor;
85 }

◆ convolve() [2/2]

void ossimDiscrete3x3HatFilter::convolve ( const unsigned char *  data,
double &  result,
ossim_uint8  nullPixel = OSSIM_DEFAULT_NULL_PIX_UINT8 
) const
virtual

Reimplemented from ossimDiscreteConvolutionKernel.

Definition at line 151 of file ossimDiscrete3x3HatFilter.cpp.

154 {
155  double divisor = 0;
156  result = 0;
157 
158  if(data[0] != nullPixel)
159  {
160  divisor += (*theKernel)[0][0];
161  result += (*theKernel)[0][0] * data[0];
162  }
163  if(data[1] != nullPixel)
164  {
165  divisor += (*theKernel)[0][1];
166  result += (*theKernel)[0][1] * data[1];
167  }
168  if(data[2] != nullPixel)
169  {
170  divisor += (*theKernel)[0][2];
171  result += (*theKernel)[0][2] * data[2];
172  }
173  if(data[3] != nullPixel)
174  {
175  divisor += (*theKernel)[1][0];
176  result += (*theKernel)[1][0] * data[3];
177  }
178  if(data[4] != nullPixel)
179  {
180  divisor += (*theKernel)[1][1];
181  result += (*theKernel)[1][1] * data[4];
182  }
183  if(data[5] != nullPixel)
184  {
185  divisor += (*theKernel)[1][2];
186  result += (*theKernel)[1][2] * data[5];
187  }
188  if(data[6] != nullPixel)
189  {
190  divisor += (*theKernel)[2][0];
191  result += (*theKernel)[2][0] * data[6];
192  }
193  if(data[7] != nullPixel)
194  {
195  divisor += (*theKernel)[2][1];
196  result += (*theKernel)[2][1] * data[7];
197  }
198  if(data[8] != nullPixel)
199  {
200  divisor += (*theKernel)[2][2];
201  result += (*theKernel)[2][2] * data[8];
202  }
203 
204 
205  if(divisor > 0)
206  result /= divisor;
207 }

◆ convolveSubImage() [1/2]

void ossimDiscrete3x3HatFilter::convolveSubImage ( const float *  data,
long  dataWidth,
double &  result,
float  nullPixel = OSSIM_DEFAULT_NULL_PIX_FLOAT 
) const
virtual

Reimplemented from ossimDiscreteConvolutionKernel.

Definition at line 87 of file ossimDiscrete3x3HatFilter.cpp.

91 {
92  double divisor = 0.0;
93  result = 0;
94 
95  if(data[0] != nullPixel)
96  {
97  divisor += (*theKernel)[0][0];
98  result += (*theKernel)[0][0]*data[0];
99  }
100  if(data[1] != nullPixel)
101  {
102  divisor += (*theKernel)[0][1];
103  result += (*theKernel)[0][1]*data[1];
104  }
105  if(data[2] != nullPixel)
106  {
107  divisor += (*theKernel)[0][2];
108  result += (*theKernel)[0][2]*data[2];
109  }
110 
111  data +=dataWidth;
112  if(data[0] != nullPixel)
113  {
114  divisor += (*theKernel)[1][0];
115  result += (*theKernel)[1][0]*data[0];
116  }
117  if(data[1] != nullPixel)
118  {
119  divisor += (*theKernel)[1][1];
120  result += (*theKernel)[1][1]*data[1];
121  }
122  if(data[2] != nullPixel)
123  {
124  divisor += (*theKernel)[1][2];
125  result += (*theKernel)[1][2]*data[2];
126  }
127 
128  data +=dataWidth;
129  if(data[0] != nullPixel)
130  {
131  divisor += (*theKernel)[2][0];
132  result += (*theKernel)[2][0]*data[0];
133  }
134  if(data[1] != nullPixel)
135  {
136  divisor += (*theKernel)[2][1];
137  result += (*theKernel)[2][1]*data[1];
138  }
139  if(data[2] != nullPixel)
140  {
141  divisor += (*theKernel)[2][2];
142  result += (*theKernel)[2][2]*data[2];
143  }
144 
145  if(divisor > 0)
146  {
147  result /= divisor;
148  }
149 }

◆ convolveSubImage() [2/2]

void ossimDiscrete3x3HatFilter::convolveSubImage ( const unsigned char *  data,
long  dataWidth,
double &  result,
ossim_uint8  nullPixel = OSSIM_DEFAULT_NULL_PIX_UINT8 
) const
virtual

this allows you to pass a subImage to the convolution engine. It needs to know the width of the buffer so it can increment to the next element.

Reimplemented from ossimDiscreteConvolutionKernel.

Definition at line 210 of file ossimDiscrete3x3HatFilter.cpp.

214 {
215  double divisor = 0.0;
216  result = 0;
217 
218  if(data[0] != nullPixel)
219  {
220  divisor += (*theKernel)[0][0];
221  result += (*theKernel)[0][0]*data[0];
222  }
223  if(data[1] != nullPixel)
224  {
225  divisor += (*theKernel)[0][1];
226  result += (*theKernel)[0][1]*data[1];
227  }
228  if(data[2] != nullPixel)
229  {
230  divisor += (*theKernel)[0][2];
231  result += (*theKernel)[0][2]*data[2];
232  }
233 
234  data +=dataWidth;
235  if(data[0] != nullPixel)
236  {
237  divisor += (*theKernel)[1][0];
238  result += (*theKernel)[1][0]*data[0];
239  }
240  if(data[1] != nullPixel)
241  {
242  divisor += (*theKernel)[1][1];
243  result += (*theKernel)[1][1]*data[1];
244  }
245  if(data[2] != nullPixel)
246  {
247  divisor += (*theKernel)[1][2];
248  result += (*theKernel)[1][2]*data[2];
249  }
250 
251  data +=dataWidth;
252  if(data[0] != nullPixel)
253  {
254  divisor += (*theKernel)[2][0];
255  result += (*theKernel)[2][0]*data[0];
256  }
257  if(data[1] != nullPixel)
258  {
259  divisor += (*theKernel)[2][1];
260  result += (*theKernel)[2][1]*data[1];
261  }
262  if(data[2] != nullPixel)
263  {
264  divisor += (*theKernel)[2][2];
265  result += (*theKernel)[2][2]*data[2];
266  }
267 
268  if(divisor > 0)
269  {
270  result /= divisor;
271  }
272 }

The documentation for this class was generated from the following files: