Example for image interpolation with bicubic, bilinear
- Author
- MIP
#include <Base/Image/Image.hh>
#include <Base/Image/ImageIO.hh>
#define OFFX 0.3
#define OFFY 0.2
using namespace BIAS;
using namespace std;
int main(int argc, char *argv[])
{
if (argc<2){
BIASERR(argv[0]<<" <image-file>");
return -1;
}
BIASERR("error loading "<<argv[1]);
return -2;
}
unsigned char **pDb = imbilinear.GetImageDataArray();
double CurValue = 0;
for (
unsigned int x=2; x<im.
GetWidth()-3; x++) {
for (
unsigned int y=2; y<im.
GetHeight()-3; y++) {
for (unsigned int c=0; c<channelcount; c++) {
double(y)+double(OFFY),
(unsigned short)(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)+double(OFFY),
(unsigned short)(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;
}
return 0;
}