OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimFilterTable.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // License: LGPL
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: Garrett Potts
8 //
9 //----------------------------------------------------------------------------
10 // $Id: ossimFilterTable.cpp 23604 2015-10-28 13:40:09Z gpotts $
11 #include <iostream>
14 
16  :theWeights(0),
17  theWidth(0),
18  theHeight(0),
19  theWidthHeight(0),
20  theXSupport(0),
21  theYSupport(0),
22  theFilterSteps(0)
23 {
24 
25 }
26 
28 {
29  if(theWeights)
30  {
31  delete [] theWeights;
32  theWeights = 0;
33  }
34 }
35 
37  const ossimFilter& filter)
38 {
39  buildTable(filterSteps, filter, filter);
40 }
41 
43  const ossimFilter& xFilter,
44  const ossimFilter& yFilter)
45 {
46  ossim_int32 subpixelSample=0;
47  ossim_int32 subpixelLine=0;
48  double dx = 0.0;
49  double dy = 0.0;
50  double kernelH = 0.0;
51  double kernelV = 0.0;
52  double x = 0;
53  double y = 0;
54 
55  double xsupport = ceil(xFilter.getSupport());
56  double ysupport = ceil(yFilter.getSupport());
57  double left = 0;
58  double right = 0;
59  double top = 0;
60  double bottom = 0;
61 
62  theXSupport = (ossim_uint32)xsupport;
63  theYSupport = (ossim_uint32)ysupport;
64  theFilterSteps = filterSteps;
65  theWidth = (2*theXSupport);
66  theHeight = (2*theYSupport);
68 
70  left = -(xsupport-1);
71  right = xsupport;
72  top = -(ysupport-1);
73  bottom = ysupport;
74  ossim_uint32 idx = 0;
75 
76  for (subpixelLine = 0; subpixelLine < (int)filterSteps;
77  subpixelLine++)
78  {
79 
80  // Calculate subpixel sample step.
81  // ----------------------------------
82  dy = subpixelLine / (double)(filterSteps);
83  for (subpixelSample = 0; subpixelSample < (int)filterSteps; subpixelSample++)
84  {
85 
86  // Calculate subpixel sample step.
87  // ----------------------------------
88  dx = subpixelSample / (double)(filterSteps);
89 
90  for (kernelV=top; kernelV<=bottom;
91  kernelV++)
92  {
93  y = kernelV - dy;
94  double tempWeight = yFilter.filter(y, yFilter.getSupport());
95  for(kernelH=left; kernelH<=right;++kernelH)
96  {
97  x = kernelH - dx;
98 
99  // Get the weight for the current pixel.
100  // ----------------------------------------
101  theWeights[idx] = tempWeight*xFilter.filter(x, xFilter.getSupport());
102  ++idx;
103  }
104  }
105  }
106  }
107 }
108 
110 {
111  return theWidthHeight;
112 }
113 
115 {
116  return theXSupport;
117 }
118 
120 {
121  return theYSupport;
122 }
123 
125 {
126  return theWidth;
127 }
128 
130 {
131  return theHeight;
132 }
133 
135 {
136  if(theWeights)
137  {
138  delete [] theWeights;
139  theWeights = 0;
140  }
141 
143 
144  if(size)
145  {
146  theWeights = new double[size];
147  }
148 }
ossim_uint32 theYSupport
ossim_uint32 x
ossim_uint32 theWidthHeight
virtual double getSupport() const =0
void allocateWeights()
Creates the weight array "theWeights".
ossim_uint32 theHeight
ossim_uint32 y
ossim_uint32 getXSupport() const
ossim_uint32 theWidth
~ossimFilterTable()
destructor
ossim_uint32 theXSupport
ossim_uint32 getWidth() const
yy_size_t size
unsigned int ossim_uint32
ossim_uint32 theFilterSteps
ossim_uint32 getHeight() const
ossimFilterTable()
default constructor
virtual double filter(double x, double support) const =0
ossim_uint32 getYSupport() const
void buildTable(ossim_uint32 filterSteps, const ossimFilter &filter)
Builds a table with filter being used in both x and y direction.
ossim_uint32 getWidthByHeight() const
int ossim_int32