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

#include <ossimFilterResampler.h>

Public Types

enum  ossimFilterResamplerType {
  ossimFilterResampler_NEAREST_NEIGHBOR = 0, ossimFilterResampler_BOX = 1, ossimFilterResampler_GAUSSIAN = 2, ossimFilterResampler_CUBIC = 3,
  ossimFilterResampler_HANNING = 4, ossimFilterResampler_HAMMING = 5, ossimFilterResampler_LANCZOS = 6, ossimFilterResampler_MITCHELL = 7,
  ossimFilterResampler_CATROM = 8, ossimFilterResampler_BLACKMAN = 9, ossimFilterResampler_BLACKMAN_SINC = 10, ossimFilterResampler_BLACKMAN_BESSEL = 11,
  ossimFilterResampler_QUADRATIC = 12, ossimFilterResampler_TRIANGLE = 13, ossimFilterResampler_BILINEAR = 13, ossimFilterResampler_HERMITE = 14,
  ossimFilterResampler_BELL = 15, ossimFilterResampler_BSPLINE = 16, ossimFilterResampler_MAGIC = 17
}
 

Public Member Functions

 ossimFilterResampler ()
 
virtual ~ossimFilterResampler ()
 
virtual void resample (const ossimRefPtr< ossimImageData > &input, ossimRefPtr< ossimImageData > &output, const ossimDpt &ul, const ossimDpt &ur, const ossimDpt &deltaUl, const ossimDpt &deltaUr, const ossimDpt &length)
 
virtual void resample (const ossimRefPtr< ossimImageData > &input, ossimRefPtr< ossimImageData > &output, const ossimIrect &outputSubRect, const ossimDpt &ul, const ossimDpt &ur, const ossimDpt &deltaUl, const ossimDpt &deltaUr, const ossimDpt &length)
 
void setFilterType (ossimFilterResamplerType filterType)
 
void setFilterType (ossimFilterResamplerType minifyFilterType, ossimFilterResamplerType magnifyFilterType)
 
void setFilterType (const ossimString &type)
 
void setFilterType (const ossimString &minifyType, const ossimString &magnifyType)
 
void setMinifyFilterType (const ossimString &minifyType)
 
void setMagnifyFilterType (const ossimString &magnifyType)
 
void setMinifyFilterType (ossimFilterResamplerType filterType)
 
void setMagnifyFilterType (ossimFilterResamplerType filterType)
 
ossimString getMinifyFilterTypeAsString () const
 
ossimString getMagnifyFilterTypeAsString () const
 
void setScaleFactor (const ossimDpt &scale)
 
void setBlurFactor (ossim_float64 blur)
 
void setBoundingInputRect (const ossimIrect &rect)
 
ossimIrect getBoundingInputRect () const
 
ossim_float64 getBlurFactor () const
 
const ossimDptgetScaleFactor () const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual void getKernelSupport (double &x, double &y) const
 
virtual void getFilterTypes (std::vector< ossimString > &filterTypes) const
 

Private Member Functions

const ossimFiltergetHorizontalFilter () const
 
const ossimFiltergetVerticalFilter () const
 
template<class T >
void resampleBilinearTile (T dummy, const ossimRefPtr< ossimImageData > &input, ossimRefPtr< ossimImageData > &output, const ossimIrect &outputSubRect, const ossimDpt &inputUl, const ossimDpt &inputUr, const ossimDpt &deltaUl, const ossimDpt &deltaUr, const ossimDpt &outLength)
 
void computeTable ()
 
ossimString getFilterTypeAsString (ossimFilterResamplerType type) const
 
ossimFilterResamplerType getFilterType (const ossimString &type) const
 
ossimFiltercreateNewFilter (ossimFilterResamplerType filterType, ossimFilterResamplerType &result)
 

Private Attributes

ossimFiltertheMinifyFilter
 
ossimFiltertheMagnifyFilter
 
ossimFilterTable theFilterTable
 
ossimFilterResamplerType theMinifyFilterType
 
ossimFilterResamplerType theMagnifyFilterType
 
ossimDpt theScaleFactor
 
ossimDpt theInverseScaleFactor
 
ossimIrect theInputRect
 
ossim_float64 theBlurFactor
 

Detailed Description

Definition at line 24 of file ossimFilterResampler.h.

Member Enumeration Documentation

◆ ossimFilterResamplerType

Enumerator
ossimFilterResampler_NEAREST_NEIGHBOR 
ossimFilterResampler_BOX 
ossimFilterResampler_GAUSSIAN 
ossimFilterResampler_CUBIC 
ossimFilterResampler_HANNING 
ossimFilterResampler_HAMMING 
ossimFilterResampler_LANCZOS 
ossimFilterResampler_MITCHELL 
ossimFilterResampler_CATROM 
ossimFilterResampler_BLACKMAN 
ossimFilterResampler_BLACKMAN_SINC 
ossimFilterResampler_BLACKMAN_BESSEL 
ossimFilterResampler_QUADRATIC 
ossimFilterResampler_TRIANGLE 
ossimFilterResampler_BILINEAR 
ossimFilterResampler_HERMITE 
ossimFilterResampler_BELL 
ossimFilterResampler_BSPLINE 
ossimFilterResampler_MAGIC 

Definition at line 27 of file ossimFilterResampler.h.

28  {
48 
49  };

Constructor & Destructor Documentation

◆ ossimFilterResampler()

ossimFilterResampler::ossimFilterResampler ( )

Definition at line 25 of file ossimFilterResampler.cpp.

References ossimPreferences::instance(), loadState(), and setScaleFactor().

30  theScaleFactor(1.0, 1.0),
31  theInverseScaleFactor(1.0, 1.0),
32  theBlurFactor(1.0)
33 {
34  setScaleFactor(ossimDpt(1.0, 1.0));
35  loadState(ossimPreferences::instance()->preferencesKWL(),"resampler.");
36 
37 }
void setScaleFactor(const ossimDpt &scale)
ossimFilterResamplerType theMagnifyFilterType
static ossimPreferences * instance()
ossimFilterResamplerType theMinifyFilterType
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)

◆ ~ossimFilterResampler()

ossimFilterResampler::~ossimFilterResampler ( )
virtual

Definition at line 39 of file ossimFilterResampler.cpp.

References theMagnifyFilter, and theMinifyFilter.

40 {
41  if(theMinifyFilter)
42  {
43  delete theMinifyFilter;
44  theMinifyFilter = NULL;
45  }
47  {
48  delete theMagnifyFilter;
49  theMagnifyFilter = NULL;
50  }
51 }

Member Function Documentation

◆ computeTable()

void ossimFilterResampler::computeTable ( )
private

Definition at line 945 of file ossimFilterResampler.cpp.

References ossimFilterTable::buildTable(), theFilterTable, and theMagnifyFilter.

Referenced by setFilterType().

946 {
948 }
ossimFilterTable theFilterTable
void buildTable(ossim_uint32 filterSteps, const ossimFilter &filter)
Builds a table with filter being used in both x and y direction.

◆ createNewFilter()

ossimFilter * ossimFilterResampler::createNewFilter ( ossimFilterResamplerType  filterType,
ossimFilterResamplerType result 
)
private

Definition at line 213 of file ossimFilterResampler.cpp.

References ossimFilterResampler_BELL, ossimFilterResampler_BLACKMAN, ossimFilterResampler_BLACKMAN_BESSEL, ossimFilterResampler_BLACKMAN_SINC, ossimFilterResampler_BOX, ossimFilterResampler_BSPLINE, ossimFilterResampler_CATROM, ossimFilterResampler_CUBIC, ossimFilterResampler_GAUSSIAN, ossimFilterResampler_HAMMING, ossimFilterResampler_HANNING, ossimFilterResampler_HERMITE, ossimFilterResampler_LANCZOS, ossimFilterResampler_MAGIC, ossimFilterResampler_MITCHELL, ossimFilterResampler_NEAREST_NEIGHBOR, ossimFilterResampler_QUADRATIC, and ossimFilterResampler_TRIANGLE.

Referenced by setFilterType().

216 {
217  switch(filterType)
218  {
220  {
221  return new ossimNearestNeighborFilter();
222  }
224  {
225  return new ossimBoxFilter();
226  }
228  {
229  return new ossimGaussianFilter();
230  }
232  {
233  return new ossimCubicFilter();
234  }
236  {
237  return new ossimHanningFilter();
238  }
240  {
241  return new ossimHammingFilter();
242  }
244  {
245  return new ossimLanczosFilter();
246  }
248  {
249  return new ossimCatromFilter();
250  }
252  {
253  return new ossimMitchellFilter();
254  }
256  {
257  return new ossimBlackmanFilter();
258  }
260  {
261  return new ossimBlackmanSincFilter();
262  }
264  {
265  return new ossimBlackmanBesselFilter();
266  }
268  {
269  return new ossimQuadraticFilter();
270  }
272  {
273  return new ossimTriangleFilter();
274  }
276  {
277  return new ossimHermiteFilter();
278  }
280  {
281  return new ossimGaussianFilter();
282  }
284  {
285  return new ossimBSplineFilter();
286  }
288  {
289  return new ossimBSplineFilter();
290  }
291  }
292 
294  return new ossimNearestNeighborFilter();
295 }

◆ getBlurFactor()

ossim_float64 ossimFilterResampler::getBlurFactor ( ) const

Definition at line 868 of file ossimFilterResampler.cpp.

References theBlurFactor.

869 {
870  return theBlurFactor;
871 }

◆ getBoundingInputRect()

ossimIrect ossimFilterResampler::getBoundingInputRect ( ) const
inline

Definition at line 90 of file ossimFilterResampler.h.

91  {
92  return theInputRect;
93  }

◆ getFilterType()

ossimFilterResampler::ossimFilterResamplerType ossimFilterResampler::getFilterType ( const ossimString type) const
private

Definition at line 665 of file ossimFilterResampler.cpp.

References ossimString::contains(), ossimFilterResampler_BLACKMAN, ossimFilterResampler_BLACKMAN_BESSEL, ossimFilterResampler_BLACKMAN_SINC, ossimFilterResampler_BOX, ossimFilterResampler_BSPLINE, ossimFilterResampler_CATROM, ossimFilterResampler_CUBIC, ossimFilterResampler_GAUSSIAN, ossimFilterResampler_HAMMING, ossimFilterResampler_HANNING, ossimFilterResampler_HERMITE, ossimFilterResampler_LANCZOS, ossimFilterResampler_MAGIC, ossimFilterResampler_MITCHELL, ossimFilterResampler_NEAREST_NEIGHBOR, ossimFilterResampler_QUADRATIC, ossimFilterResampler_TRIANGLE, and ossimString::upcase().

Referenced by setFilterType(), setMagnifyFilterType(), and setMinifyFilterType().

666 {
667  ossimString typeUpper = type;
668  typeUpper = typeUpper.upcase();
669 
670  if(typeUpper.contains("BOX"))
671  {
673  }
674  else if(typeUpper.contains("NEAREST"))
675  {
677  }
678  else if(typeUpper.contains("GAUSSIAN"))
679  {
681  }
682  else if(typeUpper.contains("HANNING"))
683  {
685  }
686  else if(typeUpper.contains("HAMMING"))
687  {
689  }
690  else if(typeUpper.contains("LANCZOS"))
691  {
693  }
694  else if(typeUpper.contains("MITCHELL"))
695  {
697  }
698  else if(typeUpper.contains("CATROM"))
699  {
701  }
702  else if(typeUpper.contains("CUBIC"))
703  {
705  }
706  else if(typeUpper.contains("BESSEL"))
707  {
709  }
710  else if(typeUpper.contains("SINC"))
711  {
713  }
714  else if(typeUpper.contains("BLACKMAN"))
715  {
717  }
718  else if(typeUpper.contains("QUADRATIC"))
719  {
721  }
722  else if(typeUpper.contains("TRIANGLE"))
723  {
725  }
726  else if(typeUpper.contains("BILINEAR"))
727  {
729  }
730  else if(typeUpper.contains("HERMITE"))
731  {
733  }
734 // else if(typeUpper.contains("BELL"))
735 // {
736 // return ossimFilterResampler_BELL;
737 // }
738  else if(typeUpper.contains("BSPLINE"))
739  {
741  }
742  else if(typeUpper.contains("MAGIC"))
743  {
745  }
746 
748 }
static ossimString upcase(const ossimString &aString)
Definition: ossimString.cpp:34
bool contains(char aChar) const
Definition: ossimString.h:58

◆ getFilterTypeAsString()

ossimString ossimFilterResampler::getFilterTypeAsString ( ossimFilterResamplerType  type) const
private

Definition at line 561 of file ossimFilterResampler.cpp.

References ossimFilterResampler_BELL, ossimFilterResampler_BLACKMAN, ossimFilterResampler_BLACKMAN_BESSEL, ossimFilterResampler_BLACKMAN_SINC, ossimFilterResampler_BOX, ossimFilterResampler_BSPLINE, ossimFilterResampler_CATROM, ossimFilterResampler_CUBIC, ossimFilterResampler_GAUSSIAN, ossimFilterResampler_HAMMING, ossimFilterResampler_HANNING, ossimFilterResampler_HERMITE, ossimFilterResampler_LANCZOS, ossimFilterResampler_MAGIC, ossimFilterResampler_MITCHELL, ossimFilterResampler_NEAREST_NEIGHBOR, ossimFilterResampler_QUADRATIC, and ossimFilterResampler_TRIANGLE.

Referenced by getMagnifyFilterTypeAsString(), getMinifyFilterTypeAsString(), and saveState().

562 {
563  switch(type)
564  {
566  {
567  return "nearest neighbor";
568  }
570  {
571  return "box";
572  }
574  {
575  return "gaussian";
576  }
578  {
579  return "cubic";
580  }
582  {
583  return "hanning";
584  }
586  {
587  return "hamming";
588  }
590  {
591  return "lanczos";
592  }
594  {
595  return "mitchell";
596  }
598  {
599  return "catrom";
600  }
602  {
603  return "blackman";
604  }
606  {
607  return "sinc";
608  }
610  {
611  return "bessel";
612  }
614  {
615  return "quadratic";
616  }
618  {
619  return "bilinear";
620  }
622  {
623  return "hermite";
624  }
626  {
627  return "gaussian";
628  }
630  {
631  return "bspline";
632  }
634  {
635  return "magic";
636  }
637  }
638 
639  return "nearest neighbor";
640 }

◆ getFilterTypes()

void ossimFilterResampler::getFilterTypes ( std::vector< ossimString > &  filterTypes) const
virtual

Definition at line 642 of file ossimFilterResampler.cpp.

Referenced by ossimImageRenderer::getProperty(), and ossimInfo::printResamplerFilters().

643 {
644  filterTypes.push_back("nearest neighbor");
645  filterTypes.push_back("bilinear");
646  filterTypes.push_back("cubic");
647 // filterTypes.push_back("bell");
648  filterTypes.push_back("bessel");
649  filterTypes.push_back("blackman");
650  filterTypes.push_back("box");
651  filterTypes.push_back("bspline");
652  filterTypes.push_back("catrom");
653  filterTypes.push_back("gaussian");
654  filterTypes.push_back("hanning");
655  filterTypes.push_back("hamming");
656  filterTypes.push_back("hermite");
657  filterTypes.push_back("lanczos");
658  filterTypes.push_back("mitchell");
659  filterTypes.push_back("quadratic");
660  filterTypes.push_back("sinc");
661  filterTypes.push_back("magic");
662 }

◆ getHorizontalFilter()

const ossimFilter * ossimFilterResampler::getHorizontalFilter ( ) const
private

Definition at line 778 of file ossimFilterResampler.cpp.

References theMagnifyFilter, theMinifyFilter, theScaleFactor, and ossimDpt::x.

Referenced by getKernelSupport().

779 {
780  if(theScaleFactor.x < 1)
781  {
782  return theMinifyFilter;
783  }
784 
785  return theMagnifyFilter;
786 }
double x
Definition: ossimDpt.h:164

◆ getKernelSupport()

void ossimFilterResampler::getKernelSupport ( double &  x,
double &  y 
) const
virtual

Definition at line 750 of file ossimFilterResampler.cpp.

References getHorizontalFilter(), ossimFilter::getSupport(), getVerticalFilter(), x, and y.

Referenced by ossimImageRenderer::fillTile().

751 {
752  const ossimFilter* horizontalFilter = getHorizontalFilter();
753  const ossimFilter* verticalFilter = getVerticalFilter();
754 
755  if(!horizontalFilter)
756  {
757  x = 0.0;
758  }
759  else
760  {
761 // x = theBlurFactor*ossim::max(1.0/theScaleFactor.x, 1.0)*
762 // horizontalFilter->getSupport();
763  x = horizontalFilter->getSupport();
764  }
765 
766  if(!verticalFilter)
767  {
768  y = 0.0;
769  }
770  else
771  {
772 // y = theBlurFactor*ossim::max(1.0/theScaleFactor.y, 1.0)*
773 // verticalFilter->getSupport();
774  y = verticalFilter->getSupport();
775  }
776 }
ossim_uint32 x
virtual double getSupport() const =0
ossim_uint32 y
const ossimFilter * getVerticalFilter() const
const ossimFilter * getHorizontalFilter() const

◆ getMagnifyFilterTypeAsString()

ossimString ossimFilterResampler::getMagnifyFilterTypeAsString ( ) const

Definition at line 840 of file ossimFilterResampler.cpp.

References getFilterTypeAsString(), and theMagnifyFilterType.

841 {
843 }
ossimString getFilterTypeAsString(ossimFilterResamplerType type) const
ossimFilterResamplerType theMagnifyFilterType

◆ getMinifyFilterTypeAsString()

ossimString ossimFilterResampler::getMinifyFilterTypeAsString ( ) const

Definition at line 835 of file ossimFilterResampler.cpp.

References getFilterTypeAsString(), and theMinifyFilterType.

Referenced by ossimImageRenderer::getProperty().

836 {
838 }
ossimString getFilterTypeAsString(ossimFilterResamplerType type) const
ossimFilterResamplerType theMinifyFilterType

◆ getScaleFactor()

const ossimDpt& ossimFilterResampler::getScaleFactor ( ) const
inline

Definition at line 97 of file ossimFilterResampler.h.

98  {
99  return theScaleFactor;
100  }

◆ getVerticalFilter()

const ossimFilter * ossimFilterResampler::getVerticalFilter ( ) const
private

Definition at line 788 of file ossimFilterResampler.cpp.

References theMagnifyFilter, theMinifyFilter, theScaleFactor, and ossimDpt::y.

Referenced by getKernelSupport().

789 {
790  if(theScaleFactor.y < 1)
791  {
792  return theMinifyFilter;
793  }
794 
795  return theMagnifyFilter;
796 }
double y
Definition: ossimDpt.h:165

◆ loadState()

bool ossimFilterResampler::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
virtual

Loads the state of this object.

Definition at line 901 of file ossimFilterResampler.cpp.

References ossimKeywordlist::find(), FLT_EPSILON, ossimKeywordNames::SCALE_X_KW, ossimKeywordNames::SCALE_Y_KW, setMagnifyFilterType(), setMinifyFilterType(), theInverseScaleFactor, theScaleFactor, ossimString::toDouble(), ossimDpt::x, and ossimDpt::y.

Referenced by ossimFilterResampler().

903 {
904  const char* lookup = 0;
905 
906  lookup = kwl.find(prefix, ossimKeywordNames::SCALE_X_KW);
907  if (lookup)
908  {
909  theScaleFactor.x = ossimString(lookup).toDouble();
910  }
911 
912  lookup = kwl.find(prefix, ossimKeywordNames::SCALE_Y_KW);
913  if (lookup)
914  {
915  theScaleFactor.y = ossimString(lookup).toDouble();
916  }
917 
918  lookup = kwl.find(prefix, "minify_type");
919  if (lookup)
920  {
921  setMinifyFilterType(lookup);
922  }
923 
924  lookup = kwl.find(prefix, "magnify_type");
925  if (lookup)
926  {
927  setMagnifyFilterType(lookup);
928  }
929 
930  if(fabs(theScaleFactor.x) <= FLT_EPSILON)
931  {
932  theScaleFactor.x = 1.0;
933  }
934  if(fabs(theScaleFactor.y) <= FLT_EPSILON)
935  {
936  theScaleFactor.y = 1.0;
937  }
938 
941 
942  return true;
943 }
const char * find(const char *key) const
double y
Definition: ossimDpt.h:165
static const char * SCALE_X_KW
static const char * SCALE_Y_KW
#define FLT_EPSILON
double toDouble() const
void setMinifyFilterType(const ossimString &minifyType)
void setMagnifyFilterType(const ossimString &magnifyType)
double x
Definition: ossimDpt.h:164

◆ resample() [1/2]

void ossimFilterResampler::resample ( const ossimRefPtr< ossimImageData > &  input,
ossimRefPtr< ossimImageData > &  output,
const ossimDpt ul,
const ossimDpt ur,
const ossimDpt deltaUl,
const ossimDpt deltaUr,
const ossimDpt length 
)
virtual

Definition at line 54 of file ossimFilterResampler.cpp.

References ossimImageData::getImageRectangle().

Referenced by ossimImageCacheTileSource::fillTile(), and ossimImageRenderer::fillTile().

61 {
62  resample(input,
63  output,
64  output->getImageRectangle(),
65  ul,
66  ur,
67  deltaUl,
68  deltaUr,
69  length);
70 }
virtual ossimIrect getImageRectangle() const
virtual void resample(const ossimRefPtr< ossimImageData > &input, ossimRefPtr< ossimImageData > &output, const ossimDpt &ul, const ossimDpt &ur, const ossimDpt &deltaUl, const ossimDpt &deltaUr, const ossimDpt &length)

◆ resample() [2/2]

void ossimFilterResampler::resample ( const ossimRefPtr< ossimImageData > &  input,
ossimRefPtr< ossimImageData > &  output,
const ossimIrect outputSubRect,
const ossimDpt ul,
const ossimDpt ur,
const ossimDpt deltaUl,
const ossimDpt deltaUr,
const ossimDpt length 
)
virtual

Definition at line 72 of file ossimFilterResampler.cpp.

References ossimImageData::getBuf(), ossimRectilinearDataObject::getScalarType(), OSSIM_FLOAT32, OSSIM_FLOAT64, OSSIM_NORMALIZED_DOUBLE, OSSIM_NORMALIZED_FLOAT, OSSIM_SINT16, OSSIM_SINT32, OSSIM_SINT8, OSSIM_UINT16, OSSIM_UINT32, OSSIM_UINT8, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, OSSIM_USHORT15, ossimNotify(), ossimNotifyLevel_WARN, resampleBilinearTile(), and ossimRefPtr< T >::valid().

80 {
81  if(!input.valid() ||
82  !output.valid() ||
83  !input->getBuf() ||
84  !output->getBuf())
85  {
86  return;
87  }
88 
89  ossimScalarType scalarType = input->getScalarType();
90  switch(scalarType)
91  {
92  case OSSIM_UINT8:
93  {
94  resampleBilinearTile(ossim_uint8(0), // dummy template variable
95  input,
96  output,
97  outputSubRect,
98  ul,
99  ur,
100  deltaUl,
101  deltaUr,
102  length);
103  break;
104  }
105  case OSSIM_SINT8:
106  {
107  resampleBilinearTile(ossim_sint8(0), // dummy template variable
108  input,
109  output,
110  outputSubRect,
111  ul,
112  ur,
113  deltaUl,
114  deltaUr,
115  length);
116  break;
117  }
118  case OSSIM_UINT16:
119  case OSSIM_USHORT11:
120  case OSSIM_USHORT12:
121  case OSSIM_USHORT13:
122  case OSSIM_USHORT14:
123  case OSSIM_USHORT15:
124  {
125  resampleBilinearTile(ossim_uint16(0), // dummy template variable
126  input,
127  output,
128  outputSubRect,
129  ul,
130  ur,
131  deltaUl,
132  deltaUr,
133  length);
134  break;
135  }
136  case OSSIM_SINT16:
137  {
138  resampleBilinearTile(ossim_sint16(0), // dummy template variable
139  input,
140  output,
141  outputSubRect,
142  ul,
143  ur,
144  deltaUl,
145  deltaUr,
146  length);
147  break;
148  }
149  case OSSIM_UINT32:
150  {
151  resampleBilinearTile(ossim_uint32(0), // dummy template variable
152  input,
153  output,
154  outputSubRect,
155  ul,
156  ur,
157  deltaUl,
158  deltaUr,
159  length);
160  break;
161  }
162  case OSSIM_SINT32:
163  {
164  resampleBilinearTile(ossim_sint32(0), // dummy template variable
165  input,
166  output,
167  outputSubRect,
168  ul,
169  ur,
170  deltaUl,
171  deltaUr,
172  length);
173  break;
174  }
175  case OSSIM_FLOAT32:
177  {
178  resampleBilinearTile(ossim_float32(0.0), // dummy template variable
179  input,
180  output,
181  outputSubRect,
182  ul,
183  ur,
184  deltaUl,
185  deltaUr,
186  length);
187  break;
188  }
189  case OSSIM_FLOAT64:
191  {
192  resampleBilinearTile(ossim_float64(0.0), // dummy template variable
193  input,
194  output,
195  outputSubRect,
196  ul,
197  ur,
198  deltaUl,
199  deltaUr,
200  length);
201  break;
202  }
203  default:
204  {
206  << "ossimFilterResampler::resample error: unknown scalar type: "
207  << scalarType << endl;
208  }
209  }
210 }
16 bit unsigned integer (15 bits used)
8 bit signed integer
64 bit floating point
16 bit unsigned integer
bool valid() const
Definition: ossimRefPtr.h:75
float ossim_float32
16 bit signed integer
16 bit unsigned integer (14 bits used)
signed char ossim_sint8
16 bit unsigned integer (13 bits used)
32 bit floating point
unsigned short ossim_uint16
32 bit unsigned integer
double ossim_float64
signed short ossim_sint16
32 bit signed integer
unsigned int ossim_uint32
32 bit normalized floating point
signed int ossim_sint32
ossimScalarType
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
void resampleBilinearTile(T dummy, const ossimRefPtr< ossimImageData > &input, ossimRefPtr< ossimImageData > &output, const ossimIrect &outputSubRect, const ossimDpt &inputUl, const ossimDpt &inputUr, const ossimDpt &deltaUl, const ossimDpt &deltaUr, const ossimDpt &outLength)
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
16 bit unsigned integer (12 bits used)

◆ resampleBilinearTile()

template<class T >
void ossimFilterResampler::resampleBilinearTile ( dummy,
const ossimRefPtr< ossimImageData > &  input,
ossimRefPtr< ossimImageData > &  output,
const ossimIrect outputSubRect,
const ossimDpt inputUl,
const ossimDpt inputUr,
const ossimDpt deltaUl,
const ossimDpt deltaUr,
const ossimDpt outLength 
)
private

Definition at line 313 of file ossimFilterResampler.cpp.

References FLT_EPSILON, ossimImageData::getBuf(), ossimFilterTable::getClosestWeights(), ossimFilterTable::getHeight(), ossimImageData::getImageRectangle(), ossimImageData::getMaxPix(), ossimImageData::getMinPix(), ossimImageData::getNullPix(), ossimImageData::getNumberOfBands(), ossimImageData::getSizePerBand(), ossimFilterTable::getWidth(), ossimImageData::getWidth(), ossimFilterTable::getXSupport(), ossimFilterTable::getYSupport(), ossimIrect::height(), theFilterTable, ossimIrect::ul(), ossimIrect::width(), ossimIpt::x, ossimDpt::x, ossimIpt::y, and ossimDpt::y.

Referenced by resample().

323 {
324 #if 0 /* Please leave for debug. */
325  std::cout << "INPUT = \n" << *input << std::endl
326  << "OUTPUT = \n" << *output << std::endl
327  << "inputUL= " << inputUl << std::endl
328  << "inputUR= " << inputUr << std::endl
329  << "deltaUL= " << deltaUl << std::endl
330  << "deltaUr= " << deltaUr << std::endl
331  << "outlength= " << outLength << std::endl;
332 #endif
333 
334  ossim_uint32 band, centerOffset;
335  ossim_float64 tmpFlt64, stepSizeWidth;
336 
337  if(outLength.x>1) {
338  stepSizeWidth = 1.0/(outLength.x-1.0);
339  } else {
340  stepSizeWidth = 1.0;
341  }
342 
343  // INPUT INFORMATION
344  ossim_uint32 inWidth = input->getWidth();
345  ossim_uint32 inBandSize = input->getSizePerBand(); // fix for out-of-bounds check OLK 06/2005
346  ossim_uint32 BANDS = input->getNumberOfBands();
347  ossimIrect inputRect = input->getImageRectangle();
348 
349  // OUTPUT INFORMATION
350  const ossim_float64* NULL_PIX = output->getNullPix();
351  const ossim_float64* MIN_PIX = output->getMinPix();
352  const ossim_float64* MAX_PIX = output->getMaxPix();
353  ossimIrect outputRect = output->getImageRectangle();
354  ossim_uint32 resultRectH = outputSubRect.height();
355  ossim_uint32 resultRectW = outputSubRect.width();
356  ossim_uint32 outputRectW = outputRect.width();
357 
358  // calculate the offset into the data so we can refer to it at 0 index.
359  ossim_uint32 resultOffset=(outputSubRect.ul().y - outputRect.ul().y)*outputRectW +
360  (outputSubRect.ul().x - outputRect.ul().x);
361 
362  // make a local copy of the band pointers (at resultOffset)
363  ossim_float64 *densityvals=new ossim_float64[BANDS];
364  ossim_float64 *pixelvals=new ossim_float64[BANDS];
365  const T* *inputBuf = new const T*[BANDS];
366  T* *resultBuf = new T*[BANDS];
367  if(!pixelvals||!inputBuf||!resultBuf)
368  {
369  return;
370  }
371 
372  for(band = 0; band < BANDS; ++band)
373  {
374  inputBuf[band] = static_cast<const T*>(input->getBuf(band));
375  resultBuf[band] = static_cast<T*>(output->getBuf(band))+resultOffset;
376  }
377 
378  // FILTER INFORMAION
379  ossim_uint32 xkernel_width = theFilterTable.getWidth();;
380  ossim_uint32 ykernel_height = theFilterTable.getHeight();
381  double xkernel_half_width = theFilterTable.getXSupport();
382  double ykernel_half_height = theFilterTable.getYSupport();
383 
384  double initialx = inputUl.x-inputRect.ul().x;
385  double initialy = inputUl.y-inputRect.ul().y;
386  double terminalx = inputUr.x-inputRect.ul().x;
387  double terminaly = inputUr.y-inputRect.ul().y;
388  double pointx,pointy,deltaX,deltaY;
389  ossim_int32 starty,startx;
390 
391  if(xkernel_width==0 || ykernel_height==0)
392  {
393  // USING NEAREST NEIGHBOR
394  for(ossim_uint32 resultY = 0; resultY < resultRectH; ++resultY)
395  {
396 // deltaX = (terminalx-initialx) * stepSizeWidth;
397 // deltaY = (terminaly-initialy) * stepSizeHeight;
398  // this should be stepsize width for both since we are traversing horizontal
399  deltaX = (terminalx-initialx) * stepSizeWidth;
400  deltaY = (terminaly-initialy) * stepSizeWidth;
401  pointx = initialx;
402  pointy = initialy;
403  for(ossim_uint32 resultX = 0; resultX < resultRectW; ++resultX)
404  {
405  // just sample center in input space.
406  centerOffset = ossim::round<int>(pointy)*inWidth + ossim::round<int>(pointx);
407  for(band=0;band<BANDS;++band)
408  {
409  resultBuf[band][resultX] = inputBuf[band][centerOffset];
410  }
411  pointy += deltaY;
412  pointx += deltaX;
413  } // End of loop in x direction.
414 
415  // increment pointers to where we are now.
416  for(band=0;band<BANDS;++band)
417  {
418  resultBuf[band] += outputRectW;
419  }
420  initialx += deltaUl.x;
421  initialy += deltaUl.y;
422  terminalx += deltaUr.x;
423  terminaly += deltaUr.y;
424  } // End of loop in y direction.
425 
426  }
427  else
428  {
429  // USING A KERNEL
430  const double* kernel;
431  ossim_uint32 iy,ix,sourceIndex,nullCount;
432  for(ossim_uint32 resultY = 0; resultY < resultRectH; ++resultY)
433  {
434  deltaX = (terminalx-initialx) * stepSizeWidth;
435  deltaY = (terminaly-initialy) * stepSizeWidth;
436  pointx = initialx;
437  pointy = initialy;
438  for(ossim_uint32 resultX = 0; resultX < resultRectW; ++resultX)
439  {
440  starty = ossim::round<int>(pointy - ykernel_half_height + .5);
441  startx = ossim::round<int>(pointx - xkernel_half_width + .5);
442  centerOffset = ossim::round<int>(pointy)*inWidth + ossim::round<int>(pointx);
443  sourceIndex = starty*inWidth+startx;
444 
445  // look at center pixel, make sure they aren't all null.
446  nullCount=0;
447  if(centerOffset<inBandSize)
448  {
449  for (band=0;band<BANDS;++band)
450  {
451  if(inputBuf[band][centerOffset]==static_cast<T>(NULL_PIX[band]))
452  {
453  ++nullCount;
454  }
455  }
456  // the center of the kernel is outside the input space, just set null.
457  }
458  else
459  {
460  nullCount=BANDS;
461  }
462 
463  // make sure we have non-null data and we fit within the inputBuf.
464  if ( nullCount==BANDS || (sourceIndex>=inBandSize))
465  {
466  // we don't need to continue, just assign null!
467  for (band=0;band<BANDS;++band)
468  {
469  resultBuf[band][resultX] = static_cast<T>(NULL_PIX[band]);
470  }
471  }
472  else
473  {
474  kernel = theFilterTable.getClosestWeights(pointx,pointy);
475  if(kernel)
476  {
477  // reset the pixel/density sums for each band to zero.
478  memset(densityvals,'\0',sizeof(ossim_float64)*BANDS);
479  memset(pixelvals,'\0',sizeof(ossim_float64)*BANDS);
480 
481  // apply kernel to input space.
482  for (iy=0;((iy<ykernel_height)&&(sourceIndex<inBandSize));++iy)
483  {
484  for (ix = 0;((ix<xkernel_width)&&(sourceIndex<inBandSize));++ix)
485  {
486  tmpFlt64=*kernel; // pixel weight;
487  for(band=0;band<BANDS;++band)
488  {
489  if(inputBuf[band][sourceIndex]!=NULL_PIX[band])
490  {
491  densityvals[band] += tmpFlt64;
492  pixelvals[band] += (inputBuf[band][sourceIndex]*tmpFlt64);
493  }
494  }
495  ++sourceIndex;
496  ++kernel;
497  if(sourceIndex>=inBandSize)
498  {
499  break;
500  }
501  }
502  sourceIndex+=(inWidth-xkernel_width);
503  }
504 
505  // actually assign the value to the output
506  for (band = 0; band < BANDS; ++band)
507  {
508  if(densityvals[band]<=FLT_EPSILON)
509  {
510  //---
511  // Setting tempFlt64 to pixelvals[band] causing 0's where -32768
512  // should be when null check was skipped above.
513  // tmpFlt64 = pixelvals[band];
514  //---
515  tmpFlt64 = NULL_PIX[band];
516  }
517  else
518  {
519  // normalize
520  tmpFlt64 = pixelvals[band]/densityvals[band];
521  }
522 
523  // clamp
524  tmpFlt64 = (tmpFlt64>=MIN_PIX[band]?(tmpFlt64<MAX_PIX[band]?tmpFlt64:MAX_PIX[band]):MIN_PIX[band]);
525  // set resultant pixel value.
526  resultBuf[band][resultX] = static_cast<T>(tmpFlt64);
527  }
528 
529  // we didn't get a filter kernel, just set NULL in this disaster.
530  }
531  else
532  {
533  for (band=0;band<BANDS;++band)
534  {
535  resultBuf[band][resultX] = static_cast<T>(NULL_PIX[band]);
536  }
537  }
538  }
539  pointy += deltaY;
540  pointx += deltaX;
541  } // End of loop in x direction.
542 
543  // increment pointers to where we are now.
544  for(band=0;band<BANDS;++band)
545  {
546  resultBuf[band] += outputRectW;
547  }
548  initialx += deltaUl.x;
549  initialy += deltaUl.y;
550  terminalx += deltaUr.x;
551  terminaly += deltaUr.y;
552  } // End of loop in y direction.
553  } // USING A KERNEL END
554 
555  delete [] densityvals;
556  delete [] pixelvals;
557  delete [] resultBuf;
558  delete [] inputBuf;
559 }
virtual ossim_uint32 getWidth() const
virtual const ossim_float64 * getMaxPix() const
virtual ossim_uint32 getNumberOfBands() const
ossim_uint32 getXSupport() const
double y
Definition: ossimDpt.h:165
ossim_uint32 height() const
Definition: ossimIrect.h:487
const ossimIpt & ul() const
Definition: ossimIrect.h:274
double ossim_float64
const double * getClosestWeights(const double &x, const double &y) const
Inlined below.
ossimFilterTable theFilterTable
ossim_uint32 getWidth() const
#define FLT_EPSILON
virtual ossim_uint32 getSizePerBand() const
Returns the number of pixels in a single band in a tile.
unsigned int ossim_uint32
virtual const ossim_float64 * getNullPix() const
virtual ossimIrect getImageRectangle() const
ossim_uint32 getHeight() const
ossim_uint32 width() const
Definition: ossimIrect.h:500
virtual const ossim_float64 * getMinPix() const
ossim_uint32 getYSupport() const
ossim_int32 y
Definition: ossimIpt.h:142
virtual const void * getBuf() const
double x
Definition: ossimDpt.h:164
ossim_int32 x
Definition: ossimIpt.h:141
int ossim_int32

◆ saveState()

bool ossimFilterResampler::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Saves the state of this object.

Definition at line 878 of file ossimFilterResampler.cpp.

References ossimKeywordlist::add(), getFilterTypeAsString(), ossimKeywordNames::SCALE_X_KW, ossimKeywordNames::SCALE_Y_KW, theMagnifyFilterType, theMinifyFilterType, theScaleFactor, ossimDpt::x, and ossimDpt::y.

Referenced by ossimImageRenderer::saveState().

880 {
881  kwl.add(prefix,
884  true);
885  kwl.add(prefix,
888  true);
889  kwl.add(prefix,
890  "minify_type",
892  true);
893  kwl.add(prefix,
894  "magnify_type",
896  true);
897 
898  return true;
899 }
double y
Definition: ossimDpt.h:165
static const char * SCALE_X_KW
static const char * SCALE_Y_KW
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
ossimString getFilterTypeAsString(ossimFilterResamplerType type) const
ossimFilterResamplerType theMagnifyFilterType
double x
Definition: ossimDpt.h:164
ossimFilterResamplerType theMinifyFilterType

◆ setBlurFactor()

void ossimFilterResampler::setBlurFactor ( ossim_float64  blur)

Definition at line 873 of file ossimFilterResampler.cpp.

References theBlurFactor.

874 {
875  theBlurFactor = blur;
876 }

◆ setBoundingInputRect()

void ossimFilterResampler::setBoundingInputRect ( const ossimIrect rect)
inline

Definition at line 86 of file ossimFilterResampler.h.

Referenced by ossimImageRenderer::fillTile().

87  {
88  theInputRect = rect;
89  }

◆ setFilterType() [1/4]

void ossimFilterResampler::setFilterType ( ossimFilterResamplerType  filterType)

Definition at line 803 of file ossimFilterResampler.cpp.

Referenced by ossimKakaduJpipHandler::getTile(), setFilterType(), setMagnifyFilterType(), setMinifyFilterType(), and ossimImageRenderer::setProperty().

804 {
805  setFilterType(filterType, filterType);
806 }
void setFilterType(ossimFilterResamplerType filterType)

◆ setFilterType() [2/4]

void ossimFilterResampler::setFilterType ( ossimFilterResamplerType  minifyFilterType,
ossimFilterResamplerType  magnifyFilterType 
)

Definition at line 845 of file ossimFilterResampler.cpp.

References computeTable(), createNewFilter(), theMagnifyFilter, theMagnifyFilterType, theMinifyFilter, and theMinifyFilterType.

848 {
849  if(theMinifyFilter)
850  {
851  delete theMinifyFilter;
852  theMinifyFilter = NULL;
853  }
854  if(theMagnifyFilter)
855  {
856  delete theMagnifyFilter;
857  theMagnifyFilter = NULL;
858  }
859 
860  theMinifyFilterType = minifyFilterType;
861  theMagnifyFilterType = magnifyFilterType;
862 
865  computeTable();
866 }
ossimFilterResamplerType theMagnifyFilterType
ossimFilter * createNewFilter(ossimFilterResamplerType filterType, ossimFilterResamplerType &result)
ossimFilterResamplerType theMinifyFilterType

◆ setFilterType() [3/4]

void ossimFilterResampler::setFilterType ( const ossimString type)

Definition at line 798 of file ossimFilterResampler.cpp.

References setFilterType().

799 {
800  setFilterType(type, type);
801 }
void setFilterType(ossimFilterResamplerType filterType)

◆ setFilterType() [4/4]

void ossimFilterResampler::setFilterType ( const ossimString minifyType,
const ossimString magnifyType 
)

Definition at line 807 of file ossimFilterResampler.cpp.

References getFilterType(), and setFilterType().

809 {
810  setFilterType(getFilterType(minifyType),
811  getFilterType(magnifyType));
812 }
void setFilterType(ossimFilterResamplerType filterType)
ossimFilterResamplerType getFilterType(const ossimString &type) const

◆ setMagnifyFilterType() [1/2]

void ossimFilterResampler::setMagnifyFilterType ( const ossimString magnifyType)

Definition at line 819 of file ossimFilterResampler.cpp.

References getFilterType().

Referenced by loadState().

820 {
821  setMagnifyFilterType(getFilterType(magnifyType));
822 }
ossimFilterResamplerType getFilterType(const ossimString &type) const
void setMagnifyFilterType(const ossimString &magnifyType)

◆ setMagnifyFilterType() [2/2]

void ossimFilterResampler::setMagnifyFilterType ( ossimFilterResamplerType  filterType)

Definition at line 830 of file ossimFilterResampler.cpp.

References setFilterType(), and theMinifyFilterType.

831 {
833 }
void setFilterType(ossimFilterResamplerType filterType)
ossimFilterResamplerType theMinifyFilterType

◆ setMinifyFilterType() [1/2]

void ossimFilterResampler::setMinifyFilterType ( const ossimString minifyType)

Definition at line 814 of file ossimFilterResampler.cpp.

References getFilterType().

Referenced by loadState().

815 {
816  setMinifyFilterType(getFilterType(minifyType));
817 }
ossimFilterResamplerType getFilterType(const ossimString &type) const
void setMinifyFilterType(const ossimString &minifyType)

◆ setMinifyFilterType() [2/2]

void ossimFilterResampler::setMinifyFilterType ( ossimFilterResamplerType  filterType)

Definition at line 824 of file ossimFilterResampler.cpp.

References setFilterType(), and theMagnifyFilterType.

825 {
826  setFilterType(filterType,
828 }
void setFilterType(ossimFilterResamplerType filterType)
ossimFilterResamplerType theMagnifyFilterType

◆ setScaleFactor()

void ossimFilterResampler::setScaleFactor ( const ossimDpt scale)

Definition at line 297 of file ossimFilterResampler.cpp.

References FLT_EPSILON, theInverseScaleFactor, theScaleFactor, ossimDpt::x, and ossimDpt::y.

Referenced by ossimImageRenderer::fillTile(), and ossimFilterResampler().

298 {
299  theScaleFactor = scale;
300  if(fabs(theScaleFactor.x) <= FLT_EPSILON)
301  {
302  theScaleFactor.x = 1.0;
303  }
304  if(fabs(theScaleFactor.y) <= FLT_EPSILON)
305  {
306  theScaleFactor.y = 1.0;
307  }
308 
311 }
double y
Definition: ossimDpt.h:165
#define FLT_EPSILON
double x
Definition: ossimDpt.h:164

Member Data Documentation

◆ theBlurFactor

ossim_float64 ossimFilterResampler::theBlurFactor
private

Definition at line 148 of file ossimFilterResampler.h.

Referenced by getBlurFactor(), and setBlurFactor().

◆ theFilterTable

ossimFilterTable ossimFilterResampler::theFilterTable
private

Definition at line 140 of file ossimFilterResampler.h.

Referenced by computeTable(), and resampleBilinearTile().

◆ theInputRect

ossimIrect ossimFilterResampler::theInputRect
private

Definition at line 147 of file ossimFilterResampler.h.

◆ theInverseScaleFactor

ossimDpt ossimFilterResampler::theInverseScaleFactor
private

Definition at line 145 of file ossimFilterResampler.h.

Referenced by loadState(), and setScaleFactor().

◆ theMagnifyFilter

ossimFilter* ossimFilterResampler::theMagnifyFilter
private

◆ theMagnifyFilterType

ossimFilterResamplerType ossimFilterResampler::theMagnifyFilterType
private

◆ theMinifyFilter

ossimFilter* ossimFilterResampler::theMinifyFilter
private

◆ theMinifyFilterType

ossimFilterResamplerType ossimFilterResampler::theMinifyFilterType
private

◆ theScaleFactor

ossimDpt ossimFilterResampler::theScaleFactor
private

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