test-hmaxRec.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 "HMAX/Hmax.H"
00039 #include "Image/Image.H"
00040 #include "Image/ColorOps.H"
00041 #include "Image/MathOps.H"
00042 #include "Image/CutPaste.H"
00043 #include "Image/Transforms.H"
00044 #include "Raster/Raster.H"
00045 #include "Util/Types.H"
00046 #include "Util/log.H"
00047 #include "GUI/DebugWin.H"
00048 #include "Media/TestImages.H"
00049
00050 #include <iostream>
00051 #include <unistd.h>
00052
00053
00054 #define NORI 4
00055
00056 int main(const int argc, const char **argv)
00057 {
00058 int debug=0;
00059 if (argc != 2)
00060 { std::cerr<<"USAGE: test-hmaxRec <file>"<<std::endl; exit(1); }
00061
00062
00063 std::vector<int> scss(5);
00064 scss[0] = 0; scss[1] = 2; scss[2] = 5; scss[3] = 8; scss[4] = 12;
00065 std::vector<int> spss(4);
00066 spss[0] = 4; spss[1] = 6; spss[2] = 9; spss[3] = 12;
00067 Hmax hmax(NORI, spss, scss);
00068
00069 const char *imageSetFile = argv[1];
00070
00071
00072 TestImages testImages(imageSetFile, TestImages::XMLFILE);
00073
00074
00075 int totalObjects = 0;
00076
00077 for (uint scene=0; scene<testImages.getNumScenes(); scene++)
00078 {
00079
00080 for (uint obj=0; obj<testImages.getNumObj(scene); obj++)
00081 {
00082 TestImages::ObjData objData = testImages.getObjectData(scene, obj);
00083
00084
00085 Point2D<int> upperLeft(0,0);
00086
00087 if (objData.img.getWidth() > 256 || objData.img.getHeight() > 256)
00088 upperLeft = Point2D<int>((objData.img.getWidth()/2)-128, (objData.img.getHeight()/2)-128);
00089
00090 LINFO("Upper left %ix%i", upperLeft.i, upperLeft.j);
00091 Image<PixRGB<byte> > inputImg = crop(objData.img, upperLeft, Dims(256,256), true);
00092
00093 if (objData.img.getWidth() < 256 || objData.img.getHeight() < 256)
00094 inputImg = shift(inputImg, 128-(objData.img.getWidth()/2), 128-(objData.img.getHeight()/2));
00095
00096 totalObjects++;
00097
00098
00099 Image<byte> input = luminance(inputImg);
00100
00101 Image<PixRGB<byte> > out = toRGB(input);
00102 if(debug) SHOWIMG(out);
00103
00104
00105
00106 Image<float> inputf = input;
00107 Image<float> c2resp = hmax.getC2(inputf);
00108
00109 float mi, ma; getMinMax(c2resp, mi, ma);
00110 LINFO("%ix%i min=%f max=%f", c2resp.getWidth(), c2resp.getHeight(), mi, ma);
00111
00112 printf("%i ", objData.id);
00113 for(int i=0; i<c2resp.getWidth()*c2resp.getHeight(); i++)
00114 {
00115 printf("%i:%f ", i,c2resp[i]);
00116 }
00117 printf("\n");
00118
00119
00120
00121
00122
00123 if (debug)
00124 {
00125 c2resp = scaleBlock(c2resp, input.getDims());
00126
00127 inplaceNormalize(c2resp, 0.0F, 255.0F);
00128 SHOWIMG(c2resp);
00129 }
00130 }
00131 }
00132
00133 return 0;
00134 }
00135
00136
00137
00138
00139
00140