#include <Base/Image/Image.hh>
#include <Base/Image/ImageIO.hh>
#include <Base/Image/ImageConvert.hh>
#include <Filter/Rescale.hh>
#include <Base/Debug/TimeMeasure.hh>
#include <Base/Common/BIASpragma.hh>
using namespace BIAS;
using namespace std;
int main(int argc, char *argv[])
{
cout<<"This example compares different upsampling methods for factor 2"
<<endl;
if (argc<2){
BIASERR(argv[0]<<" <image-file>");
return -1;
}
BIASERR("error loading "<<argv[1]);
return -2;
}
Upsampler.UpsampleBy2Grey(im, imbilinear,
Bilinear);
Upsampler.UpsampleBy2Grey(im, imbicubic,
Bicubic);
BIASERR("error writing cubic image");
return -3;
}
BIASERR("error writing bilinear image");
return -3;
}
BIASERR("error writing bilinear image");
return -3;
}
imbicubic.SetZero();
imbilinear.SetZero();
unsigned char **pDc = imbicubic.GetImageDataArray();
unsigned char **pDb = imbilinear.GetImageDataArray();
double CurValue = 0;
for (unsigned int x=2; x<imbicubic.GetWidth()-6; x++) {
for (unsigned int y=2; y<imbicubic.GetHeight()-6; y++) {
for (unsigned int c=0; c<channelcount; c++) {
double(y)*0.5, c));
if (CurValue<0.0)CurValue = 0.0;
if (CurValue>255.0)CurValue = 255.0;
pDc[y][(x*channelcount)+c] = (unsigned char) CurValue;
double(y)*0.5,
c));
if (CurValue<0.0)CurValue = 0.0;
if (CurValue>255.0)CurValue = 255.0;
pDb[y][(x*channelcount)+c] = (unsigned char) CurValue;
}
}
}
BIASERR("error writing cubic image");
return -3;
}
BIASERR("error writing bilinear image");
return -3;
}
cout<<"Performing time measurements"<<endl;
Upsampler.UpsampleBy2Grey(im, imbilinear,
Bilinear);
Upsampler.UpsampleBy2Grey(im, imbicubic,
Bicubic);
unsigned int numberruns = 10;
for (unsigned int i=0; i<numberruns; i++) {
Upsampler.UpsampleBy2Grey(im, imbilinear,
Bilinear);
Upsampler.UpsampleBy2Grey(im, imbicubic,
Bicubic);
}
cout<<"time nearest neighbor (real/user):"
cout<<
"time bilinear (real/user):"<<b1.
GetRealTime()/double(numberruns)
cout<<
"time bicubic (real/user):"<<b2.
GetRealTime()/double(numberruns)
return 0;
}