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

#include <ossimHsvGridRemapEngine.h>

Inheritance diagram for ossimHsvGridRemapEngine:
ossimGridRemapEngine ossimObject ossimReferenced

Public Member Functions

 ossimHsvGridRemapEngine ()
 
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: ossimHsvGridRemapEngine

Definition at line 29 of file ossimHsvGridRemapEngine.h.

Constructor & Destructor Documentation

◆ ossimHsvGridRemapEngine()

ossimHsvGridRemapEngine::ossimHsvGridRemapEngine ( )
inline

Definition at line 32 of file ossimHsvGridRemapEngine.h.

Referenced by dup().

Member Function Documentation

◆ assignRemapValues()

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

Implements ossimGridRemapEngine.

Definition at line 157 of file ossimHsvGridRemapEngine.cpp.

159 {
160  static const char MODULE[] = "ossimHsvGridRemapEngine::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  // HSV 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 ossimHsvGridRemapEngine::computeRemapNode ( ossimAtbPointSource point_source,
void *  source_value,
void *  target_value 
)
protectedvirtual

Implements ossimGridRemapEngine.

Definition at line 255 of file ossimHsvGridRemapEngine.cpp.

258 {
259  static const char MODULE[] = "ossimHsvGridRemapEngine::computeRemapNode";
260  if (traceExec()) CLOG << "entering..." << endl;
261 
262  //***
263  // Compute the remap grid node value specific to this HSV implementation:
264  //***
265  double node[3];
266  node[0] = ((double*)target_value)[0] - ((double*)source_value)[0];
267  node[1] = ((double*)target_value)[1] - ((double*)source_value)[1];
268  node[2] = ((double*)target_value)[2] - ((double*)source_value)[2];
269 
270  //***
271  // Fetch a pointer to the remapper feeding this point source in order to
272  // pass it the node value:
273  //***
274  ossimGridRemapSource* remapper = ps->getRemapSource();
275  remapper->setGridNode(ps->getViewPoint(), node);
276 
277  if (traceExec()) CLOG << "returning..." << endl;
278  return;
279 }
#define CLOG
Definition: ossimTrace.h:23
void setGridNode(const ossimDpt &view_pt, const double *value)

◆ computeSourceValue()

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

Implements ossimGridRemapEngine.

Definition at line 221 of file ossimHsvGridRemapEngine.cpp.

223 {
224  static const char MODULE[]="ossimHsvGridRemapEngine::computeSourceValue";
225  if (traceExec()) CLOG << "entering..." << endl;
226 
227  //***
228  // This engine defines "value" as the HSV vector corresponding to the mean
229  // RGB pixel value of the source data:
230  //***
231  ossimRgbVector rgb_vector;
232  rgb_vector.setR((unsigned char) source->computeAverageBandValue(0));
233  rgb_vector.setG((unsigned char) source->computeAverageBandValue(1));
234  rgb_vector.setB((unsigned char) source->computeAverageBandValue(2));
235 
236  //***
237  // Assign the HSV components to the result vector:
238  //***
239  ossimHsvVector hsv_vector (rgb_vector);
240  ((double*)result)[0] = (double) hsv_vector.getH();
241  ((double*)result)[1] = (double) hsv_vector.getS();
242  ((double*)result)[2] = (double) hsv_vector.getV();
243 
244  if (traceExec()) CLOG << "returning..." << endl;
245  return;
246 }
#define CLOG
Definition: ossimTrace.h:23
void setR(unsigned char R)
void setB(unsigned char B)
virtual ossim_float64 computeAverageBandValue(ossim_uint32 bandNumber=0) const
This will compute the average value for the band.
void setG(unsigned char G)

◆ dup()

ossimObject * ossimHsvGridRemapEngine::dup ( ) const
virtual

Implements ossimGridRemapEngine.

Definition at line 43 of file ossimHsvGridRemapEngine.cpp.

References ossimHsvGridRemapEngine().

44 {
45  return new ossimHsvGridRemapEngine;
46 }

◆ remapTile()

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

Implements ossimGridRemapEngine.

Definition at line 52 of file ossimHsvGridRemapEngine.cpp.

55 {
56  static const char MODULE[] = "ossimHsvGridRemapEngine::remapTile";
57  if (traceExec()) CLOG << "entering..." << endl;
58 
59  //***
60  // Fetch tile size and NULL pixel value:
61  //***
62  int width = tile->getWidth();
63  int height = tile->getHeight();
64  int offset = 0;
65 
66  void* red_buf = tile->getBuf(0);
67  void* grn_buf = tile->getBuf(1);
68  void* blu_buf = tile->getBuf(2);
69 
70  ossimDblGrid& gridH = *(remapper->getGrid(0));
71  ossimDblGrid& gridS = *(remapper->getGrid(1));
72  ossimDblGrid& gridV = *(remapper->getGrid(2));
73 
74  //---
75  // Remap according to pixel type:
76  //---
77  switch(tile->getScalarType())
78  {
79  case OSSIM_UINT8:
80  {
81  for (double line=origin.line; line<origin.line+height; line+=1.0)
82  {
83  for (double samp=origin.samp; samp<origin.samp+width; samp+=1.0)
84  {
85  //---
86  // Fetch pixel from the input tile band buffers and convert
87  // to HSV:
88  //---
89  ossimRgbVector rgb_pixel (((ossim_uint8*)red_buf)[offset],
90  ((ossim_uint8*)grn_buf)[offset],
91  ((ossim_uint8*)blu_buf)[offset]);
92  ossimHsvVector hsv_pixel (rgb_pixel);
93 
94  //---
95  // Remap pixel HSV with spatially variant bias value:
96  //---
97  hsv_pixel.setH(hsv_pixel.getH() + gridH(samp,line));
98  hsv_pixel.setS(hsv_pixel.getS() + gridS(samp,line));
99  hsv_pixel.setV(hsv_pixel.getV() + gridV(samp,line));
100 
101  //---
102  // Convert back to RGB and write to the tile:
103  //---
104  rgb_pixel = hsv_pixel; // auto-clamped
105  ((ossim_uint8*)red_buf)[offset] = rgb_pixel.getR();
106  ((ossim_uint8*)grn_buf)[offset] = rgb_pixel.getG();
107  ((ossim_uint8*)blu_buf)[offset] = rgb_pixel.getB();
108 
109  offset++;
110  }
111  }
112  break;
113  }
114 
115  case OSSIM_USHORT11:
116  case OSSIM_USHORT12:
117  case OSSIM_USHORT13:
118  case OSSIM_USHORT14:
119  case OSSIM_USHORT15:
120  break;
121 
122  case OSSIM_UINT16:
123  break;
124 
125  case OSSIM_SINT16:
126  break;
127 
128  case OSSIM_FLOAT64:
129  break;
130 
132  break;
133 
134  case OSSIM_FLOAT32:
135  break;
136 
138  break;
139 
141  default:
142  break;
143 
144  } // end switch statement
145 
146  if (traceExec()) CLOG << "returning..." << endl;
147  return;
148 };
16 bit unsigned integer (15 bits used)
virtual ossim_uint32 getWidth() const
64 bit floating point
#define CLOG
Definition: ossimTrace.h:23
16 bit unsigned integer
16 bit signed integer
virtual ossim_uint32 getHeight() const
16 bit unsigned integer (14 bits used)
16 bit unsigned integer (13 bits used)
32 bit floating point
32 bit normalized floating point
ossimDblGrid * getGrid(unsigned int index)
virtual ossimScalarType getScalarType() const
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
virtual const void * getBuf() const
8 bit unsigned integer
unsigned char ossim_uint8
16 bit unsigned integer (12 bits used)

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