33 #include <Base/Image/Image.hh>
34 #include <Base/Image/ImageIO.hh>
35 #include <Base/Image/ImageConvert.hh>
36 #include <Filter/Rescale.hh>
37 #include <Base/Debug/TimeMeasure.hh>
39 #include <Base/Common/BIASpragma.hh>
45 int main(
int argc,
char *argv[])
48 cout<<
"This example compares different upsampling methods for factor 2"
52 BIASERR(argv[0]<<
" <image-file>");
58 BIASERR(
"error loading "<<argv[1]);
69 Upsampler.UpsampleBy2Grey(im, imbilinear,
Bilinear);
70 Upsampler.UpsampleBy2Grey(im, imbicubic,
Bicubic);
74 BIASERR(
"error writing cubic image");
79 BIASERR(
"error writing bilinear image");
83 if (
ImageIO::Save(
"image_nearestneighbor_auto.mip", imnn)!=0){
84 BIASERR(
"error writing bilinear image");
91 unsigned char **pDc = imbicubic.GetImageDataArray();
92 unsigned char **pDb = imbilinear.GetImageDataArray();
96 for (
unsigned int x=2; x<imbicubic.GetWidth()-6; x++) {
97 for (
unsigned int y=2; y<imbicubic.GetHeight()-6; y++) {
98 for (
unsigned int c=0; c<channelcount; c++) {
101 if (CurValue<0.0)CurValue = 0.0;
102 if (CurValue>255.0)CurValue = 255.0;
103 pDc[y][(x*channelcount)+c] = (
unsigned char) CurValue;
107 if (CurValue<0.0)CurValue = 0.0;
108 if (CurValue>255.0)CurValue = 255.0;
109 pDb[y][(x*channelcount)+c] = (
unsigned char) CurValue;
116 BIASERR(
"error writing cubic image");
121 BIASERR(
"error writing bilinear image");
125 cout<<
"Performing time measurements"<<endl;
128 Upsampler.UpsampleBy2Grey(im, imbilinear,
Bilinear);
129 Upsampler.UpsampleBy2Grey(im, imbicubic,
Bicubic);
131 unsigned int numberruns = 10;
132 for (
unsigned int i=0; i<numberruns; i++) {
134 Upsampler.UpsampleBy2Grey(im, imbilinear,
Bilinear);
137 Upsampler.UpsampleBy2Grey(im, imbicubic,
Bicubic);
143 cout<<
"time nearest neighbor (real/user):"
146 cout<<
"time bilinear (real/user):"<<b1.
GetRealTime()/double(numberruns)
148 cout<<
"time bicubic (real/user):"<<b2.
GetRealTime()/double(numberruns)
double BilinearInterpolation(const double x, const double y, const unsigned short int channel=0) const
Generic bilinear interpolation.
unsigned int GetWidth() const
double BicubicInterpolation(const double &x, const double &y, const unsigned short int channel=0) const
Generic bicubic interpolation.
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
unsigned int GetHeight() const
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
double GetRealTime() const
return real time (=wall time clock) in usec JW For Win32: real-time is measured differently from user...
enum EColorModel GetColorModel() const
static int Load(const std::string &FileName, ImageBase &img)
first tries a call to Read MIP image and if that fails, tries to Import Image with all other availabl...
double GetUserTime() const
return user time (=system usage time) in msec JW For Win32: user-time is the sum over all processes o...
class TimeMeasure contains functions for timing real time and cpu time.
static int IP_ToGrey(Image< StorageType > &img)
In place conversion to gray image.