24 #include <Base/Image/ImageIO.hh>
27 #include <Base/Common/BIASpragma.hh>
28 #include <Base/Common/CompareFloatingPoint.hh>
29 #include <Filter/Mean.hh>
30 #include <Filter/Gauss.hh>
31 #include <Filter/Binomial.hh>
32 #include <Filter/GaussThreshold.hh>
43 template <
class InputImageType,
class OutputImageType>
46 :
FilterBase<InputImageType, OutputImageType>()
57 template <
class InputImageType,
class OutputImageType>
65 template <
class InputStorageType,
class OutputStorageType>
72 if (_lowpass)
delete _lowpass;
81 template <
class InputImageType,
class OutputImageType>
84 if (_lowpass)
delete _lowpass;
87 template <
class InputImageType,
class OutputImageType>
91 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::Filter\n");
93 if (_RescaleFactor<1.0){
94 res=Upsample(src, dst);
95 }
else if (_RescaleFactor>1.0){
96 res=Downsample(src, dst);
100 _LastPositionOffset=0.0;
109 template <
class InputImageType,
class OutputImageType>
113 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::Downsample(src, dst)\n");
114 double pow2 = log(_RescaleFactor)/log(2.0);
117 unsigned newwidth, newheight;
118 if (fabs(_RescaleFactor-2.0)<=DBL_EPSILON){
127 return DownsampleBy2(src, dst);
128 }
else if (fabs(_RescaleFactor-4.0)<=DBL_EPSILON ){
137 return DownsampleBy4(src, dst);
138 }
else if ( pow2 - floor(pow2) <DBL_EPSILON ) {
139 return DownsampleBPoT(src,dst);
142 return Downsample(src, dst, _RescaleFactor);
146 template <
class InputImageType,
class OutputImageType>
151 const double old_width = (double)src.
GetWidth();
152 const double old_height = (double)src.
GetHeight();
153 const unsigned newwidth = (unsigned)floor(old_width/factor);
154 const unsigned newheight = (unsigned)floor(old_height/factor);
158 if ((res=_ApplyMeanFilter(src, meanim, factor))!=0){
159 BIASERR(
"error applying mean filter");
162 int tlx, tly, brx, bry;
165 tlx=(int)ceil((
double)tlx/factor);
166 tly=(int)ceil((
double)tly/factor);
167 brx=(int)floor((
double)brx/factor);
168 bry=(int)floor((
double)bry/factor);
174 return _FillInterpolated(meanim, factor, dst);
179 template <
class InputImageType,
class OutputImageType>
182 const unsigned newwidth,
const unsigned newheight)
185 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::Downsample(src, dst, width, height)\n");
193 const double hfactor = (double)src.
GetWidth() / (double)newwidth;
194 const double vfactor = (double)src.
GetHeight() / (double)newheight;
195 const double factor = (vfactor>hfactor)?vfactor:hfactor;
198 if (_ApplyMeanFilter(src, meanim, factor)!=0){
199 BIASERR(
"error applying mean filter");
206 _LastPositionOffset = 0.5 * double((pMean->
GetSize()+1)%2);
208 _LastPositionOffset = 0.0;
211 int tlx, tly, brx, bry;
214 tlx=(int)ceil((
double)tlx/hfactor);
215 tly=(int)ceil((
double)tly/vfactor);
216 brx=(int)floor((
double)brx/hfactor);
217 bry=(int)floor((
double)bry/vfactor);
228 res=_FillInterpolatedGrey(meanim, dst);
230 res=_FillInterpolatedColor(meanim, dst);
320 template <
class InputImageType,
class OutputImageType>
324 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::DownsampleBy2(src, dst)\n");
334 res = DownsampleBy2Grey(src, dst);
337 res = DownsampleBy2Color(src, dst);
342 res = Downsample(src, dst, newwidth, newheight);
346 _LastPositionOffset=0.5;
350 template <
class InputImageType,
class OutputImageType>
355 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::DownsampleBy2Grey\n");
356 unsigned minx, miny, maxx, maxy, dx, dy, mdx, mdy;
360 if (minx%2!=0) minx++;
361 if (maxx%2!=0) maxx--;
362 if (miny%2!=0) miny++;
363 if (maxy%2!=0) maxy--;
373 register const InputImageType *srcu, *srcl;
374 register OutputImageType *dst, *dstend, *dstlend;
383 dstend = Destination.
GetImageData() + mdx + mdy*dstwidth;
386 srcwidth+=(srcwidth-maxx+minx);
387 dststep=dstwidth-mdx+dx;
392 while (dst < dstend){
393 while (dst < dstlend){
395 sum += (double)*srcu++;
396 sum += (double)*srcu++;
397 sum += (double)*srcl++;
398 sum += (double)*srcl++;
399 *dst++ = (OutputImageType)(sum / 4.0);
407 _LastPositionOffset=0.5;
416 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::DownsampleBy2Grey\n");
417 register unsigned sum;
418 unsigned minx, miny, maxx, maxy, dx, dy, mdx, mdy;
422 if (minx%2!=0) minx++;
423 if (maxx%2!=0) maxx--;
424 if (miny%2!=0) miny++;
425 if (maxy%2!=0) maxy--;
434 register const unsigned char *srcu, *srcl;
435 register unsigned char *dst, *dstend, *dstlend;
443 dstend = Destination.
GetImageData() + mdx + mdy*dstwidth;
446 srcwidth+=(srcwidth-maxx+minx);
447 dststep=dstwidth-mdx+dx;
452 while (dst < dstend){
453 while (dst < dstlend){
467 _LastPositionOffset=0.5;
473 #ifdef BUILD_IMAGE_USHORT
479 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::DownsampleBy2Grey\n");
480 register unsigned sum;
481 unsigned minx, miny, maxx, maxy, dx, dy, mdx, mdy;
485 if (minx%2!=0) minx++;
486 if (maxx%2!=0) maxx--;
487 if (miny%2!=0) miny++;
488 if (maxy%2!=0) maxy--;
497 register const unsigned short *srcu, *srcl;
498 register unsigned short *dst, *dstend, *dstlend;
506 dstend = Destination.
GetImageData() + mdx + mdy*dstwidth;
509 srcwidth+=(srcwidth-maxx+minx);
510 dststep=dstwidth-mdx+dx;
515 while (dst < dstend){
516 while (dst < dstlend){
530 _LastPositionOffset=0.5;
536 template <
class InputImageType,
class OutputImageType>
541 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::DownsampleBy2Color\n");
544 if (this->DebugLevelIsSet(D_RESCALE_WRITE_IMG)) {
547 ImageIO::Save(
"filtered-source.mip", im);
549 unsigned tlx, tly, brx, bry;
552 BIASERR(
"ROI not yet supported");
560 register double sum1, sum2, sum3;
561 register const InputImageType *srcu, *srcl;
562 register OutputImageType *dst, *dstend, *dstlend;
563 register int srcwidth=Source.
GetWidth()*3, dstwidth=Destination.
GetWidth()*3;
568 dstlend = dst + dstwidth * 3;
573 while (dst < dstend){
574 while (dst < dstlend){
575 sum1 = sum2 = sum3 = 0.0;
576 sum1 += (double)*srcu++;
577 sum2 += (double)*srcu++;
578 sum3 += (double)*srcu++;
579 sum1 += (double)*srcu++;
580 sum2 += (double)*srcu++;
581 sum3 += (double)*srcu++;
582 sum1 += (double)*srcl++;
583 sum2 += (double)*srcl++;
584 sum3 += (double)*srcl++;
585 sum1 += (double)*srcl++;
586 sum2 += (double)*srcl++;
587 sum3 += (double)*srcl++;
588 *dst++ = (OutputImageType)(sum1 / 4.0);
589 *dst++ = (OutputImageType)(sum2 / 4.0);
590 *dst++ = (OutputImageType)(sum3 / 4.0);
597 _LastPositionOffset=0.5;
606 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::DownsampleBy2Color\n");
609 if (this->DebugLevelIsSet(D_RESCALE_WRITE_IMG)) {
612 ImageIO::Save(
"filtered-source.mip", im);
614 unsigned tlx, tly, brx, bry;
617 BIASERR(
"ROI not yet supported");
622 register unsigned int sum1, sum2, sum3;
623 register const unsigned char *srcu, *srcl;
624 register unsigned char *dst, *dstend, *dstlend;
625 register int srcwidth=Source.
GetWidth() * 3,
631 dstlend = dst + dstwidth;
636 while (dst < dstend){
637 while (dst < dstlend){
638 sum1 = sum2 = sum3 = 0;
669 _LastPositionOffset=0.5;
674 #ifdef BUILD_IMAGE_USHORT
680 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::DownsampleBy2Color\n");
682 if (this->DebugLevelIsSet(D_RESCALE_WRITE_IMG)) {
685 ImageIO::Save(
"filtered-source.mip", im);
687 unsigned tlx, tly, brx, bry;
690 BIASERR(
"ROI not yet supported");
694 register unsigned int sum1, sum2, sum3;
695 register const unsigned short *srcu, *srcl;
696 register unsigned short *dst, *dstend, *dstlend;
697 register int srcwidth=Source.
GetWidth() * 3,
703 dstlend = dst + dstwidth;
708 while (dst < dstend){
709 while (dst < dstlend){
710 sum1 = sum2 = sum3 = 0;
732 _LastPositionOffset=0.5;
739 template <
class InputImageType,
class OutputImageType>
743 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::DownsampleBy4\n");
745 unsigned nwidth=(int)src.
GetWidth()>>2;
746 unsigned nheight=(int)src.
GetHeight()>>2;
753 res = DownsampleBy4Grey(src, dst);
756 double oldFactor = GetFactor();
758 res = DownsampleBPoT(src, dst);
759 SetFactor(oldFactor);
764 res = Downsample(src, dst, newwidth, newheight);
768 _LastPositionOffset=1.5;
772 template <
class InputImageType,
class OutputImageType>
777 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::DownsampleBy4Grey\n");
788 unsigned minx, miny, maxx, maxy, dx, dy, mdx, mdy;
792 if (minx%4!=0) minx+=(4-(minx%4));
793 if (maxx%4!=0) maxx-=(maxx%4);
794 if (miny%4!=0) miny+=(4-(miny%4));
795 if (maxy%4!=0) maxy-=(maxy%4);
804 register const InputImageType *src1, *src2, *src3, *src4;
805 register OutputImageType *dst, *dstend, *dstlend;
806 register int srcwidth=(int)Source.
GetWidth();
807 register const int dstwidth=(int)Destination.
GetWidth();
808 register int dststep;
811 src2 = src1 + srcwidth;
812 src3 = src2 + srcwidth;
813 src4 = src3 + srcwidth;
818 dstend = Destination.
GetImageData() + mdx + (mdy-1)*dstwidth;
820 srcwidth+=(3*srcwidth-maxx+minx);
821 dststep=dstwidth-mdx+dx;
829 const double div=(1.0/16.0);
830 while (dst < dstend){
831 while (dst < dstlend){
853 *dst++ = (OutputImageType)(sum * div);
863 _LastPositionOffset=1.5;
874 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::DownsampleBy4Grey\n");
881 register unsigned sum;
882 unsigned minx, miny, maxx, maxy, dx, dy, mdx, mdy;
886 if (minx%4!=0) minx+=(4-(minx%4));
887 if (maxx%4!=0) maxx-=(maxx%4);
888 if (miny%4!=0) miny+=(4-(miny%4));
889 if (maxy%4!=0) maxy-=(maxy%4);
898 register const unsigned char *src1, *src2, *src3, *src4;
899 register unsigned char *dst, *dstend, *dstlend;
900 register int srcwidth=(int)Source.
GetWidth();
901 register const int dstwidth=(int)Destination.
GetWidth();
902 register int dststep;
905 src2 = src1 + srcwidth;
906 src3 = src2 + srcwidth;
907 src4 = src3 + srcwidth;
912 dstend = Destination.
GetImageData() + mdx + (mdy-1)*dstwidth;
914 srcwidth+=(3*srcwidth-maxx+minx);
915 dststep=dstwidth-mdx+dx;
920 while (dst < dstend){
921 while (dst < dstlend){
953 _LastPositionOffset=1.5;
958 #ifdef BUILD_IMAGE_USHORT
964 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::DownsampleBy4Grey\n");
971 register unsigned sum;
972 unsigned minx, miny, maxx, maxy, dx, dy, mdx, mdy;
976 if (minx%4!=0) minx+=(4-(minx%4));
977 if (maxx%4!=0) maxx-=(maxx%4);
978 if (miny%4!=0) miny+=(4-(miny%4));
979 if (maxy%4!=0) maxy-=(maxy%4);
988 register const unsigned short *src1, *src2, *src3, *src4;
989 register unsigned short *dst, *dstend, *dstlend;
990 register int srcwidth=(int)Source.
GetWidth();
991 register const int dstwidth=(int)Destination.
GetWidth();
992 register int dststep;
995 src2 = src1 + srcwidth;
996 src3 = src2 + srcwidth;
997 src4 = src3 + srcwidth;
1000 dstlend = dst + mdx;
1002 dstend = Destination.
GetImageData() + mdx + (mdy-1)*dstwidth;
1004 srcwidth+=(3*srcwidth-maxx+minx);
1005 dststep=dstwidth-mdx+dx;
1010 while (dst < dstend){
1011 while (dst < dstlend){
1040 dstlend += dstwidth;
1043 _LastPositionOffset=1.5;
1053 template <
class InputImageType,
class OutputImageType>
1058 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::DownsampleBPoT\n");
1061 int PowerOfTwo = (int)rint(log(_RescaleFactor)/log(2.0));
1062 if (PowerOfTwo == 0){
1065 Destination = Source;
1066 _LastPositionOffset=0.0;
1070 unsigned int newwidth, newheight;
1071 unsigned int oldwidth,oldheight;
1076 newwidth = (oldwidth >> PowerOfTwo);
1077 newheight = (oldheight >> PowerOfTwo);
1079 if (Destination.
GetWidth() != newwidth
1084 Destination.
Init(newwidth,newheight,channels,
1088 OutputImageType *sink;
1089 const InputImageType *src;
1090 bool IdenticalImages =
false;
1095 if ((
void*)src==(
void*)sink){
1096 IdenticalImages =
true;
1097 sink =
new OutputImageType[newwidth * newheight];
1100 unsigned min_oldx, min_oldy, max_oldx, max_oldy;
1101 const double div = pow(2.0,PowerOfTwo+PowerOfTwo);
1102 const int sze = pow(2.0,PowerOfTwo);
1106 for (
unsigned y=0; y<newheight; y++){
1107 min_oldy = y<<PowerOfTwo;
1108 max_oldy = min_oldy + sze;
1109 for (
unsigned x=0; x<newwidth; x++){
1110 min_oldx = x<<PowerOfTwo;
1111 max_oldx = min_oldx + sze;
1112 for (
unsigned c=0; c<channels; c++){
1115 for (
unsigned oy=min_oldy; oy<max_oldy; oy++){
1116 for (
unsigned ox=min_oldx; ox<max_oldx; ox++){
1117 sum += (double) src[oy*oldwidth*channels + ox*channels+c];
1121 sink[y*newwidth*channels+x*channels+c] =
1122 Cast<OutputImageType>(sum / div);
1129 BIASERR(
"Rescale::DownsampleBPoT unfinished for planar images");
1135 if (IdenticalImages) {
1137 Destination.
Init(newwidth, newheight, channels);
1142 _LastPositionOffset= pow(2.0, PowerOfTwo-1.0)-0.5;
1155 template <
class InputImageType,
class OutputImageType>
1159 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::Upsample(src, dst)\n");
1161 return Upsample(src, dst,
1162 (
unsigned int)floor((
double)src.
GetWidth()/
1164 (
unsigned int)floor((
double)src.
GetHeight()/
1168 template <
class InputImageType,
class OutputImageType>
1171 const unsigned newwidth,
const unsigned newheight)
1173 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::Upsample(src, dst, w, h)\n");
1175 unsigned tlx, tly, brx, bry;
1179 BIASERR(
"Upsampling with ROI not yet supported, ignoring.");
1185 BIASASSERT(src.
GetWidth()<=newwidth);
1190 float scalex, scaley;
1192 bool identicalimages=
false;
1193 OutputImageType *sink;
1196 identicalimages=
true;
1198 if (!identicalimages){
1208 sink =
new OutputImageType[ newwidth * newheight * channelcount];
1211 scalex = (float)(src.
GetWidth() - 1)/ (
float) (newwidth);
1212 scaley = (float)(src.
GetHeight() - 1) / (
float) (newheight);
1214 for (
unsigned int y = 0; y<newheight; y++)
1215 for (
unsigned int x = 0; x<newwidth; x++)
1216 for (
unsigned int c = 0; c<channelcount; c++) {
1217 oldx = (float)x * scalex;
1218 oldy = (float)y * scaley;
1221 sink[(y * newwidth + x)* channelcount + c] =
1226 BIASERR(
"Upscale only implemented on interleaved images");
1229 if (identicalimages && res==0){
1231 dst.
Init(newwidth, newheight, channelcount);
1240 template <
class InputImageType,
class OutputImageType>
1243 const unsigned newwidth,
const unsigned newheight)
1245 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::UpsampleGrey(src, dst, w, h)\n");
1247 unsigned tlx, tly, brx, bry;
1250 BIASERR(
"ROI not yet supported for UpsampleGrey, ignoring");
1257 BIASERR(
"UpsampleGrey only for grey images");
1263 BIASASSERT(src.
GetWidth()<newwidth);
1269 float scalex, scaley;
1270 bool identicalimages=
false;
1271 OutputImageType *sink;
1274 identicalimages=
true;
1276 if (!identicalimages){
1281 dst.
Init(newwidth, newheight, 1);
1285 sink =
new OutputImageType[ newwidth * newheight ];
1288 scalex = (float)(src.
GetWidth() - 1)/ (
float) (newwidth);
1289 scaley = (float)(src.
GetHeight() - 1) / (
float) (newheight);
1291 for (
unsigned int y = 0; y<newheight; y++)
1292 for (
unsigned int x = 0; x<newwidth; x++){
1293 oldx = (float)x * scalex;
1294 oldy = (float)y * scaley;
1295 sink[(y * newwidth + x)] =
1299 BIASERR(
"UpscaleGrey only implemented on interleaved images");
1302 if (identicalimages && res==0){
1304 dst.
Init(newwidth, newheight, 1);
1315 #define WY0 -0.03125
1323 template <
class InputImageType,
class OutputImageType>
1328 const double& valmin,
1329 const double& valmax) {
1330 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::UpsampleBy2Grey\n");
1331 register OutputImageType *dstu=NULL, *dstl=NULL;
1332 register const InputImageType *src=NULL, *srclend=NULL;
1333 const int srcwidth = Source.
GetWidth(),
1336 if (srcwidth*2!=dstwidth) {
1337 BIASERR(
"wrong image width :"<<srcwidth<<
"*2 != "<<dstwidth);
1345 srclend = src + srcwidth;
1347 switch (interpolation_method) {
1349 register const InputImageType* srcend = src + Source.
GetPixelCount();
1350 while (src < srcend){
1351 while (src < srclend){
1352 *dstu++ = *dstl++ = *src;
1353 *dstu++ = *dstl++ = *src++;
1357 srclend += srcwidth;
1364 BIASERR(
"need image of more than one line !");
1369 register const InputImageType* srcend =
1372 while (src < srcend){
1373 const InputImageType* c_srclend = srclend-1;
1374 while (src < c_srclend){
1375 *dstl++ = OutputImageType(0.5 * (src[0] + src[srcwidth]));
1377 *dstu++ = OutputImageType(0.5 * (src[0] + src[1]));
1378 *dstl++ = OutputImageType(0.25 * (src[0] + src[1]+
1379 src[srcwidth] + src[srcwidth+1]));
1383 *dstl++ = OutputImageType(0.5 * (src[0] + src[srcwidth]));
1386 *dstl = dstl[-1]; dstl++;
1392 srclend += srcwidth;
1396 while (src < srclend){
1397 *dstu++ = *dstl++ = *src++;
1398 *dstu++ = *dstl++ = OutputImageType(0.5*(src[-1]+src[0]));
1401 *dstu++ = *dstl++ = *src;
1402 *dstu++ = *dstl++ = *src;
1408 BIASERR(
"need image of more than three lines !");
1414 const InputImageType* c_firstsrclend = srclend-1;
1415 while (src < c_firstsrclend){
1416 *dstl++ = OutputImageType(0.5 * (*src + src[srcwidth]));
1418 *dstu++ = OutputImageType(0.5 * (src[0] + src[1]));
1419 *dstl++ = OutputImageType(0.25 * (src[0] + src[1] +
1420 src[srcwidth] + src[srcwidth+1]));
1424 *dstl++ = OutputImageType(0.5 * (src[0] + src[srcwidth]));
1427 *dstl = dstl[-1]; dstl++;
1431 srclend += srcwidth;
1433 register const InputImageType* srcend =
1436 const int width2 = 2*srcwidth;
1437 const int mwidth = -srcwidth;
1439 while (src < srcend){
1441 *dstl++ = OutputImageType(0.5 * (*src + src[srcwidth]));
1443 *dstu++ = OutputImageType(0.5 * (src[0] + src[1]));
1444 *dstl++ = OutputImageType(0.25 * (src[0] + src[1] +
1445 src[srcwidth] + src[srcwidth+1]));
1448 const InputImageType* c_srclend = srclend - 2;
1449 while (src < c_srclend){
1451 register double val = 2.0*((WY0*(src[mwidth ]+src[width2 ])) +
1452 (WY1*(src[ 0 ]+src[srcwidth ])));
1453 if (val>=valmax) *dstl++ = OutputImageType(valmax);
1454 else if (val<=valmin) *dstl++ = OutputImageType(valmin);
1455 else *dstl++ = OutputImageType(val);
1458 *dstu++ = OutputImageType(*src);
1461 val = (WX0*(src[-1] + src[2])+WX1*(src[0]+src[1]))*0.5;
1463 if (val>=valmax) *dstu++ = OutputImageType(valmax);
1464 else if (val<=valmin) *dstu++ = OutputImageType(valmin);
1465 else *dstu++ = OutputImageType(val);
1468 val = ((WX0*(src[mwidth - 1] + src[mwidth + 2]) +
1469 WX1*(src[mwidth ] + src[mwidth + 1])) +
1470 (WX0*(src[width2 - 1] + src[width2 + 2]) +
1471 WX1*(src[width2 ] + src[width2 + 1])))*WY0 +
1472 ((WX0*(src[-1 ] + src[ 2 ]) +
1473 WX1*(src[ 0 ] + src[ 1 ])) +
1474 (WX0*(src[srcwidth - 1] + src[srcwidth + 2]) +
1475 WX1*(src[srcwidth ] + src[srcwidth + 1])))*WY1;
1477 if (val>=valmax) *dstl++ = OutputImageType(valmax);
1478 else if (val<=valmin) *dstl++ = OutputImageType(valmin);
1479 else *dstl++ = OutputImageType(val);
1486 *dstl++ = OutputImageType(0.5 * (*src + src[srcwidth]));
1488 *dstu++ = OutputImageType(0.5 * (src[0] + src[1]));
1489 *dstl++ = OutputImageType(0.25 * (src[0] + src[1] +
1490 src[srcwidth] + src[srcwidth+1]));
1493 *dstl++ = OutputImageType(0.5 * (src[0] + src[srcwidth]));
1496 *dstl = dstl[-1]; dstl++;
1501 srclend += srcwidth;
1505 register const InputImageType* srcendlin =
1508 while (src < srcendlin){
1509 const InputImageType* c_srclend = srclend - 1;
1510 while (src < c_srclend){
1511 *dstl++ = OutputImageType(0.5 * (*src + src[srcwidth]));
1513 *dstu++ = OutputImageType(0.5 * (src[-1] + src[0]));
1514 *dstl++ = OutputImageType(0.25 * (src[-1] + src[0] +
1515 src[srcwidth-1] + src[srcwidth]));
1517 *dstl++ = OutputImageType(0.5 * (src[0] + src[srcwidth]));
1520 *dstl = dstl[-1]; dstl++;
1525 srclend += srcwidth;
1530 while (src < srclend){
1531 *dstu++ = *dstl++ = *src++;
1532 *dstu++ = *dstl++ = OutputImageType(0.5*(src[-1]+src[0]));
1535 *dstu++ = *dstl++ = *src;
1536 *dstu++ = *dstl++ = *src;
1540 BIASERR(
"interpolation not implemented in rescale");
1547 template <
class InputImageType,
class OutputImageType>
1552 const double& valmin,
1553 const double& valmax) {
1554 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::UpsampleBy2RGBInterleaved\n");
1555 register OutputImageType *dstu=NULL, *dstl=NULL;
1556 register const InputImageType *src=NULL, *srclend=NULL;
1557 const int srcwidth = Source.
GetWidth(),
1559 const int srcwidth3 = 3*srcwidth, dstwidth3=3*dstwidth;
1562 if (srcwidth*2!=dstwidth) {
1563 BIASERR(
"wrong image width :"<<srcwidth<<
"*2 != "<<dstwidth);
1567 BIASERR(
"wrong channel count in source");
1571 BIASERR(
"wrong channel count in dest");
1575 BIASERR(
"only for interleaved images");
1583 srclend = src + srcwidth3;
1585 switch (interpolation_method) {
1587 register const InputImageType* srcend = src + Source.
GetPixelCount()*3;
1588 while (src < srcend){
1589 while (src < srclend){
1590 *dstu++ = *dstl++ = src[0];
1591 *dstu++ = *dstl++ = src[1];
1592 *dstu++ = *dstl++ = src[2];
1593 *dstu++ = *dstl++ = *src++;
1594 *dstu++ = *dstl++ = *src++;
1595 *dstu++ = *dstl++ = *src++;
1599 srclend += srcwidth3;
1606 BIASERR(
"need image of more than one line !");
1611 register const InputImageType* srcend =
1614 while (src < srcend){
1615 const InputImageType* c_srclend = srclend-3;
1616 while (src < c_srclend){
1617 *dstl++ = OutputImageType(0.5 * (src[0] + src[srcwidth3]));
1618 *dstl++ = OutputImageType(0.5 * (src[1] + src[srcwidth3+1]));
1619 *dstl++ = OutputImageType(0.5 * (src[2] + src[srcwidth3+2]));
1625 *dstu++ = OutputImageType(0.5 * (src[0] + src[3]));
1626 *dstu++ = OutputImageType(0.5 * (src[1] + src[4]));
1627 *dstu++ = OutputImageType(0.5 * (src[2] + src[5]));
1629 *dstl++ = OutputImageType(0.25 * (src[0] + src[3]+
1630 src[srcwidth3] + src[srcwidth3+1]));
1632 *dstl++ = OutputImageType(0.25 * (src[0] + src[3]+
1633 src[srcwidth3] + src[srcwidth3+1]));
1635 *dstl++ = OutputImageType(0.25 * (src[0] + src[3]+
1636 src[srcwidth3] + src[srcwidth3+1]));
1641 *dstl++ = OutputImageType(0.5 * (src[0] + src[srcwidth3]));
1642 *dstl++ = OutputImageType(0.5 * (src[1] + src[srcwidth3+1]));
1643 *dstl++ = OutputImageType(0.5 * (src[2] + src[srcwidth3+2]));
1653 *dstl = dstl[-3]; dstl++;
1654 *dstl = dstl[-3]; dstl++;
1655 *dstl = dstl[-3]; dstl++;
1660 srclend += srcwidth3;
1664 while (src < srclend){
1665 *dstu++ = *dstl++ = *src++;
1666 *dstu++ = *dstl++ = *src++;
1667 *dstu++ = *dstl++ = *src++;
1669 *dstu++ = *dstl++ = OutputImageType(0.5*(src[-3]+src[0]));
1670 *dstu++ = *dstl++ = OutputImageType(0.5*(src[-2]+src[1]));
1671 *dstu++ = *dstl++ = OutputImageType(0.5*(src[-1]+src[2]));
1674 *dstu++ = *dstl++ = src[0];
1675 *dstu++ = *dstl++ = src[1];
1676 *dstu++ = *dstl++ = src[2];
1677 *dstu++ = *dstl++ = src[0];
1678 *dstu++ = *dstl++ = src[1];
1679 *dstu++ = *dstl++ = src[2];
1685 if ((srcwidth<4) || Source.
GetHeight()<4) {
1686 BIASERR(
"need image of more than three lines !");
1692 const InputImageType* c_firstsrclend = srclend-3;
1693 while (src < c_firstsrclend){
1694 *dstl++ = OutputImageType(0.5 * (src[0] + src[srcwidth3]));
1695 *dstl++ = OutputImageType(0.5 * (src[1] + src[srcwidth3+1]));
1696 *dstl++ = OutputImageType(0.5 * (src[2] + src[srcwidth3+2]));
1702 *dstu++ = OutputImageType(0.5 * (src[0] + src[3]));
1703 *dstu++ = OutputImageType(0.5 * (src[1] + src[4]));
1704 *dstu++ = OutputImageType(0.5 * (src[2] + src[5]));
1706 *dstl++ = OutputImageType(0.25 * (src[0] + src[3] +
1707 src[srcwidth3] + src[srcwidth3+3]));
1709 *dstl++ = OutputImageType(0.25 * (src[0] + src[3] +
1710 src[srcwidth3] + src[srcwidth3+3]));
1712 *dstl++ = OutputImageType(0.25 * (src[0] + src[3] +
1713 src[srcwidth3] + src[srcwidth3+3]));
1717 *dstl++ = OutputImageType(0.5 * (src[0] + src[srcwidth3]));
1718 *dstl++ = OutputImageType(0.5 * (src[1] + src[srcwidth3+1]));
1719 *dstl++ = OutputImageType(0.5 * (src[2] + src[srcwidth3+2]));
1726 *dstl = dstl[-3]; dstl++;
1727 *dstl = dstl[-3]; dstl++;
1728 *dstl = dstl[-3]; dstl++;
1732 srclend += srcwidth3;
1734 register const InputImageType* srcend =
1737 const int width2 = 2*srcwidth3;
1738 const int mwidth = -srcwidth3;
1740 while (src < srcend){
1742 *dstl++ = OutputImageType(0.5 * (*src + src[srcwidth3]));
1743 *dstl++ = OutputImageType(0.5 * (src[1] + src[srcwidth3+1]));
1744 *dstl++ = OutputImageType(0.5 * (src[2] + src[srcwidth3+2]));
1750 *dstu++ = OutputImageType(0.5 * (src[0] + src[3]));
1751 *dstu++ = OutputImageType(0.5 * (src[1] + src[4]));
1752 *dstu++ = OutputImageType(0.5 * (src[2] + src[5]));
1754 *dstl++ = OutputImageType(0.25 * (src[0] + src[3] +
1755 src[srcwidth3] + src[srcwidth3+1]));
1757 *dstl++ = OutputImageType(0.25 * (src[0] + src[3] +
1758 src[srcwidth3] + src[srcwidth3+1]));
1760 *dstl++ = OutputImageType(0.25 * (src[0] + src[3] +
1761 src[srcwidth3] + src[srcwidth3+1]));
1764 const InputImageType* c_srclend = srclend - 6;
1765 while (src < c_srclend){
1767 register double val = 2.0*((WY0*(src[mwidth ]+src[width2 ])) +
1768 (WY1*(src[ 0 ]+src[srcwidth3 ])));
1769 if (val>=valmax) *dstl++ = OutputImageType(valmax);
1770 else if (val<=valmin) *dstl++ = OutputImageType(valmin);
1771 else *dstl++ = OutputImageType(val);
1773 val = 2.0*((WY0*(src[mwidth+1 ]+src[width2+1 ])) +
1774 (WY1*(src[ 1 ]+src[srcwidth3+1 ])));
1775 if (val>=valmax) *dstl++ = OutputImageType(valmax);
1776 else if (val<=valmin) *dstl++ = OutputImageType(valmin);
1777 else *dstl++ = OutputImageType(val);
1779 val = 2.0*((WY0*(src[mwidth+2 ]+src[width2+2 ])) +
1780 (WY1*(src[ 2 ]+src[srcwidth3+2 ])));
1781 if (val>=valmax) *dstl++ = OutputImageType(valmax);
1782 else if (val<=valmin) *dstl++ = OutputImageType(valmin);
1783 else *dstl++ = OutputImageType(val);
1786 *dstu++ = OutputImageType(src[0]);
1787 *dstu++ = OutputImageType(src[1]);
1788 *dstu++ = OutputImageType(src[2]);
1791 val = (WX0*(src[-3] + src[6])+WX1*(src[0]+src[3]))*0.5;
1792 if (val>=valmax) *dstu++ = OutputImageType(valmax);
1793 else if (val<=valmin) *dstu++ = OutputImageType(valmin);
1794 else *dstu++ = OutputImageType(val);
1796 val = (WX0*(src[-2] + src[7])+WX1*(src[1]+src[4]))*0.5;
1797 if (val>=valmax) *dstu++ = OutputImageType(valmax);
1798 else if (val<=valmin) *dstu++ = OutputImageType(valmin);
1799 else *dstu++ = OutputImageType(val);
1801 val = (WX0*(src[-1] + src[8])+WX1*(src[2]+src[5]))*0.5;
1802 if (val>=valmax) *dstu++ = OutputImageType(valmax);
1803 else if (val<=valmin) *dstu++ = OutputImageType(valmin);
1804 else *dstu++ = OutputImageType(val);
1807 val = ((WX0*(src[mwidth - 3] + src[mwidth + 6]) +
1808 WX1*(src[mwidth ] + src[mwidth + 3])) +
1809 (WX0*(src[width2 - 3] + src[width2 + 6]) +
1810 WX1*(src[width2 ] + src[width2 + 3])))*WY0 +
1811 ((WX0*(src[-3 ] + src[ 6 ]) +
1812 WX1*(src[ 0 ] + src[ 3 ])) +
1813 (WX0*(src[srcwidth3 - 3] + src[srcwidth3 + 6]) +
1814 WX1*(src[srcwidth3 ] + src[srcwidth3 + 3])))*WY1;
1815 if (val>=valmax) *dstl++ = OutputImageType(valmax);
1816 else if (val<=valmin) *dstl++ = OutputImageType(valmin);
1817 else *dstl++ = OutputImageType(val);
1819 val = ((WX0*(src[mwidth - 3] + src[mwidth + 6]) +
1820 WX1*(src[mwidth ] + src[mwidth + 3])) +
1821 (WX0*(src[width2 - 3] + src[width2 + 6]) +
1822 WX1*(src[width2 ] + src[width2 + 3])))*WY0 +
1823 ((WX0*(src[-3 ] + src[ 6 ]) +
1824 WX1*(src[ 0 ] + src[ 3 ])) +
1825 (WX0*(src[srcwidth3 - 3] + src[srcwidth3 + 6]) +
1826 WX1*(src[srcwidth3 ] + src[srcwidth3 + 3])))*WY1;
1827 if (val>=valmax) *dstl++ = OutputImageType(valmax);
1828 else if (val<=valmin) *dstl++ = OutputImageType(valmin);
1829 else *dstl++ = OutputImageType(val);
1831 val = ((WX0*(src[mwidth - 3] + src[mwidth + 6]) +
1832 WX1*(src[mwidth ] + src[mwidth + 3])) +
1833 (WX0*(src[width2 - 3] + src[width2 + 6]) +
1834 WX1*(src[width2 ] + src[width2 + 3])))*WY0 +
1835 ((WX0*(src[-3 ] + src[ 6 ]) +
1836 WX1*(src[ 0 ] + src[ 3 ])) +
1837 (WX0*(src[srcwidth3 - 3] + src[srcwidth3 + 6]) +
1838 WX1*(src[srcwidth3 ] + src[srcwidth3 + 3])))*WY1;
1839 if (val>=valmax) *dstl++ = OutputImageType(valmax);
1840 else if (val<=valmin) *dstl++ = OutputImageType(valmin);
1841 else *dstl++ = OutputImageType(val);
1847 *dstl++ = OutputImageType(0.5 * (src[0] + src[srcwidth3]));
1848 *dstl++ = OutputImageType(0.5 * (src[1] + src[srcwidth3+1]));
1849 *dstl++ = OutputImageType(0.5 * (src[2] + src[srcwidth3+2]));
1855 *dstu++ = OutputImageType(0.5 * (src[0] + src[3]));
1856 *dstu++ = OutputImageType(0.5 * (src[1] + src[4]));
1857 *dstu++ = OutputImageType(0.5 * (src[2] + src[5]));
1859 *dstl++ = OutputImageType(0.25 * (src[0] + src[3] +
1860 src[srcwidth] + src[srcwidth+1]));
1862 *dstl++ = OutputImageType(0.25 * (src[0] + src[3] +
1863 src[srcwidth] + src[srcwidth+1]));
1865 *dstl++ = OutputImageType(0.25 * (src[0] + src[3] +
1866 src[srcwidth] + src[srcwidth+1]));
1871 *dstl++ = OutputImageType(0.5 * (src[0] + src[srcwidth3]));
1872 *dstl++ = OutputImageType(0.5 * (src[1] + src[srcwidth3+1]));
1873 *dstl++ = OutputImageType(0.5 * (src[2] + src[srcwidth3+2]));
1883 *dstl = dstl[-3]; dstl++;
1885 *dstl = dstl[-3]; dstl++;
1887 *dstl = dstl[-3]; dstl++;
1892 srclend += srcwidth3;
1896 register const InputImageType* srcendlin =
1899 while (src < srcendlin){
1900 const InputImageType* c_srclend = srclend - 3;
1901 while (src < c_srclend){
1902 *dstl++ = OutputImageType(0.5 * (*src + src[srcwidth3]));
1903 *dstl++ = OutputImageType(0.5 * (src[1] + src[srcwidth3+1]));
1904 *dstl++ = OutputImageType(0.5 * (src[2] + src[srcwidth3+2]));
1910 *dstu++ = OutputImageType(0.5 * (src[-3] + src[0]));
1911 *dstu++ = OutputImageType(0.5 * (src[-2] + src[1]));
1912 *dstu++ = OutputImageType(0.5 * (src[-1] + src[2]));
1914 *dstl++ = OutputImageType(0.25 * (src[-3] + src[0] +
1915 src[srcwidth3-3] + src[srcwidth3]));
1916 *dstl++ = OutputImageType(0.25 * (src[-2] + src[1] +
1917 src[srcwidth3-2] + src[srcwidth3]));
1918 *dstl++ = OutputImageType(0.25 * (src[-1] + src[2] +
1919 src[srcwidth3-1] + src[srcwidth3]));
1921 *dstl++ = OutputImageType(0.5 * (src[0] + src[srcwidth3]));
1922 *dstl++ = OutputImageType(0.5 * (src[1] + src[srcwidth3+1]));
1923 *dstl++ = OutputImageType(0.5 * (src[2] + src[srcwidth3+2]));
1933 *dstl = dstl[-3]; dstl++;
1935 *dstl = dstl[-3]; dstl++;
1937 *dstl = dstl[-3]; dstl++;
1942 srclend += srcwidth3;
1947 while (src < srclend){
1948 *dstu++ = *dstl++ = *src++;
1949 *dstu++ = *dstl++ = *src++;
1950 *dstu++ = *dstl++ = *src++;
1952 *dstu++ = *dstl++ = OutputImageType(0.5*(src[-3]+src[0]));
1953 *dstu++ = *dstl++ = OutputImageType(0.5*(src[-2]+src[1]));
1954 *dstu++ = *dstl++ = OutputImageType(0.5*(src[-1]+src[2]));
1957 *dstu++ = *dstl++ = *src;
1958 *dstu++ = *dstl++ = src[1];
1959 *dstu++ = *dstl++ = src[2];
1961 *dstu++ = *dstl++ = *src;
1962 *dstu++ = *dstl++ = src[1];
1963 *dstu++ = *dstl++ = src[2];
1970 BIASERR(
"interpolation not implemented in rescale");
1977 template <
class InputImageType,
class OutputImageType>
1982 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::UpsampleBy2\n");
1985 BIASERR(
"only for interleaved images");
1990 register OutputImageType *dstu=NULL, *dstl=NULL;
1991 register const InputImageType *src=NULL, *srcend=NULL, *srclend=NULL;
1999 srclend = src + srcwidth - cc;
2001 while (src < srcend){
2002 while (src < srclend){
2003 for (
int i=0; i<cc; i++){
2004 *dstu = *dstl = dstu[cc] = dstl[cc] = *src;
2005 src++; dstu++; dstl++;
2012 srclend += srcwidth;
2022 template <
class InputImageType,
class OutputImageType>
2030 gauss->
SetSigma(_RescaleMeanSigmaFactor * factor);
2044 mean->
SetSize((
int)ceil(1.0*factor));
2048 template <
class InputImageType,
class OutputImageType>
2054 _lowpass = lowpass.
Clone();
2055 UpdateLowpass(_RescaleFactor);
2058 template <
class InputImageType,
class OutputImageType>
2080 BIASERR(
"Invalid LowPassType: " << lpt);
2084 UpdateLowpass(_RescaleFactor) ;
2087 template <
class InputImageType,
class OutputImageType>
2092 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::_ApplyMeanFilter\n");
2093 UpdateLowpass(factor);
2097 int res=_lowpass->Filter(src, dst);
2101 if (this->DebugLevelIsSet(D_RESCALE_WRITE_IMG)) {
2103 ImageIO::Save(
"rescale-lowpass-filtered.mip", dst);
2110 template <
class InputImageType,
class OutputImageType>
2115 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::_FillInterpolatedGrey\n");
2121 if (this->DebugLevelIsSet(D_RESCALE_WRITE_IMG)) {
2124 ImageIO::Save(
"filtered.mip", im);
2127 int tlx, tly, brx, bry;
2129 const int minx=tlx, maxx=brx, miny=tly, maxy=bry;
2134 for (y=miny; y<maxy; y++){
2135 for (x=minx; x<maxx; x++){
2136 idst[y][x]=(OutputImageType)
2150 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::_FillInterpolatedGrey\n");
2156 if (this->DebugLevelIsSet(D_RESCALE_WRITE_IMG)) {
2159 ImageIO::Save(
"filtered.mip", im);
2162 int tlx, tly, brx, bry;
2164 const int minx=tlx, maxx=brx, miny=tly, maxy=bry;
2169 for (y=miny; y<maxy; y++){
2170 for (x=minx; x<maxx; x++){
2171 idst[y][x]=(
unsigned char)
2178 #ifdef BUILD_IMAGE_USHORT
2184 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::_FillInterpolatedGrey\n");
2194 int tlx, tly, brx, bry;
2196 const int minx=tlx, maxx=brx, miny=tly, maxy=bry;
2201 for (y=miny; y<maxy; y++){
2202 for (x=minx; x<maxx; x++){
2203 idst[y][x]=(
unsigned short)
2211 template <
class InputImageType,
class OutputImageType>
2216 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::_FillInterpolatedColor\n");
2221 if (this->DebugLevelIsSet(D_RESCALE_WRITE_IMG)) {
2224 ImageIO::Save(
"filtered.mip", im);
2227 int tlx, tly, brx, bry;
2229 const int minx=tlx, maxx=brx, miny=tly, maxy=bry;
2236 for (y=miny; y<maxy; y++){
2237 for (x=minx; x<maxx; x++){
2239 idst[y][x*cc+c]=(OutputImageType)
2251 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::_FillInterpolatedColor\n");
2256 if (this->DebugLevelIsSet(D_RESCALE_WRITE_IMG)) {
2259 ImageIO::Save(
"filtered.mip", im);
2262 int tlx, tly, brx, bry;
2264 const int minx=tlx, maxx=brx, miny=tly, maxy=bry;
2271 for (y=miny; y<maxy; y++){
2272 for (x=minx; x<maxx; x++){
2274 idst[y][x*cc+c]=(
unsigned char)rint
2281 #ifdef BUILD_IMAGE_USHORT
2289 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::_FillInterpolatedColor\n");
2299 int tlx, tly, brx, bry;
2301 const int minx=tlx, maxx=brx, miny=tly, maxy=bry;
2308 for (y=miny; y<maxy; y++){
2309 for (x=minx; x<maxx; x++){
2311 idst[y][x*cc+c]=(
unsigned char)rint
2321 template <
class InputImageType,
class OutputImageType>
2325 if (_RescaleFactor<=1.0){
2326 border_x = border_y = 0;
2333 template <
class InputImageType,
class OutputImageType>
2338 BIASDOUT(D_FILTERBASE_CALLSTACK,
"Rescale::_FillInterpolatedColor\n");
2343 if (this->DebugLevelIsSet(D_RESCALE_WRITE_IMG)) {
2346 ImageIO::Save(
"filtered.mip", im);
2349 int tlx, tly, brx, bry;
2351 const int minx=tlx, maxx=brx, miny=tly, maxy=bry;
2353 register int x, xc, y;
2355 register unsigned c;
2356 double src_x, src_y;
2357 for (y=miny; y<maxy; y++){
2358 src_y = (y+0.5)*factor-0.5;
2359 for (x=minx; x<maxx; x++){
2360 src_x = (x+0.5)*factor-0.5;
2362 for (c=0; c<cc; c++){
2363 idst[y][xc+c] = Cast<OutputImageType>
2368 _LastPositionOffset = 0.5*factor-0.5;
2376 #define FILTER_INSTANTIATION_CLASS Rescale
2377 #include "Filterinst.hh"
void Release()
reimplemented from ImageBase
void GetBorders(int &border_x, int &border_y) const
double BilinearInterpolationRGBInterleaved(const double x, const double y, unsigned int channel) const
Bilinear interpolation for interleaved RGB images.
double BilinearInterpolation(const double x, const double y, const unsigned short int channel=0) const
Generic bilinear interpolation.
int SetCorners(unsigned UpperLeftX, unsigned UpperLeftY, unsigned LowerRightX, unsigned LowerRightY)
Sets a rectangular region of interest.
void GetCorners(unsigned &UpperLeftX, unsigned &UpperLeftY, unsigned &LowerRightX, unsigned &LowerRightY) const
Return the region of interest, by saving the coordinates within the variables defined by the paramete...
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
bool IsInterleaved() const
unsigned int GetWidthStep() const
returns the number of bytes per line
StorageType FastBilinearInterpolationGrey(const double x, const double y) const
Fast bilinear interpolation for grey-value images.
virtual parent class for API definition of all (future) filters
Down-, Upsampling routines and Resize.
int Downsample(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
generic downsample function.
unsigned int GetWidth() const
double _LastPositionOffset
see DownsampleBy2 for explanation
void SetSize(const int size)
int DownsampleBy2Grey(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
assumes that destination is initialized.
smoothing with gaussian kernel
double _RescaleMeanSigmaFactor
ROI * GetROI()
Returns a pointer to the roi object.
Rescale< InputStorageType, OutputStorageType > & operator=(const Rescale< InputStorageType, OutputStorageType > &other)
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
base class for simple n->n filter implementations
virtual int Filter(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
scales the src to dst using the downsampling factor from SetFactor()
FilterNToN< InputStorageType, OutputStorageType > * _lowpass
smoothing with gaussian kernel using a threshold
unsigned int GetHeight() const
void SetSigma(const double si)
The image template class for specific storage types.
bool SamePixelAndChannelCount(const ImageBase &Image) const
checks if data area has same "size" as Image of other type
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
enum EColorModel GetColorModel() const
void ReleaseImageDataPointer()
Releases ImageData_ (to be used together with RedirectImageDataPointer)
int DownsampleBy2(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
Takes the source image that has to have a defined ROI.
virtual FilterNToN< InputStorageType, OutputStorageType > * Clone() const =0
enum EStorageType GetStorageType() const
unsigned long int GetPixelCount() const
returns number of pixels in image
This is the base class for images in BIAS.
void RedirectImageDataPointer(void *data)
This method takes data and set the internal image data pointer to this.
binomial low pass filter class
void SetHalfWinSize(int hws)
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase