#ifndef FLIP_HEADER #define FLIP_HEADER 1 ///////////////////////////////////////////////////// //! docentry="Image.Image Processing.Operators" //! file="amma/Image/IPStream/IPBasic/Flip.hh" //! lib=IP //! userlevel=Normal //! rcsid="$Id: Flip.hh,v 1.6 2001/02/15 16:43:19 eep1rs Exp $" //! author="Alistair Fitch" //! date="21/03/2000" #include "amma/Image.hh" #include "amma/ImagIter.hh" //: Standard image processing operations. namespace StdImageN { template ImageC Flip(const ImageC &im) { ImageC flipped(im.Rectangle()); ImageIterC it(im); IndexT frow = flipped.BRow(); PixelT *place = &(flipped[frow][flipped.RCol()]); while(it.IsElm()) { *place = it.Data(); if(it.RNext()) { place--; continue; } // Next row ? if(!it.IsElm()) break; frow--; place = &(flipped[frow][flipped.RCol()]); } return flipped; } //: Flip image back to front and upside down. // Make a new which is flipped both vertically and horizontally. template ImageC FlipH(const ImageC &im) { ImageC flipped(im.Rectangle()); ImageIterC it(im); IndexT frow = flipped.TRow(); PixelT *place = &(flipped[frow][flipped.RCol()]); while(it.IsElm()) { *place = it.Data(); if(it.RNext()) { place--; continue; } // Next row ? if(!it.IsElm()) break; frow++; place = &(flipped[frow][flipped.RCol()]); } return flipped; } //: Flip image horizontaly. template ImageC FlipV(const ImageC &im) { ImageC flipped(im.Rectangle()); ImageIterC it(im); IndexT frow = flipped.BRow(); PixelT *place = &(flipped[frow][flipped.LCol()]); while(it.IsElm()) { *place = it.Data(); if(it.RNext()) { place++; continue; } // Next row ? if(!it.IsElm()) break; frow--; place = &(flipped[frow][flipped.LCol()]); } return flipped; } //: Flip image vertically. }; #endif