21 #ifndef IMG_ALG_TRANSFORM_SHIFT_HH
22 #define IMG_ALG_TRANSFORM_SHIFT_HH
30 unsigned int absmod(
int x,
unsigned int y)
32 return x<0 ? y+std::div(x,y).rem : std::div(x,y).rem;
37 namespace ost {
namespace img {
namespace alg {
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;
ImageStateConstModOPAlgorithm< ShiftFnc > Shift
#define DLLEXPORT_IMG_ALG
static String GetAlgorithmName()
boost::shared_ptr< ImageStateBase > ImageStateBasePtr
ImageStateBasePtr VisitState(const ImageStateImpl< T, D > &in_state) const
class encapsulating 1D to 3D point