Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages   Examples  

Reflection.cpp

00001 /* Copyright (c) 2001 S.E. Grigorescu */
00002 
00003 #include "Reflection.h"
00004 
00005 template void Reflect< int >(Image< int >&, string, Image< int >&);
00006 template void Reflect< byte >(Image< byte >&, string, Image< byte >&);
00007 template void Reflect< float >(Image< float >&, string, Image< float >&);
00008 template void Reflect< int >(Image< int >&, string);
00009 template void Reflect< byte >(Image< byte >&, string);
00010 template void Reflect< float >(Image< float >&, string);
00011  
00012 template< class T > void Reflect(Image< T >& input, string axis, Image< T >& output)
00013 {
00014   Image< T > res;
00015   res = input;
00016 
00017   for (int i = 0; i < input.getHeight(); i++)
00018     for (int j = 0; j < input.getWidth(); j++) {
00019       if (axis.substr(0, 1) == "v" || axis.substr(0, 1) == "V")
00020         res[i][j] = input[i][input.getWidth()-1-j];
00021       if (axis.substr(0, 1) == "h" || axis.substr(0, 1) == "H")
00022         res[i][j] = input[input.getHeight()-1-i][j];
00023     }
00024   output = res;
00025 }
00026 
00027 template< class T > void Reflect(Image< T >& input, string axis)
00028 {
00029   Reflect(input, axis, input);
00030 }