21 #ifndef IMG_ALG_TRANSFORM_SHIFT_HH
22 #define IMG_ALG_TRANSFORM_SHIFT_HH
28 namespace ost {
namespace img {
namespace alg {
32 unsigned int absmod(
int x,
unsigned int y)
34 return x<0 ? y+std::div(x,y).rem : std::div(x,y).rem;
44 template <
typename T,
class D>
46 boost::shared_ptr<ImageStateImpl<T,D> > isi = in_state.CloneState(
false);
48 unsigned int depth=in_state.GetExtent().GetDepth();
49 unsigned int height=in_state.GetExtent().GetHeight();
50 unsigned int width=in_state.GetExtent().GetWidth();
52 unsigned int p0=absmod(shift_[0],width);
53 unsigned int p1=absmod(shift_[1],height);
54 unsigned int p2=absmod(shift_[2],depth);
56 for(
unsigned int u=0;u<width;++u) {
57 for(
unsigned int v=0;v<height;++v) {
58 for(
unsigned int w=0;w<depth;++w) {
59 isi->Value(Index((u+p0)%width,(v+p1)%height,(w+p2)%depth))=in_state.Value(Index(u,v,w));
73 typedef ImageStateConstModOPAlgorithm<ShiftFnc>
Shift;