PolatSagiTest.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include "Util/Assert.H"
00007 #include "CINNIC/CINNICstatsRun.H"
00008 #include "Raster/Raster.H"
00009 #include "Image/Image.H"
00010 #include "Image/Pixels.H"
00011
00012 #include <fstream>
00013 #include <iostream>
00014
00015
00016 const char* configFile;
00017
00018 const char* configFile2;
00019
00020 const char* targetFileName;
00021
00022 const char* notargetFileName;
00023
00024 readConfig ReadConfig(25);
00025
00026 readConfig ReadConfig2(25);
00027
00028 CINNICstatsRun runStats;
00029
00030 Image<float> Fimage[2];
00031
00032 float forReturn;
00033
00034 std::string in;
00035
00036 int height, width;
00037
00038 int currentX, currentY;
00039
00040 int main(int argc, char* argv[])
00041 {
00042 LINFO("Polat and Sagi 2AFC test");
00043 LINFO("Copyright 2002 ACME Vision Systems, Wallawalla, WA");
00044 ASSERT(argc > 1);
00045 targetFileName = argv[1];
00046 notargetFileName = argv[2];
00047
00048 if(argc > 3)
00049 {
00050 configFile = argv[3];
00051 }
00052 else
00053 {
00054 configFile = "stats.conf";
00055 }
00056 if(argc > 4)
00057 {
00058 configFile2 = argv[4];
00059 }
00060 else
00061 {
00062 configFile2 = "contour.conf";
00063 }
00064
00065 ReadConfig.openFile(configFile);
00066 ReadConfig2.openFile(configFile2);
00067 LINFO("Setting Stuff in Stats");
00068 runStats.setStuff();
00069 LINFO("Setting Stuff in Config");
00070 runStats.setConfig(ReadConfig,ReadConfig2);
00071
00072 std::ifstream readData;
00073 int item;
00074
00075 for(int i = 0; i < 2; i++)
00076 {
00077 if(i == 0)
00078 {
00079 readData.open(targetFileName,std::ios::in);
00080 LINFO("Opening %s",targetFileName);
00081 }
00082 if(i == 1)
00083 {
00084 readData.open(notargetFileName,std::ios::in);
00085 LINFO("Opening %s",notargetFileName);
00086 }
00087
00088 item = 0;
00089 while (readData >> in)
00090 {
00091 if(item == 0)
00092 {
00093 width = atoi(in.c_str());
00094 currentX = 0;
00095 }
00096 if(item == 1)
00097 {
00098 height = atoi(in.c_str());
00099 currentY = 0;
00100 }
00101 if(item == 2)
00102 Fimage[i].resize(width,height);
00103 if(item >= 2)
00104 {
00105 if(currentY == height)\
00106 {
00107 currentY = 0;
00108 currentX++;
00109 }
00110 Fimage[i].setVal(currentX,currentY,atof(in.c_str()));
00111 currentY++;
00112
00113 }
00114 item++;
00115 }
00116 readData.close();
00117 readData.clear();
00118 }
00119
00120
00121 LINFO("DUH, they all look the same");
00122 forReturn = runStats.polatSagi2AFC(Fimage[0],Fimage[1]);
00123 LINFO("Probability Value = %f",forReturn);
00124 std::cout << forReturn << "\n";
00125 std::cout << runStats.getMu1() << "\n";
00126 std::cout << runStats.getMu2() << "\n";
00127 return (int)(forReturn*10000);
00128 }
00129
00130
00131
00132
00133
00134