OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimAtbPointSource.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // AUTHOR: Oscar Kramer (okramer@imagelinks.com)
6 //
7 // DESCRIPTION: Contains implementation of class ossimAtbPointSource.
8 // This object provides the statistics associated with a given point on a
9 // given image corresponding to a matchpoint. A matchpoint contains a
10 // collection of these point sources, one for each contributing image.
11 //
12 // LIMITATIONS: None.
13 //
14 //*****************************************************************************
15 // $Id: ossimAtbPointSource.cpp 15766 2009-10-20 12:37:09Z gpotts $
16 
23 
24 //***
25 // Define Trace flags for use within this file:
26 //***
27 #include <ossim/base/ossimTrace.h>
28 static ossimTrace traceExec ("ossimImageSource:exec");
29 static ossimTrace traceDebug ("ossimImageSource:debug");
30 
31 static const int DEFAULT_KERNEL_SIZE = 18; // recommend odd number
32 
33 //*****************************************************************************
34 // DEFAULT CONSTRUCTOR: ossimAtbPointSource
35 //
36 //*****************************************************************************
38  : theRemapSource (0),
39  theGridRemapEngine (0),
40  theKernelSize (DEFAULT_KERNEL_SIZE),
41  theViewPointIsValid (false)
42 {
43  static const char MODULE[] = "ossimAtbPointSource Default Constructor";
44  if (traceExec()) CLOG << "entering..." << endl;
45 
46  if (traceExec()) CLOG << "returning..." << endl;
47 }
48 
49 
50 //*****************************************************************************
51 // CONSTRUCTOR: ossimAtbPointSource(image_source)
52 //
53 //*****************************************************************************
55  const ossimDpt& view_point)
56  : theRemapSource (source),
57  theGridRemapEngine (source->getRemapEngine()),
58  theKernelSize (DEFAULT_KERNEL_SIZE),
59  theViewPointIsValid (false)
60 {
61  static const char MODULE[] = "ossimAtbPointSource Default Constructor";
62  if (traceExec()) CLOG << "entering..." << endl;
63 
64  setViewPoint(view_point);
65 
66  if (traceExec()) CLOG << "returning..." << endl;
67 }
68 
69 
70 //*****************************************************************************
71 // DESTRUCTOR: ~ossimAtbPointSource()
72 //
73 //*****************************************************************************
75 {
76 }
77 
78 //*****************************************************************************
79 // METHOD: ossimAtbPointSource::setRemapSource()
80 //
81 // Sets the pointer to the source of pixels used to compute the stats.
82 //
83 //*****************************************************************************
85 {
86  static const char MODULE[] = "ossimAtbPointSource::setRemapSource()";
87  if (traceExec()) CLOG << "entering..." << endl;
88 
89  theRemapSource = source;
90 
91  //***
92  // Also fetch the remap engine which should be a derived ossimAtbRemapEngine:
93  //***
95 
96  if (traceExec()) CLOG << "returning..." << endl;
97  return;
98 }
99 
100 
101 //*****************************************************************************
102 // METHOD: ossimAtbPointSource::setViewPoint()
103 //
104 // Sets the view coordinates corresponding to this point.
105 //
106 //*****************************************************************************
108 {
109  static const char MODULE[] = "ossimAtbPointSource::setViewPoint()";
110  if (traceExec()) CLOG << "entering..." << endl;
111 
112  theViewPoint = view_point;
113 
114  if ((theRemapSource.valid()) &&
116  theViewPointIsValid = true;
117  else
118  theViewPointIsValid = false;
119 
120  if (traceExec()) CLOG << "returning..." << endl;
121  return;
122 }
123 
124 
125 //*****************************************************************************
126 // METHOD: ossimAtbPointSource::getSourceValue()
127 //
128 // Returns the computed value vector corresponding to the region about the
129 // view point. The definition of "value" is implemented by theGridRemapEngine.
130 //
131 //*****************************************************************************
132 void ossimAtbPointSource::getSourceValue(void* value_vector)
133 {
134  static const char MODULE[] = "ossimAtbPointSource::getSourceValue()";
135  if (traceExec()) CLOG << "entering..." << endl;
136 
137  //***
138  // Verify that members are initialized before processing:
139  //***
141  {
142  CLOG <<"ERROR: This object was not properly initialized before attempting"
143  <<" to compute target value! Returning usassigned vector..."<<endl;
144  return;
145  }
146 
147  //***
148  // Extract the data kernel from the image chain:
149  //***
150  ossimIpt kernel_2d_size (theKernelSize, theKernelSize);
151  ossimIpt kernel_ul (theViewPoint - kernel_2d_size/2.0);
152  ossimIpt kernel_lr (kernel_ul.x + kernel_2d_size.x - 1,
153  kernel_ul.y + kernel_2d_size.y - 1);
154  ossimIrect kernel_rect (kernel_ul, kernel_lr);
155  ossimRefPtr<ossimImageData> kernel_data =
156  theRemapSource->getTile(kernel_rect);
157 
158  //***
159  // Fetch the value of the data kernel. Note: this is not necessarily in
160  // the same color space as the pixels. It depends on which engine is being
161  // utilized:
162  //***
163  theGridRemapEngine->computeSourceValue(kernel_data, value_vector);
164 
165 // delete kernel_data;
166 
167  if (traceExec()) CLOG << "returning..." << endl;
168  return;
169 }
170 
171 
172 //*****************************************************************************
173 // METHOD: ossimAtbPointSource:: setKernelSize(N)
174 //
175 // Method to set the kernel size used in computing statistics. The kernel
176 // will be resized to NxN.
177 //
178 //*****************************************************************************
180 {
181  static const char MODULE[] = "ossimAtbPointSource::setKernelSize()";
182  if (traceExec()) CLOG << "entering..." << endl;
183 
184  theKernelSize = side_size;
185 
186  if (traceExec()) CLOG << "returning..." << endl;
187  return;
188 }
189 
190 
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
#define CLOG
Definition: ossimTrace.h:23
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &origin, ossim_uint32 resLevel=0)
ossimGridRemapEngine * getRemapEngine()
ossimRefPtr< ossimGridRemapEngine > theGridRemapEngine
bool valid() const
Definition: ossimRefPtr.h:75
void setRemapSource(ossimGridRemapSource *image_source)
ossimRefPtr< ossimGridRemapSource > theRemapSource
void getSourceValue(void *value)
void setViewPoint(const ossimDpt &view_point)
void setKernelSize(int side_size)
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
virtual void computeSourceValue(ossimRefPtr< ossimImageData > &source, void *result)=0
bool pointWithin(const ossimIpt &pt) const
Definition: ossimIrect.h:729