void fft_shift_z(image_type& I) { int wh = I.plane_size(); int half_size = I.size() >> 1; int half_size_1 = half_size-wh; int quater_size = half_size >> 1; typename image_type::iterator iter1 = I.begin(); typename image_type::iterator iter2 = iter1+half_size; typename image_type::iterator end = iter1+wh; for(;iter1 != end;++iter1,++iter2) { for(int z = 0,rz = half_size_1;z < quater_size;z+=wh,rz-=wh) { std::swap(iter1[z],iter1[rz]); std::swap(iter2[z],iter2[rz]); } } }
void fft_shift_x(image_type& I) { int half_w = I.width() >> 1; int half_w_1 = half_w-1; int w_1 = I.width()-1; int quater_w = half_w >> 1; typename image_type::iterator iter1 = I.begin(); typename image_type::iterator end = I.end(); for(;iter1 != end;iter1 += I.width()) { typename image_type::iterator iter2 = iter1+half_w; for(int x = 0,rx = half_w_1;x < quater_w;++x,--rx) { std::swap(iter1[x],iter1[rx]); std::swap(iter2[x],iter2[rx]); } } }
void fft_shift_y(image_type& I) { int w = I.width(); int half_wh = I.plane_size() >> 1; int half_wh_1 = half_wh-w; int quater_wh = half_wh >> 1; typename image_type::iterator iter1 = I.begin(); typename image_type::iterator end = I.end(); for(;iter1 != end;iter1 += I.plane_size()) { typename image_type::iterator iter1_x = iter1; typename image_type::iterator iter1_x_end = iter1+w; typename image_type::iterator iter2_x = iter1_x+half_wh; for(;iter1_x != iter1_x_end;++iter1_x,++iter2_x) for(int y = 0,ry = half_wh_1;y < quater_wh;y+=w,ry-=w) { std::swap(iter1_x[y],iter1_x[ry]); std::swap(iter2_x[y],iter2_x[ry]); } } }