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

Downsampling.cpp

00001 /* Copyright (c) 2001 S.E. Grigorescu */
00002 
00003 #include "Downsampling.h"
00004 
00005 template void Downsample< int >(Image< int >&, Image< int >&);
00006 template void Downsample< byte >(Image< byte >&, Image< byte >&);
00007 template void Downsample< float >(Image< float >&, Image< float >&);
00008 template void Downsample< int >(Image< int >&);
00009 template void Downsample< byte >(Image< byte >&);
00010 template void Downsample< float >(Image< float >&);
00011  
00012 template< class T > void Downsample(Image< T >& input, Image< T >& output)
00013 {
00014   Image< T > res(floor((input.getWidth()+1.0)/2.0), 
00015                  floor((input.getHeight()+1.0)/2.0), output.getName());
00016 
00017   for (int i = 0; i < input.getHeight(); i += 2)
00018     for (int j = 0; j < input.getWidth(); j += 2)
00019       res[i/2][j/2] = input[i][j];
00020   output = res;
00021 }
00022 
00023 template< class T > void Downsample(Image< T >& input)
00024 {
00025   Downsample(input, input);
00026 }