app-analyze-stim.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 <cfloat>
00039 #include <fstream>
00040 #include <iostream>
00041 #include <math.h>
00042 #include <string>
00043 #include <vector>
00044
00045 #include "Util/log.H"
00046 #include "Raster/Raster.H"
00047 #include "Image/Image.H"
00048 #include "Psycho/StimAnalyzer.H"
00049
00050 using namespace std;
00051
00052 int main(const int argc, const char **argv)
00053 {
00054 if(argc < 4)
00055 {
00056 std::cerr << "image-prefix - prefix#.png for salmap\n";
00057 std::cerr << "gt-prefix - prefix#.png for ground truth images\n";
00058 std::cerr << "output-stats-file - file to append frame stats to\n";
00059 std::cerr << "output-stats-file - file to append total stats to\n";
00060 std::cerr << "frames - number of frames to run\n";
00061 LFATAL("Usage: app-analyze-stim image-prefix gt-prefix output-stats-file output-stats-file frames");
00062 }
00063 const string inFilePrefix = argv[1];
00064 const string inFileGTPrefix = argv[2];
00065 const string outStatsFileF = argv[3];
00066 const string outStatsFileT = argv[4];
00067 const unsigned int frames = atoi(argv[5]);
00068
00069 const string dot = ".";
00070 const string type = "png";
00071
00072 StimAnalyzer SA(frames,1);
00073
00074 for(unsigned int i = 0; i < frames; i++)
00075 {
00076 char c[100];
00077 if(i < 10)
00078 sprintf(c,"00000%d",i);
00079 else if(i < 100)
00080 sprintf(c,"0000%d",i);
00081 else if(i < 1000)
00082 sprintf(c,"000%d",i);
00083 else if(i < 10000)
00084 sprintf(c,"00%d",i);
00085 else if(i < 100000)
00086 sprintf(c,"0%d",i);
00087 else
00088 sprintf(c,"%d",i);
00089
00090 const string imageName = inFilePrefix + c + dot + type;
00091 const string gtName = inFileGTPrefix + c + dot + type;
00092
00093 const Image<byte> inImage = Raster::ReadGray(imageName);
00094 const Image<PixRGB<byte> > inGT = Raster::ReadRGB(gtName);
00095
00096 const Image<float> finImage = inImage;
00097 const Image<PixRGB<float> > finGT = inGT;
00098
00099 SA.SAinputImages(finImage,finGT,i,0);
00100 SA.SAcompImages();
00101 }
00102
00103 SA.SAfinalStats();
00104 SA.SAdumpFrameStats(inFilePrefix,outStatsFileF,false);
00105 SA.SAdumpConditionStats(inFilePrefix,outStatsFileT,false);
00106 }
00107
00108
00109
00110
00111
00112
00113