test-Foveator.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "Foveator/BlurFoveator.H"
00039 #include "Foveator/Foveator.H"
00040 #include "Foveator/LPTFoveator.H"
00041 #include "Foveator/PyrFoveator.H"
00042 #include "Image/Image.H"
00043 #include "Image/Pixels.H"
00044 #include "Raster/Raster.H"
00045 #include "Util/Timer.H"
00046 #include "Util/log.H"
00047
00048
00049
00050
00051
00052
00053 int main (int argc, char **argv)
00054 {
00055 if (argc != 2)
00056 {
00057 LFATAL("usage: test-Foveator file.[ppm|pgm]\n");
00058 }
00059
00060
00061
00062 Image< PixRGB<byte> > img;
00063
00064 img = Raster::ReadRGB( argv[1] );
00065 if (!img.initialized())
00066 {
00067 LFATAL("error loading image: %s", argv[1] );
00068 }
00069
00070
00071
00072 char *blr_out, *pyr_out, *lpt_out, *map_out;
00073 int filenameLength = strlen( argv[1] );
00074 blr_out = new char[filenameLength + 5];
00075 pyr_out = new char[filenameLength + 5];
00076 lpt_out = new char[filenameLength + 5];
00077 map_out = new char[filenameLength + 5];
00078
00079 int lastdot = filenameLength - 1;
00080 while( argv[1][lastdot] != '.' )
00081 {
00082 lastdot--;
00083 }
00084 int i = 0;
00085 for( i = 0; i < lastdot; i++ )
00086 {
00087 blr_out[i] = argv[1][i];
00088 pyr_out[i] = argv[1][i];
00089 lpt_out[i] = argv[1][i];
00090 map_out[i] = argv[1][i];
00091 }
00092
00093 blr_out[i++] = '_';
00094 blr_out[i++] = 'b';
00095 blr_out[i++] = 'l';
00096 blr_out[i++] = 'r';
00097 i -= 4;
00098 pyr_out[i++] = '_';
00099 pyr_out[i++] = 'p';
00100 pyr_out[i++] = 'y';
00101 pyr_out[i++] = 'r';
00102 i -= 4;
00103 lpt_out[i++] = '_';
00104 lpt_out[i++] = 'l';
00105 lpt_out[i++] = 'p';
00106 lpt_out[i++] = 't';
00107 i -= 4;
00108 map_out[i++] = '_';
00109 map_out[i++] = 'm';
00110 map_out[i++] = 'a';
00111 map_out[i++] = 'p';
00112
00113 while( i < ( filenameLength + 4 ) )
00114 {
00115 blr_out[i] = argv[1][i-4];
00116 pyr_out[i] = argv[1][i-4];
00117 lpt_out[i] = argv[1][i-4];
00118 map_out[i] = argv[1][i-4];
00119 i++;
00120 }
00121 blr_out[i] = '\0';
00122 pyr_out[i] = '\0';
00123 lpt_out[i] = '\0';
00124 map_out[i] = '\0';
00125
00126
00127
00128 BlurFoveator bf( img, 5 );
00129 PyrFoveator pf( img, 5 );
00130 pf.setBaseRect( 40, 40 );
00131 LPTFoveator lf( img, img.getWidth() / 2, img.getHeight() / 2 );
00132
00133
00134
00135 Image< PixRGB<byte> > blrImg;
00136 Timer tm;
00137 blrImg = bf.foveate();
00138
00139 LINFO( "Time for BlurFoveation: %llums", tm.get() );
00140 Raster::WriteRGB( blrImg, blr_out );
00141
00142 Image< PixRGB<byte> > pyrImg;
00143 tm.reset();
00144 pyrImg = pf.foveate();
00145
00146 LINFO( "Time for PyrFoveation: %llums", tm.get() );
00147 Raster::WriteRGB( pyrImg, pyr_out );
00148
00149 Image< PixRGB<byte> > lptImg;
00150 tm.reset();
00151 lptImg = lf.foveate();
00152
00153
00154
00155 LINFO( "Time for LPTFoveation (full process): %llums", tm.get() );
00156 Raster::WriteRGB( lptImg, lpt_out );
00157
00158 Image< PixRGB<byte> > mapImg;
00159 tm.reset();
00160 mapImg = lf.getLPT();
00161
00162
00163
00164 LINFO( "Time for LPTFoveation (map image only): %llums", tm.get() );
00165 Raster::WriteRGB( mapImg, map_out );
00166 }
00167
00168
00169
00170
00171
00172