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

#include <ossimRgbGridRemapEngine.h>

Inheritance diagram for ossimRgbGridRemapEngine:
ossimGridRemapEngine ossimObject ossimReferenced

Public Member Functions

 ossimRgbGridRemapEngine ()
 
virtual ossimObjectdup () const
 
virtual void remapTile (const ossimDpt &origin_point, ossimGridRemapSource *remapper, ossimRefPtr< ossimImageData > &tile)
 
virtual void assignRemapValues (std::vector< ossimAtbPointSource *> &sources)
 
virtual void computeSourceValue (ossimRefPtr< ossimImageData > &source, void *result)
 
- Public Member Functions inherited from ossimGridRemapEngine
int getNumberOfParams () const
 
int getNumberOfBands () const
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Protected Member Functions

virtual void computeRemapNode (ossimAtbPointSource *point_source, void *source_value, void *target_value)
 
- Protected Member Functions inherited from ossimGridRemapEngine
 ossimGridRemapEngine (int numParams, int numBands)
 
 ossimGridRemapEngine ()
 
virtual ~ossimGridRemapEngine ()
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Additional Inherited Members

- Protected Attributes inherited from ossimGridRemapEngine
int theNumberOfParams
 
int theNumberOfBands
 

Detailed Description


CLASS: ossimRgbGridRemapEngine

Definition at line 29 of file ossimRgbGridRemapEngine.h.

Constructor & Destructor Documentation

◆ ossimRgbGridRemapEngine()

ossimRgbGridRemapEngine::ossimRgbGridRemapEngine ( )
inline

Definition at line 32 of file ossimRgbGridRemapEngine.h.

Referenced by dup().

Member Function Documentation

◆ assignRemapValues()

void ossimRgbGridRemapEngine::assignRemapValues ( std::vector< ossimAtbPointSource *> &  sources)
virtual

Implements ossimGridRemapEngine.

Definition at line 157 of file ossimRgbGridRemapEngine.cpp.

159 {
160  static const char MODULE[] = "ossimRgbGridRemapEngine::assignRemapValues";
161  if (traceExec()) CLOG << "entering..." << endl;
162 
163  int i; // index to individual sources
164 
165  //***
166  // Declare a 2D array that will contain all of the contributing sources'
167  // RGB mean values. Also declare the accumulator target vector.
168  //***
169  int num_contributors = (int)sources_list.size();
170  double** contributor_pixel = new double* [num_contributors];
171  for (i=0; i<num_contributors; i++)
172  contributor_pixel[i] = new double[3];
173  double target_pixel[3] = {0.0, 0.0, 0.0};
174 
175  //***
176  // Now loop over each remaining contributor and sum in its contribution:
177  //***
178  vector<ossimAtbPointSource*>::iterator source;
179  i = 0;
180  for(source=sources_list.begin();
181  source!=sources_list.end();
182  source++)
183  {
184  (*source)->getSourceValue(contributor_pixel[i]);
185 
186  target_pixel[0] += contributor_pixel[i][0]/(double)num_contributors;
187  target_pixel[1] += contributor_pixel[i][1]/(double)num_contributors;
188  target_pixel[2] += contributor_pixel[i][2]/(double)num_contributors;
189 
190  i++;
191  }
192 
193  //***
194  // The target pixel has been established. Now need to compute the actual
195  // remap quantities that will be written to the appropriate remap grids:
196  //***
197  i = 0;
198  for(source=sources_list.begin();
199  source!=sources_list.end();
200  source++)
201  {
202  computeRemapNode(*source, contributor_pixel[i], target_pixel);
203  i++;
204  }
205 
206  //***
207  // Delete locally allocated memory:
208  //***
209  for (i=0; i<num_contributors; i++)
210  delete [] contributor_pixel[i];
211  delete [] contributor_pixel;
212 
213  if (traceExec()) CLOG << "returning..." << endl;
214  return;
215 }
#define CLOG
Definition: ossimTrace.h:23
virtual void computeRemapNode(ossimAtbPointSource *point_source, void *source_value, void *target_value)

◆ computeRemapNode()

void ossimRgbGridRemapEngine::computeRemapNode ( ossimAtbPointSource point_source,
void *  source_value,
void *  target_value 
)
protectedvirtual

Implements ossimGridRemapEngine.

Definition at line 246 of file ossimRgbGridRemapEngine.cpp.

249 {
250  static const char MODULE[] = "ossimRgbGridRemapEngine::computeRemapNode";
251  if (traceExec()) CLOG << "entering..." << endl;
252 
253  //***
254  // Compute the remap grid node value specific to this RGB implementation:
255  //***
256  double node[3];
257  node[0] = ((double*)target_value)[0] - ((double*)source_value)[0];
258  node[1] = ((double*)target_value)[1] - ((double*)source_value)[1];
259  node[2] = ((double*)target_value)[2] - ((double*)source_value)[2];
260 
261  //***
262  // Fetch a pointer to the remapper feeding this point source in order to
263  // pass it the node value:
264  //***
265  ossimGridRemapSource* remapper = ps->getRemapSource();
266  remapper->setGridNode(ps->getViewPoint(), node);
267 
268  if (traceExec()) CLOG << "returning..." << endl;
269  return;
270 }
#define CLOG
Definition: ossimTrace.h:23
void setGridNode(const ossimDpt &view_pt, const double *value)

◆ computeSourceValue()

void ossimRgbGridRemapEngine::computeSourceValue ( ossimRefPtr< ossimImageData > &  source,
void *  result 
)
virtual

Implements ossimGridRemapEngine.

Definition at line 221 of file ossimRgbGridRemapEngine.cpp.

223 {
224  static const char MODULE[]="ossimRgbGridRemapEngine::computeSourceValue";
225  if (traceExec()) CLOG << "entering..." << endl;
226 
227  //***
228  // This engine defines "value" as the RGB vector corresponding to the mean
229  // RGB pixel value of the source data:
230  //***
231  ((double*)result)[0] = source->computeAverageBandValue(0);
232  ((double*)result)[1] = source->computeAverageBandValue(1);
233  ((double*)result)[2] = source->computeAverageBandValue(2);
234 
235  if (traceExec()) CLOG << "returning..." << endl;
236  return;
237 }
#define CLOG
Definition: ossimTrace.h:23
virtual ossim_float64 computeAverageBandValue(ossim_uint32 bandNumber=0) const
This will compute the average value for the band.

◆ dup()

ossimObject * ossimRgbGridRemapEngine::dup ( ) const
virtual

Implements ossimGridRemapEngine.

Definition at line 41 of file ossimRgbGridRemapEngine.cpp.

References ossimRgbGridRemapEngine().

42 {
43  return new ossimRgbGridRemapEngine;
44 }

◆ remapTile()

void ossimRgbGridRemapEngine::remapTile ( const ossimDpt origin_point,
ossimGridRemapSource remapper,
ossimRefPtr< ossimImageData > &  tile 
)
virtual

Implements ossimGridRemapEngine.

Definition at line 50 of file ossimRgbGridRemapEngine.cpp.

53 {
54  static const char MODULE[] = "ossimRgbGridRemapEngine::remapTile";
55  if (traceExec()) CLOG << "entering..." << endl;
56 
57  //***
58  // Fetch tile size and NULL pixel value:
59  //***
60  int width = tile->getWidth();
61  int height = tile->getHeight();
62  int offset = 0;
63  double null[3];
64 
65  //***
66  // Determine null pixel values so that we can recognize a null coming in and
67  // not remap it:
68  //***
69  null[0] = tile->getNullPix(0);
70  null[1] = tile->getNullPix(1);
71  null[2] = tile->getNullPix(2);
72 
73  ossimDblGrid& gridR = *(remapper->getGrid(0));
74  ossimDblGrid& gridG = *(remapper->getGrid(1));
75  ossimDblGrid& gridB = *(remapper->getGrid(2));
76 
77  //***
78  // Remap according to pixel type:
79  //***
80  switch(tile->getScalarType())
81  {
82  case OSSIM_UCHAR:
83  {
84  ossim_uint8* red_buf = (ossim_uint8*)tile->getBuf(0);
85  ossim_uint8* grn_buf = (ossim_uint8*)tile->getBuf(1);
86  ossim_uint8* blu_buf = (ossim_uint8*)tile->getBuf(2);
87  short pixel_buffer[3];
88 
89  for (double line=origin.line; line<origin.line+height; line+=1.0)
90  {
91  for (double samp=origin.samp; samp<origin.samp+width; samp+=1.0)
92  {
93  //***
94  // Scan for null pixel before adding remap delta:
95  //***
96  if ((red_buf[offset] != (ossim_uint8) null[0]) &&
97  (grn_buf[offset] != (ossim_uint8) null[1]) &&
98  (blu_buf[offset] != (ossim_uint8) null[2]))
99  {
100  //***
101  // Remap RGB pixel with spatially variant bias value:
102  //***
103  pixel_buffer[0] = red_buf[offset] + (short) gridR(samp,line);
104  pixel_buffer[1] = grn_buf[offset] + (short) gridG(samp,line);
105  pixel_buffer[2] = blu_buf[offset] + (short) gridB(samp,line);
106 
107  //***
108  // Clamp:
109  //***
110  if (pixel_buffer[0]<0) red_buf[offset] = 0;
111  else if (pixel_buffer[0]>255) red_buf[offset] = 255;
112  else red_buf[offset] = pixel_buffer[0];
113 
114 
115  if (pixel_buffer[1]<0) grn_buf[offset] = 0;
116  else if (pixel_buffer[1]>255) grn_buf[offset] = 255;
117  else grn_buf[offset] = pixel_buffer[1];
118 
119 
120  if (pixel_buffer[2]<0) blu_buf[offset] = 0;
121  else if (pixel_buffer[2]>255) blu_buf[offset] = 255;
122  else blu_buf[offset] = pixel_buffer[2];
123 
124  //***
125  // Avoid NULLS:
126  //***
127  if (red_buf[offset] == (ossim_uint8) null[0]) red_buf[offset]++;
128  if (grn_buf[offset] == (ossim_uint8) null[1]) grn_buf[offset]++;
129  if (blu_buf[offset] == (ossim_uint8) null[2]) blu_buf[offset]++;
130  }
131 
132  offset++;
133  }
134  }
135  break;
136  }
137 
138  default:
139  {
140  ossimNotify(ossimNotifyLevel_WARN) << "WARNING ossimRgbGridRemapEngine::remapTile: Scalar type not handled" << std::endl;
141  break;
142  }
143 
144  } // end switch statement
145 
146  if (traceExec()) CLOG << "returning..." << endl;
147  return;
148 };
virtual ossim_uint32 getWidth() const
#define CLOG
Definition: ossimTrace.h:23
virtual ossim_uint32 getHeight() const
virtual const ossim_float64 * getNullPix() const
ossimDblGrid * getGrid(unsigned int index)
virtual ossimScalarType getScalarType() const
virtual const void * getBuf() const
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
8 bit unsigned iteger

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