Boost logo

Boost :

From: Lubomir Bourdev (lbourdev_at_[hidden])
Date: 2008-06-16 13:38:18


Michael,

Here is a version of the algorithm that makes use of view
transformations:

template <typename View>
void reflect_quadrants(const View& src) {
    typedef typename View::point_t point_t;
    point_t q_dims = ifloor(src.dimensions()/2);
    point_t mid = iceil (src.dimensions()/2);

    View q1 = subimage_view(src,point_t(0,0),q_dims);
    View q2 = subimage_view(src,point_t(mid.x,0),q_dims);
    View q3 = subimage_view(src,point_t(0,mid.y),q_dims);
    View q4 = subimage_view(src,mid,q_dims);

    copy_pixels(flipped_left_right_view(q1), q2);
    copy_pixels(flipped_up_down_view(q1), q3);
    copy_pixels(flipped_up_down_view(flipped_left_right_view(q1)), q4);
}

std::vector<float> buffer( 1024 * 1024 );
GenerateNoise( pBuffer, 1024, 1024 )

gray32f_view_t src = interleaved_view( 1024, 1024
                                     , (gray32f_pixel_t*)
&buffer.front()
                                     , 1024 * 4 // bytes per scanline
                                     );
reflect_quadrants(src);

______

reflect_quadrants should work for images of any number of channels,
dimensions, interleaved/planar, non-byte-aligned, synthetic, etc.

Lubomir


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk