33 static const char* RESAMPLER_CONVOLUTION_TYPE_KW =
"convolution_type";
34 static const char* RESAMPLER_SCALE_X_KW =
"scale_x";
35 static const char* RESAMPLER_SCALE_Y_KW =
"scale_y";
36 static const char* RESAMPLER_CUBIC_PARAMETER_KW =
"cubic_parameter";
40 theOutputToInputRatio(1,1),
41 theResamplerType(ossimResampler_NONE),
47 theWeightTableX(NULL),
48 theWeightTableY(NULL),
49 theCubicAdjustableParameter(-.5)
126 <<
"ossimResampler::resample error: unknown scalar type: " 264 <<
"ossimResampler::resample error: unknown scalar type: " 381 <<
"ossimResampler::resample error: unknown scalar type: " 439 double *h =
new double[maxInputSize];
440 int *Lx =
new int[maxOutputSize];
441 int *Ly =
new int[maxOutputSize];
457 for (k = 0; k < maxOutputSize; ++k)
459 Lx[k] = (
ossim_int32)(scaledOriginShift.x+((k+origin.
x)/
462 for (k = 0; k < maxOutputSize; ++k)
464 Ly[k] = (
ossim_int32)(scaledOriginShift.y+((k+origin.
y)/
469 const T* inputBuf =
static_cast<T*
>(input->
getBuf(band));
470 T* outputBuf =
static_cast<T*
>(output->
getBuf(band));
471 T minPix =
static_cast<T
>(input->
getMinPix(band));
472 T maxPix =
static_cast<T
>(input->
getMaxPix(band));
473 T np =
static_cast<T
>(input->
getNullPix(band));
475 for (k = 0; k < out_height; ++k)
479 if(indexMod <0) indexMod = 0;
480 for (j = 0; j < in_width; ++j)
487 ossim_int32 index = Ly[k] + l + kernelVerticalShift;
488 if ((index >= 0) && (index < in_height))
491 if(!input->
isNull(offset))
493 lastValue = (double)inputBuf[offset];
538 if(indexMod <0) indexMod = 0;
540 if(input->
isNull(
ossimIpt(Lx[m]-scaledOriginShift.x, Ly[k]-scaledOriginShift.y)))
542 outputBuf[k*out_width +m] = np;
548 ossim_int32 index = Lx[m] + l + kernelHorizontalShift;
549 if ((index >= 0) && (index < in_width))
580 outputBuf[k*out_width +m] =
static_cast<T
>(minPix);
584 outputBuf[k*out_width +m] =
static_cast<T
>(maxPix);
588 outputBuf[k*out_width +m] =
static_cast<T
>(
x);
608 double *h =
new double[maxInputSize];
626 for (k = 0; k < maxOutputSize; ++k)
628 Lx[k] = (
ossim_int32)(scaledOriginShift.x+((k+origin.
x)/
631 for (k = 0; k < maxOutputSize; ++k)
633 Ly[k] = (
ossim_int32)(scaledOriginShift.y+((k+origin.
y)/
638 const T* inputBuf = (
const T*)(input->
getBuf(band));
639 T* outputBuf = (T*)(output->
getBuf(band));
640 double minPix =
static_cast<T
>(input->
getMinPix()[band]);
641 double maxPix =
static_cast<T
>(input->
getMaxPix()[band]);
643 for (k = 0; k < out_height; ++k)
647 if(indexMod <0) indexMod = 0;
648 for (j = 0; j < in_width; ++j)
653 ossim_int32 index = Ly[k] + l + kernelVerticalShift;
654 if ((index >= 0) && (index < in_height))
656 h[j] += ((double)inputBuf[index*in_width +j]) *
666 if(indexMod <0) indexMod = 0;
670 ossim_int32 index = Lx[m] + l + kernelHorizontalShift;
671 if ((index >= 0) && (index < in_width))
679 outputBuf[k*out_width +m] =
static_cast<T
>(minPix);
683 outputBuf[k*out_width +m] =
static_cast<T
>(maxPix);
687 outputBuf[k*out_width +m] =
static_cast<T
>(
x);
729 ossimDpt newLl = newInputUl + newDeltaUl*outLength.
y;
730 ossimDpt newLr = newInputUr + newDeltaUr*outLength.
y;
741 origin = roundedRect.ul();
747 roundedRect.height());
754 double stepSizeWidth = 1.0/outLength.
x;
755 double stepSizeHeight = 1.0/outLength.
y;
759 newInputUl.
y - rect.
ul().
y );
761 newInputUr.
y - rect.
ul().
y);
765 long subRectH = outputSubRect.
height();
766 long subRectW = outputSubRect.
width();
768 ossimIpt outputRectUl = outputRect.ul();
769 long outputRectW = outputRect.width();
770 long resultOffset = (subRectUl.
y - outputRectUl.
y)*outputRectW + (subRectUl.
x - outputRectUl.
x);
774 T* resultBuf =
static_cast<T*
>(output->
getBuf(band))+resultOffset;
775 const T *sourceBuf =
static_cast<T*
>(dupIn->
getBuf(band));
780 for(
long y = 0;
y < subRectH; ++
y)
782 double deltaX = (end.
x - start.
x)*stepSizeWidth;
783 double deltaY = (end.
y - start.
y)*stepSizeHeight;
786 for(
long x = 0;
x < subRectW; ++
x)
788 int xPixel = pointXY.
x<0?(int)floor(pointXY.
x):(int)pointXY.
x;
789 int yPixel = pointXY.
y<0?(
int)floor(pointXY.
y):(int)pointXY.
y;
792 if( (xPixel >=0) && (xPixel < inWidth) &&
793 (yPixel >=0) && (yPixel < inHeight))
795 resultBuf[
x] = sourceBuf[yPixel*inWidth + xPixel];
805 resultBuf += outputRectW;
807 start.
x += newDeltaUl.
x;
808 start.
y += newDeltaUl.
y;
809 end.
x += newDeltaUr.
x;
810 end.
y += newDeltaUr.
y;
850 double stepSizeWidth = 1.0/length.
x;
851 double stepSizeHeight = 1.0/length.
y;
855 ul.
y - rect.
ul().
y );
864 long subRectH = outputSubRect.
height();
865 long subRectW = outputSubRect.
width();
867 ossimIpt outputRectUl = outputRect.ul();
868 long outputRectW = outputRect.width();
870 long resultOffset = (subRectUl.
y - outputRectUl.
y)*outputRectW + (subRectUl.
x - outputRectUl.
x);
873 T* resultBuf =
static_cast<T*
>(output->
getBuf(band))+resultOffset;
874 const T *sourceBuf =
static_cast<T*
>(input->
getBuf(band));
880 for(
long y = 0;
y < subRectH; ++
y)
882 double deltaX = (end.
x - start.
x)*stepSizeWidth;
883 double deltaY = (end.
y - start.
y)*stepSizeHeight;
886 for(
long x = 0;
x < subRectW; ++
x)
888 int xPixel = pointXY.
x<0?(int)floor(pointXY.
x):(int)pointXY.
x;
889 int yPixel = pointXY.
y<0?(
int)floor(pointXY.
y):(int)pointXY.
y;
892 if( (xPixel >=0) && (xPixel < inWidth) &&
893 (yPixel >=0) && (yPixel < inHeight))
895 T value = sourceBuf[yPixel*inWidth + xPixel];
899 resultBuf[
x] = value;
903 resultBuf[
x] = outNp;
908 resultBuf[
x] = outNp;
914 resultBuf += outputRectW;
916 start.
x += deltaUl.
x;
917 start.
y += deltaUl.
y;
1183 const char* resamplerType = kwl.
find(prefix, RESAMPLER_CONVOLUTION_TYPE_KW);
1184 const char* scaleX = kwl.
find(prefix, RESAMPLER_SCALE_X_KW);
1185 const char* scaleY = kwl.
find(prefix, RESAMPLER_SCALE_Y_KW);
1186 const char* cubicParameter= kwl.
find(prefix, RESAMPLER_CUBIC_PARAMETER_KW);
1202 if( test ==
"BICUBIC")
1206 else if( test ==
"BILINEAR")
1227 const char* prefix)
const 1232 resamplerType =
"BICUBIC";
1236 resamplerType =
"BILINEAR";
1240 resamplerType =
"NEAREST_NEIGHBOR";
1243 RESAMPLER_CONVOLUTION_TYPE_KW,
1244 resamplerType.
c_str(),
1248 RESAMPLER_SCALE_X_KW,
1253 RESAMPLER_SCALE_Y_KW,
1258 RESAMPLER_CUBIC_PARAMETER_KW,
virtual void resampleNearestNeighbor(ossimImageData *input, ossimImageData *output, const ossimIrect &outputSubRect, const ossimDpt &ul, const ossimDpt &ur, const ossimDpt &deltaUl, const ossimDpt &deltaUr, const ossimDpt &length)
16 bit unsigned integer (15 bits used)
ossimResLevelResamplerType
virtual ossim_uint32 getWidth() const
ossim_int32 theTableWidthY
virtual const ossim_float64 * getMaxPix() const
ossim_int32 theTableWidthX
static ossimString upcase(const ossimString &aString)
virtual ossim_uint32 getNumberOfBands() const
void resampleTile(T, ossimImageData *input, ossimImageData *output)
Represents serializable keyword/value map.
const char * find(const char *key) const
double nan()
Method to return ieee floating point double precision NAN.
const ossimDpt & ul() const
ossim_int32 theTableHeight
ossim_uint32 height() const
virtual void setResamplerType(ossimResLevelResamplerType type)
double theCubicAdjustableParameter
virtual void generateWeightTable()
void resampleFullTile(T, ossimImageData *input, ossimImageData *output)
const ossimIpt & ul() const
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual ossim_uint32 getHeight() const
16 bit unsigned integer (14 bits used)
virtual ossimResLevelResamplerType getResamplerType() const
16 bit unsigned integer (13 bits used)
unsigned short ossim_uint16
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
virtual void initialize()
Initialize the data buffer.
virtual ~ossimResampler()
bool isNull(ossim_uint32 offset) const
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
ossim_int32 theKernelWidth
double getCubicC2(double t) const
double ** theWeightTableX
virtual void resample(ossimImageData *input, ossimImageData *output)
signed short ossim_sint16
unsigned int ossim_uint32
virtual const ossim_float64 * getNullPix() const
32 bit normalized floating point
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
virtual ossimIrect getImageRectangle() const
double getCubicC0(double t) const
virtual ossim_int32 getKernelWidth() const
ossim_uint32 width() const
virtual void setOrigin(const ossimIpt &origin)
virtual const ossim_float64 * getMinPix() const
ossimDpt theOutputToInputRatio
virtual ossimScalarType getScalarType() const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
void setRatio(double outputToInputRatio)
double ** theWeightTableY
virtual const void * getBuf() const
double getCubicC1(double t) const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
double getCubicC3(double t) const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
void resampleTileNearestNeighbor(T, ossimImageData *input, ossimImageData *output, const ossimDpt &ul, const ossimDpt &ur, const ossimDpt &deltaUl, const ossimDpt &deltaUr, const ossimDpt &length)
#define RTTI_DEF1(cls, name, b1)
virtual void deleteWeightTable()
void resamplePartialTile(T, ossimImageData *input, ossimImageData *output)
const ossimDpt & lr() const
ossimResLevelResamplerType theResamplerType
virtual const ossimIpt & getOrigin() const
unsigned char ossim_uint8
virtual ossim_int32 getKernelHeight() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
virtual void allocateWeightTable()
ossim_int32 theKernelHeight
16 bit unsigned integer (12 bits used)
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.