33 #include "dcmtk/config/osconfig.h" 35 #include "dcmtk/ofstd/ofcast.h" 37 #include "dcmtk/dcmimgle/ditranst.h" 38 #include "dcmtk/dcmimgle/dipxrept.h" 45 #define SCALE_FACTOR 4096 46 #define HALFSCALE_FACTOR 2048 54 static inline void setScaleValues(Uint16 data[],
58 register Uint16 remainder = max % min;
59 Uint16 step0 = max / min;
60 Uint16 step1 = max / min;
61 if (remainder > OFstatic_cast(Uint16, min / 2))
63 remainder = min - remainder;
67 const double count = OFstatic_cast(
double, min) / (OFstatic_cast(
double, remainder) + 1);
69 register double c = count;
70 for (i = 0; i < min; ++i)
72 if ((i >= OFstatic_cast(Uint16, c)) && (remainder > 0))
85 static inline double cubicValue(
const double v1,
93 double dVal = 0.5 * ((((-v1 + 3 * v2 - 3 * v3 + v4) * dD + (2 * v1 - 5 * v2 + 4 * v3 - v4)) * dD + (-v1 + v3)) * dD + (v2 + v2));
94 return (dVal < minVal) ? minVal : ((dVal > maxVal) ? maxVal : dVal);
127 const Uint16 columns,
129 const signed long left_pos,
130 const signed long top_pos,
131 const Uint16 src_cols,
132 const Uint16 src_rows,
133 const Uint16 dest_cols,
134 const Uint16 dest_rows,
137 :
DiTransTemplate<T>(planes, src_cols, src_rows, dest_cols, dest_rows, frames, bits),
156 const Uint16 src_cols,
157 const Uint16 src_rows,
158 const Uint16 dest_cols,
159 const Uint16 dest_rows,
162 :
DiTransTemplate<T>(planes, src_cols, src_rows, dest_cols, dest_rows, frames, bits),
196 const int interpolate,
199 if ((src != NULL) && (dest != NULL))
201 DCMIMGLE_TRACE(
"Col/Rows: " <<
Columns <<
" " <<
Rows << OFendl
202 <<
"Left/Top: " <<
Left <<
" " <<
Top << OFendl
203 <<
"Src X/Y: " << this->
Src_X <<
" " << this->
Src_Y << OFendl
204 <<
"Dest X/Y: " << this->
Dest_X <<
" " << this->
Dest_Y);
205 if ((
Left + OFstatic_cast(
signed long, this->
Src_X) <= 0) || (
Top + OFstatic_cast(
signed long, this->
Src_Y) <= 0) ||
206 (
Left >= OFstatic_cast(
signed long,
Columns)) || (
Top >= OFstatic_cast(
signed long,
Rows)))
208 DCMIMGLE_DEBUG(
"clipping area is fully outside the image boundaries");
221 else if ((interpolate == 1) && (this->
Bits <= MAX_INTERPOLATION_BITS))
233 else if ((interpolate >= 1) && (this->
Bits <= MAX_INTERPOLATION_BITS))
267 DCMIMGLE_DEBUG(
"using clip image to specified area algorithm");
268 const unsigned long x_feed = Columns - this->
Src_X;
269 const unsigned long y_feed = OFstatic_cast(
unsigned long, Rows - this->
Src_Y) * OFstatic_cast(
unsigned long, Columns);
274 for (
int j = 0; j < this->
Planes; ++j)
276 p = src[j] + OFstatic_cast(
unsigned long, Top) * OFstatic_cast(
unsigned long, Columns) +
Left;
278 for (
unsigned long f = this->
Frames; f != 0; --f)
280 for (y = this->
Dest_Y; y != 0; --y)
282 for (x = this->
Dest_X; x != 0; --x)
301 DCMIMGLE_DEBUG(
"using clip image to specified area and add border algorithm");
302 const Uint16 s_left = (Left > 0) ? OFstatic_cast(Uint16, Left) : 0;
303 const Uint16 s_top = (Top > 0) ? OFstatic_cast(Uint16, Top) : 0;
304 const Uint16 d_left = (Left < 0 ? OFstatic_cast(Uint16, -Left) : 0);
305 const Uint16 d_top = (Top < 0) ? OFstatic_cast(Uint16, -Top) : 0;
306 const Uint16 d_right = (OFstatic_cast(
unsigned long, this->
Src_X) + OFstatic_cast(
unsigned long, s_left) <
307 OFstatic_cast(
unsigned long, Columns) + OFstatic_cast(
unsigned long, d_left)) ?
308 (this->
Src_X - 1) : (Columns + d_left - s_left - 1);
309 const Uint16 d_bottom = (OFstatic_cast(
unsigned long, this->
Src_Y) + OFstatic_cast(
unsigned long, s_top) <
310 OFstatic_cast(
unsigned long, Rows) + OFstatic_cast(
unsigned long, d_top)) ?
311 (this->
Src_Y - 1) : (Rows + d_top - s_top - 1);
312 const Uint16 x_count = d_right - d_left + 1;
313 const Uint16 y_count = d_bottom - d_top + 1;
314 const unsigned long s_start = OFstatic_cast(
unsigned long, s_top) * OFstatic_cast(
unsigned long, Columns) + s_left;
315 const unsigned long x_feed = Columns - x_count;
316 const unsigned long y_feed = OFstatic_cast(
unsigned long, Rows - y_count) *
Columns;
317 const unsigned long t_feed = OFstatic_cast(
unsigned long, d_top) * OFstatic_cast(
unsigned long, this->
Src_X);
318 const unsigned long b_feed = OFstatic_cast(
unsigned long, this->
Src_Y - d_bottom - 1) * OFstatic_cast(
unsigned long, this->
Src_X);
329 register unsigned long i;
332 for (
int j = 0; j < this->
Planes; ++j)
334 p = src[j] + s_start;
336 for (
unsigned long f = this->
Frames; f != 0; --f)
338 for (i = t_feed; i != 0; --i)
340 for (y = y_count; y != 0; --y)
353 while (x < this->
Src_X)
360 for (i = b_feed; i != 0; --i)
376 DCMIMGLE_DEBUG(
"using replicate pixel scaling algorithm without interpolation");
377 const Uint16 x_factor = this->
Dest_X / this->
Src_X;
378 const Uint16 y_factor = this->
Dest_Y / this->
Src_Y;
379 const unsigned long x_feed =
Columns;
380 const unsigned long y_feed = OFstatic_cast(
unsigned long, Rows - this->
Src_Y) * OFstatic_cast(
unsigned long, Columns);
389 for (
int j = 0; j < this->
Planes; ++j)
391 sp = src[j] + OFstatic_cast(
unsigned long, Top) * OFstatic_cast(
unsigned long, Columns) +
Left;
393 for (
unsigned long f = this->
Frames; f != 0; --f)
395 for (y = this->
Src_Y; y != 0; --y)
397 for (dy = y_factor; dy != 0; --dy)
399 for (x = this->
Src_X, p = sp; x != 0; --x)
402 for (dx = x_factor; dx != 0; --dx)
422 DCMIMGLE_DEBUG(
"using suppress pixel scaling algorithm without interpolation");
423 const unsigned int x_divisor = this->
Src_X / this->
Dest_X;
424 const unsigned long x_feed = OFstatic_cast(
unsigned long, this->
Src_Y / this->
Dest_Y) * OFstatic_cast(
unsigned long, Columns) - this->
Src_X;
425 const unsigned long y_feed = OFstatic_cast(
unsigned long, Rows - this->
Src_Y) * OFstatic_cast(
unsigned long, Columns);
430 for (
int j = 0; j < this->
Planes; ++j)
432 p = src[j] + OFstatic_cast(
unsigned long, Top) * OFstatic_cast(
unsigned long, Columns) +
Left;
434 for (
unsigned long f = this->
Frames; f != 0; --f)
436 for (y = this->
Dest_Y; y != 0; --y)
438 for (x = this->
Dest_X; x != 0; --x)
459 DCMIMGLE_DEBUG(
"using free scaling algorithm without interpolation");
462 Uint16 *x_step =
new Uint16[xmin];
463 Uint16 *y_step =
new Uint16[ymin];
464 Uint16 *x_fact =
new Uint16[xmin];
465 Uint16 *y_fact =
new Uint16[ymin];
472 if ((x_step != NULL) && (y_step != NULL) && (x_fact != NULL) && (y_fact != NULL))
476 if (this->Dest_X < this->
Src_X)
477 setScaleValues(x_step, this->
Dest_X, this->Src_X);
478 else if (this->
Dest_X > this->Src_X)
479 setScaleValues(x_fact, this->Src_X, this->
Dest_X);
480 if (this->Dest_X <= this->Src_X)
482 if (this->
Dest_X >= this->Src_X)
484 x_step[xmin - 1] += Columns - this->
Src_X;
485 if (this->Dest_Y < this->
Src_Y)
486 setScaleValues(y_step, this->
Dest_Y, this->Src_Y);
487 else if (this->
Dest_Y > this->Src_Y)
488 setScaleValues(y_fact, this->Src_Y, this->
Dest_Y);
489 if (this->Dest_Y <= this->Src_Y)
491 if (this->
Dest_Y >= this->Src_Y)
493 y_step[ymin - 1] += Rows - this->
Src_Y;
500 for (
int j = 0; j < this->
Planes; ++j)
502 sp = src[j] + OFstatic_cast(
unsigned long, Top) * OFstatic_cast(
unsigned long, Columns) +
Left;
504 for (
unsigned long f = 0; f < this->
Frames; ++f)
506 for (y = 0; y < ymin; ++y)
508 for (dy = 0; dy < y_fact[y]; ++dy)
510 for (x = 0, p = sp; x < xmin; ++x)
513 for (dx = 0; dx < x_fact[x]; ++dx)
518 sp += OFstatic_cast(
unsigned long, y_step[y]) * OFstatic_cast(
unsigned long, Columns);
538 DCMIMGLE_DEBUG(
"using scaling algorithm with interpolation from pbmplus toolkit");
539 if ((this->
Src_X != Columns) || (this->
Src_Y != Rows))
541 DCMIMGLE_ERROR(
"interpolated scaling and clipping at the same time not implemented ... ignoring clipping region");
560 const unsigned long sxscale = OFstatic_cast(
unsigned long, (OFstatic_cast(
double, this->
Dest_X) / OFstatic_cast(
double, this->
Src_X)) * SCALE_FACTOR);
561 const unsigned long syscale = OFstatic_cast(
unsigned long, (OFstatic_cast(
double, this->
Dest_Y) / OFstatic_cast(
double, this->
Src_Y)) * SCALE_FACTOR);
564 T *xtemp =
new T[this->
Src_X];
565 signed long *xvalue =
new signed long[this->
Src_X];
567 if ((xtemp == NULL) || (xvalue == NULL))
569 DCMIMGLE_ERROR(
"can't allocate temporary buffers for interpolation scaling");
572 for (
int j = 0; j < this->
Planes; ++j)
576 for (
unsigned long f = this->
Frames; f != 0; --f)
578 for (x = 0; x < this->
Src_X; ++x)
579 xvalue[x] = HALFSCALE_FACTOR;
580 register unsigned long yfill = SCALE_FACTOR;
581 register unsigned long yleft = syscale;
582 register int yneed = 1;
584 for (y = 0; y < this->
Dest_Y; ++y)
586 if (this->
Src_Y == this->Dest_Y)
589 for (x = this->Src_X, p = sp, q = xtemp; x != 0; --x)
595 while (yleft < yfill)
597 if (yneed && (ysrc < OFstatic_cast(
int, this->
Src_Y)))
603 for (x = 0, p = sp; x < this->
Src_X; ++x)
604 xvalue[x] += yleft * OFstatic_cast(
signed long, *(p++));
609 if (yneed && (ysrc < OFstatic_cast(
int, this->
Src_Y)))
616 register signed long v;
617 for (x = 0, p = sp, q = xtemp; x < this->
Src_X; ++x)
619 v = xvalue[x] + yfill * OFstatic_cast(
signed long, *(p++));
621 *(q++) = OFstatic_cast(T, (v > maxvalue) ? maxvalue : v);
622 xvalue[x] = HALFSCALE_FACTOR;
630 yfill = SCALE_FACTOR;
632 if (this->Src_X == this->
Dest_X)
634 for (x = this->
Dest_X, p = xtemp, q = sq; x != 0; --x)
640 register signed long v = HALFSCALE_FACTOR;
641 register unsigned long xfill = SCALE_FACTOR;
642 register unsigned long xleft;
643 register int xneed = 0;
645 for (x = 0, p = xtemp; x < this->
Src_X; ++x, ++p)
648 while (xleft >= xfill)
653 v = HALFSCALE_FACTOR;
655 v += xfill * OFstatic_cast(
signed long, *p);
657 *q = OFstatic_cast(T, (v > maxvalue) ? maxvalue : v);
659 xfill = SCALE_FACTOR;
667 v = HALFSCALE_FACTOR;
670 v += xleft * OFstatic_cast(
signed long, *p);
675 v += xfill * OFstatic_cast(
signed long, *(--p));
679 *q = OFstatic_cast(T, (v > maxvalue) ? maxvalue : v);
700 DCMIMGLE_DEBUG(
"using expand pixel scaling algorithm with interpolation from c't magazine");
701 const double x_factor = OFstatic_cast(
double, this->
Src_X) / OFstatic_cast(
double, this->
Dest_X);
702 const double y_factor = OFstatic_cast(
double, this->
Src_Y) / OFstatic_cast(
double, this->
Dest_Y);
703 const unsigned long f_size = OFstatic_cast(
unsigned long, Rows) * OFstatic_cast(
unsigned long, Columns);
709 unsigned long offset;
711 double x_part, y_part;
712 double l_factor, r_factor;
713 double t_factor, b_factor;
727 for (
int j = 0; j < this->
Planes; ++j)
729 sp = src[j] + OFstatic_cast(
unsigned long, Top) * OFstatic_cast(
unsigned long, Columns) +
Left;
731 for (
unsigned long f = 0; f < this->
Frames; ++f)
733 for (y = 0; y < this->
Dest_Y; ++y)
735 by = y_factor * OFstatic_cast(
double, y);
736 ey = y_factor * (OFstatic_cast(
double, y) + 1.0);
737 byi = OFstatic_cast(
int, by);
738 eyi = OFstatic_cast(
int, ey);
739 if (OFstatic_cast(
double, eyi) == ey)
741 y_part = OFstatic_cast(
double, eyi) / y_factor;
742 b_factor = y_part - OFstatic_cast(
double, y);
743 t_factor = (OFstatic_cast(
double, y) + 1.0) - y_part;
744 for (x = 0; x < this->
Dest_X; ++x)
747 bx = x_factor * OFstatic_cast(
double, x);
748 ex = x_factor * (OFstatic_cast(
double, x) + 1.0);
749 bxi = OFstatic_cast(
int, bx);
750 exi = OFstatic_cast(
int, ex);
751 if (OFstatic_cast(
double, exi) == ex)
753 x_part = OFstatic_cast(
double, exi) / x_factor;
754 l_factor = x_part - OFstatic_cast(
double, x);
755 r_factor = (OFstatic_cast(
double, x) + 1.0) - x_part;
756 offset = OFstatic_cast(
unsigned long, byi) * OFstatic_cast(
unsigned long, Columns);
757 for (yi = byi; yi <= eyi; ++yi)
759 p = sp + offset + bxi;
760 for (xi = bxi; xi <= exi; ++xi)
762 sum = OFstatic_cast(
double, *(p++));
781 *(q++) = OFstatic_cast(T, value + 0.5);
798 DCMIMGLE_DEBUG(
"using reduce pixel scaling algorithm with interpolation from c't magazine");
799 const double x_factor = OFstatic_cast(
double, this->
Src_X) / OFstatic_cast(
double, this->
Dest_X);
800 const double y_factor = OFstatic_cast(
double, this->
Src_Y) / OFstatic_cast(
double, this->
Dest_Y);
801 const double xy_factor = x_factor * y_factor;
802 const unsigned long f_size = OFstatic_cast(
unsigned long, Rows) * OFstatic_cast(
unsigned long, Columns);
808 unsigned long offset;
810 double l_factor, r_factor;
811 double t_factor, b_factor;
825 for (
int j = 0; j < this->
Planes; ++j)
827 sp = src[j] + OFstatic_cast(
unsigned long, Top) * OFstatic_cast(
unsigned long, Columns) +
Left;
829 for (
unsigned long f = 0; f < this->
Frames; ++f)
831 for (y = 0; y < this->
Dest_Y; ++y)
833 by = y_factor * OFstatic_cast(
double, y);
834 ey = y_factor * (OFstatic_cast(
double, y) + 1.0);
835 byi = OFstatic_cast(
int, by);
836 eyi = OFstatic_cast(
int, ey);
837 if (OFstatic_cast(
double, eyi) == ey)
839 b_factor = 1 + OFstatic_cast(
double, byi) - by;
840 t_factor = ey - OFstatic_cast(
double, eyi);
841 for (x = 0; x < this->
Dest_X; ++x)
844 bx = x_factor * OFstatic_cast(
double, x);
845 ex = x_factor * (OFstatic_cast(
double, x) + 1.0);
846 bxi = OFstatic_cast(
int, bx);
847 exi = OFstatic_cast(
int, ex);
848 if (OFstatic_cast(
double, exi) == ex)
850 l_factor = 1 + OFstatic_cast(
double, bxi) - bx;
851 r_factor = ex - OFstatic_cast(
double, exi);
852 offset = OFstatic_cast(
unsigned long, byi) * OFstatic_cast(
unsigned long, Columns);
853 for (yi = byi; yi <= eyi; ++yi)
855 p = sp + offset + bxi;
856 for (xi = bxi; xi <= exi; ++xi)
858 sum = OFstatic_cast(
double, *(p++)) / xy_factor;
871 *(q++) = OFstatic_cast(T, value + 0.5);
887 DCMIMGLE_DEBUG(
"using magnification algorithm with bilinear interpolation contributed by Eduard Stanescu");
888 const double x_factor = OFstatic_cast(
double, this->
Src_X) / OFstatic_cast(
double, this->
Dest_X);
889 const double y_factor = OFstatic_cast(
double, this->
Src_Y) / OFstatic_cast(
double, this->
Dest_Y);
890 const unsigned long f_size = OFstatic_cast(
unsigned long, Rows) * OFstatic_cast(
unsigned long, Columns);
891 const unsigned long l_offset = OFstatic_cast(
unsigned long, this->
Src_Y - 1) * OFstatic_cast(
unsigned long, this->
Dest_X);
895 register T *pCurrTemp;
896 register const T *pCurrSrc;
904 T *pTemp =
new T[OFstatic_cast(
unsigned long, this->
Src_Y) * OFstatic_cast(
unsigned long, this->
Dest_X)];
907 DCMIMGLE_ERROR(
"can't allocate temporary buffer for interpolation scaling");
917 for (
int j = 0; j < this->
Planes; ++j)
919 pF = src[j] + OFstatic_cast(
unsigned long, Top) * OFstatic_cast(
unsigned long, Columns) +
Left;
921 for (
unsigned long f = this->
Frames; f != 0; --f)
923 pT = pCurrTemp = pTemp;
927 for (y = this->
Src_Y; y != 0; --y)
929 *(pCurrTemp) = *(pCurrSrc);
931 pCurrTemp += this->
Dest_X;
936 for (x = 1; x < this->
Dest_X - 1; ++x)
939 dOff = x * x_factor - nSrcIndex;
940 dOff = (1.0 < dOff) ? 1.0 : dOff;
941 for (y = 0; y < this->
Src_Y; ++y)
943 *(pCurrTemp) = OFstatic_cast(T, *(pCurrSrc) + (*(pCurrSrc + 1) - *(pCurrSrc)) * dOff);
945 pCurrTemp += this->
Dest_X;
948 if ((nSrcIndex < this->
Src_X - 2) && (x * x_factor >= nSrcIndex + 1))
957 for (y = this->
Src_Y; y != 0; --y)
959 *(pCurrTemp) = *(pCurrSrc);
961 pCurrTemp += this->
Dest_X;
964 pT = pCurrTemp = pTemp;
966 for (x = this->Dest_X; x != 0; --x)
967 *(pD++) = *(pCurrTemp++);
970 for (y = 1; y < this->
Dest_Y - 1; ++y)
972 dOff = y * y_factor - nSrcIndex;
973 dOff = (1.0 < dOff) ? 1.0 : dOff;
974 for (x = this->Dest_X; x != 0; --x)
976 *(pD++) = OFstatic_cast(T, *(pCurrTemp) + (*(pCurrTemp + this->
Dest_X) - *(pCurrTemp)) * dOff);
980 if ((nSrcIndex < this->
Src_Y - 2) && (y * y_factor >= nSrcIndex + 1))
988 pCurrTemp = pTemp + l_offset;
989 for (x = this->Dest_X; x != 0; --x)
990 *(pD++) = *(pCurrTemp++);
1007 DCMIMGLE_DEBUG(
"using magnification algorithm with bicubic interpolation contributed by Eduard Stanescu");
1010 const double x_factor = OFstatic_cast(
double, this->
Src_X) / OFstatic_cast(
double, this->
Dest_X);
1011 const double y_factor = OFstatic_cast(
double, this->
Src_Y) / OFstatic_cast(
double, this->
Dest_Y);
1012 const Uint16 xDelta = OFstatic_cast(Uint16, 1 / x_factor);
1013 const Uint16 yDelta = OFstatic_cast(Uint16, 1 / y_factor);
1014 const unsigned long f_size = OFstatic_cast(
unsigned long, Rows) * OFstatic_cast(
unsigned long, Columns);
1015 const unsigned long l_offset = OFstatic_cast(
unsigned long, this->
Src_Y - 1) * OFstatic_cast(
unsigned long, this->
Dest_X);
1019 register T *pCurrTemp;
1020 register const T *pCurrSrc;
1028 T *pTemp = pT = pCurrTemp =
new T[OFstatic_cast(
unsigned long, this->
Src_Y) * OFstatic_cast(
unsigned long, this->
Dest_X)];
1031 DCMIMGLE_ERROR(
"can't allocate temporary buffer for interpolation scaling");
1041 for (
int j = 0; j < this->
Planes; ++j)
1043 pF = src[j] + OFstatic_cast(
unsigned long, Top) * OFstatic_cast(
unsigned long, Columns) +
Left;
1045 for (
unsigned long f = this->
Frames; f != 0; --f)
1047 pT = pCurrTemp = pTemp;
1051 for (y = this->
Src_Y; y != 0; --y)
1053 *(pCurrTemp) = *(pCurrSrc);
1055 pCurrTemp += this->
Dest_X;
1059 for (x = 1; x < xDelta + 1; ++x)
1063 dOff = x * x_factor;
1064 dOff = (1.0 < dOff) ? 1.0 : dOff;
1065 for (y = this->
Src_Y; y != 0; --y)
1067 *(pCurrTemp) = OFstatic_cast(T, *(pCurrSrc) + (*(pCurrSrc + 1) - *(pCurrSrc)) * dOff);
1069 pCurrTemp += this->
Dest_X;
1075 for (x = xDelta + 1; x < this->
Dest_X - 2 * xDelta; ++x)
1078 dOff = x * x_factor - nSrcIndex;
1079 dOff = (1.0 < dOff) ? 1.0 : dOff;
1080 for (y = this->
Src_Y; y != 0; --y)
1082 *(pCurrTemp) = OFstatic_cast(T, cubicValue(*(pCurrSrc - 1), *(pCurrSrc), *(pCurrSrc + 1), *(pCurrSrc + 2), dOff, minVal, maxVal));
1084 pCurrTemp += this->
Dest_X;
1087 if ((nSrcIndex < this->
Src_X - 3) && (x * x_factor >= nSrcIndex + 1))
1095 for (x = this->
Dest_X - 2 * xDelta; x < this->
Dest_X - 1; ++x)
1098 dOff = x * x_factor - nSrcIndex;
1099 dOff = (1.0 < dOff) ? 1.0 : dOff;
1100 for (y = this->
Src_Y; y != 0; --y)
1102 *(pCurrTemp) = OFstatic_cast(T, *(pCurrSrc) + (*(pCurrSrc + 1) - *(pCurrSrc)) * dOff);
1104 pCurrTemp += this->
Dest_X;
1107 if ((nSrcIndex < this->
Src_X - 2) && (x * x_factor >= nSrcIndex + 1))
1115 pCurrTemp = pTemp + this->Dest_X - 1;
1116 pCurrSrc = pF + this->
Src_X - 1;
1117 for (y = this->
Src_Y; y != 0; --y)
1119 *(pCurrTemp) = *(pCurrSrc);
1121 pCurrTemp += this->
Dest_X;
1124 pT = pCurrTemp = pTemp;
1126 for (x = this->Dest_X; x != 0; --x)
1127 *(pD++) = *(pCurrTemp++);
1129 for (y = 1; y < yDelta + 1; ++y)
1132 dOff = y * y_factor;
1133 dOff = (1.0 < dOff) ? 1.0 : dOff;
1134 for (x = this->Dest_X; x != 0; --x)
1136 *(pD++) = OFstatic_cast(T, *(pCurrTemp) + (*(pCurrTemp + this->
Dest_X) - *(pCurrTemp)) * dOff);
1141 pCurrTemp = pT = pTemp + this->
Dest_X;
1142 for (y = yDelta + 1; y < this->
Dest_Y - yDelta - 1; ++y)
1144 dOff = y * y_factor - nSrcIndex;
1145 dOff = (1.0 < dOff) ? 1.0 : dOff;
1146 for (x = this->Dest_X; x != 0; --x)
1148 *(pD++) = OFstatic_cast(T, cubicValue(*(pCurrTemp - this->Dest_X),*(pCurrTemp), *(pCurrTemp + this->Dest_X),
1149 *(pCurrTemp + this->Dest_X + this->
Dest_X), dOff, minVal, maxVal));
1153 if ((nSrcIndex < this->
Src_Y - 3) && (y * y_factor >= nSrcIndex + 1))
1161 pCurrTemp = pT = pTemp + OFstatic_cast(
unsigned long, this->
Src_Y - 2) * OFstatic_cast(
unsigned long, this->Dest_X);
1162 for (y = this->
Dest_Y - yDelta - 1; y < this->
Dest_Y - 1; ++y)
1164 dOff = y * y_factor - nSrcIndex;
1165 dOff = (1.0 < dOff) ? 1.0 : dOff;
1166 for (x = this->Dest_X; x != 0; --x)
1168 *(pD++) = OFstatic_cast(T, *(pCurrTemp) + (*(pCurrTemp + this->
Dest_X) - *(pCurrTemp)) * dOff);
1174 pCurrTemp = pTemp + l_offset;
1175 for (x = this->Dest_X; x != 0; --x)
1176 *(pD++) = *(pCurrTemp++);
const int Bits
number of bits per plane/pixel
void bicubicPixel(const T *src[], T *dest[])
bicubic interpolation method (only for magnification)
int Planes
number of planes
void reducePixel(const T *src[], T *dest[])
free scaling method with interpolation (only for reduction)
void scalePixel(const T *src[], T *dest[])
free scaling method without interpolation.
Uint16 Src_X
width of source image
void fillPixel(T *dest[], const T value)
fill pixel data with specified value
const signed long Left
left coordinate of clipping area
void interpolatePixel(const T *src[], T *dest[])
free scaling method with interpolation
void clearPixel(T *dest[])
clear pixel data (set values to 0)
void scaleData(const T *src[], T *dest[], const int interpolate, const T value=0)
choose scaling/clipping algorithm depending on specified parameters.
void clipBorderPixel(const T *src[], T *dest[], const T value)
clip image to specified area and add a border if necessary
Template class building the base for other transformations.
void clipPixel(const T *src[], T *dest[])
clip image to specified area (only inside image boundaries).
DiScaleTemplate(const int planes, const Uint16 src_cols, const Uint16 src_rows, const Uint16 dest_cols, const Uint16 dest_rows, const Uint32 frames, const int bits=0)
constructor, scale whole image.
static void setMem(T *dest, const T value, const unsigned long count)
sets specified number of elements in destination memory to a defined value
int isSigned() const
check whether template type T is signed or not
const signed long Top
top coordinate of clipping area
void bilinearPixel(const T *src[], T *dest[])
bilinear interpolation method (only for magnification)
const Uint32 Frames
number of frames
Template class to scale images (on pixel data level).
Template class to determine pixel representation.
DiScaleTemplate(const int planes, const Uint16 columns, const Uint16 rows, const signed long left_pos, const signed long top_pos, const Uint16 src_cols, const Uint16 src_rows, const Uint16 dest_cols, const Uint16 dest_rows, const Uint32 frames, const int bits=0)
constructor, scale clipping area.
static unsigned long maxval(const int mv_bits, const unsigned long mv_pos=1)
calculate maximum value which could be stored in the specified number of bits
const Uint16 Columns
width of source image
void suppressPixel(const T *src[], T *dest[])
shrink image by an integer divisor.
Uint16 Src_Y
height of source image
virtual ~DiScaleTemplate()
destructor
void expandPixel(const T *src[], T *dest[])
free scaling method with interpolation (only for magnification)
const Uint16 Dest_Y
height of destination image
const Uint16 Rows
height of source image
void copyPixel(const T *src[], T *dest[])
copy pixel data
const Uint16 Dest_X
width of destination image
void replicatePixel(const T *src[], T *dest[])
enlarge image by an integer factor.
int isSigned() const
check whether template type T is signed or not