void iDCT(ImageFeature &src, ImageFeature &dest) { dest.resize(src.xsize(),src.ysize(),src.zsize()); //NB Not efficient for(uint c=0;c<src.zsize();++c) { uint i,j,k; double sum; // Transform in x direction ImageFeature horizontal(src.xsize(), src.ysize(),1); for (j = 0; j < src.ysize(); j++) { for (i = 0; i < src.xsize(); i++) { sum = 0.0; for (k = 0; k < src.xsize(); k++) { sum += alpha(k,src.xsize())*src(k,j,0)* cos(double(2*i+1)*M_PI*double(k)/(double(2*src.xsize()))); } horizontal(i,j,0) = sum; } } // Transform in y direction for (i = 0; i < src.xsize(); i++) { for (j = 0; j < src.ysize(); j++) { sum = 0.0; for (k = 0; k < src.ysize(); k++) { sum += alpha(k, src.xsize())*horizontal(i,k,0)* cos(double(2*j+1)*M_PI*double(k)/(double(2*src.ysize()))); } dest(i,j,c) = sum; } } } }
void shave(ImageFeature &imga, const uint shaver) { ImageFeature tmp(imga); imga.resize(imga.xsize()-2*shaver, imga.ysize()-2*shaver, imga.zsize()); for(uint x=0;x<tmp.xsize();++x) { if(x>=shaver and x<tmp.xsize()-shaver) { for(uint y=0;y<tmp.ysize();++y) { if(y>=shaver and y<tmp.ysize()-shaver) { for(uint z=0;z<tmp.zsize();++z) { imga(x-shaver,y-shaver,z)=tmp(x,y,z); } } } } } }
void appendHorizontally(ImageFeature &imga, const ImageFeature &imgb) { if(imga.ysize()!=imgb.ysize() || imga.zsize() != imgb.zsize()) { ERR << "Images have to have same width and depth" << endl; } else { ImageFeature tmp(imga); imga.resize(imga.xsize()+imgb.xsize(),imga.ysize(),imga.zsize()); for(uint y=0;y<tmp.ysize();++y) { for(uint z=0;z<tmp.zsize();++z) { for(uint x=0;x<tmp.xsize();++x) { imga(x,y,z)=tmp(x,y,z); } for(uint x=tmp.xsize();x<tmp.xsize()+imgb.xsize();++x) { imga(x,y,z)=imgb(x-tmp.xsize(),y,z); } } } } }