PatchOptions.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <iostream>
00013 #include <string>
00014 #include<fstream>
00015
00016 #include "opencv/cxcore.h"
00017
00018 #include "options.h"
00019 #include "utils/libutils.h"
00020 #include "video/PatchOptions.hpp"
00021
00022
00023 PatchOptions::PatchOptions(Point3i win, Point3i step, norm_type normopt,double minvar,int minvarf) :
00024 win(win), step(step), normopt(normopt)
00025 {
00026 this->minvar=minvar;
00027 this->minvarf=minvarf;
00028 checkValues();
00029 }
00030
00031 PatchOptions::PatchOptions(int winxy, int winz, int stepxy, int stepz, norm_type normopt,double minvar,int minvarf) :
00032 win(winxy,winxy,winz), step(stepxy, stepxy, stepz), normopt(normopt)
00033 {
00034 this->minvar=minvar;
00035 this->minvarf=minvarf;
00036 checkValues();
00037 }
00038
00039
00040 PatchOptions::~PatchOptions() {
00041
00042 }
00043
00044 void PatchOptions::checkValues() {
00045 CV_Assert(win.x>0);
00046 CV_Assert(win.y>0);
00047 CV_Assert(win.z>0);
00048 CV_Assert(step.x>0);
00049 CV_Assert(step.y>0);
00050 CV_Assert(step.z>0);
00051 }
00052
00053
00054 const char* PatchOptions::norm_type_to_string(norm_type normopt) {
00055 switch(normopt) {
00056 case NORM_NONE: return("none"); break;
00057 case NORM_ZM: return("zero-mean"); break;
00058 case NORM_ZMUV: return("zero-mean,unit-var"); break;
00059 default:
00060 CV_Error(-1, "bad normopt");
00061 }
00062 return "?";
00063 }
00064
00065 void PatchOptions::dump(ostream &output) const {
00066 output << "PatchOptions (win.yxz=" << win.y << "," << win.x << "," << win.z << "; ";
00067 output << "step.yxz=" << step.y << "," << step.x << "," << step.z << "; ";
00068 output << "normopt=" << norm_type_to_string(normopt);
00069 output << ")";
00070 }
00071
00072 void PatchOptions::dump_matlab(ostream &output) const {
00073 output << "clear patopt;\n";
00074 output << "patopt.winsize = [" << win.y << "," << win.x << "," << win.z << "];\n";
00075 output << "patopt.step = [" << step.y << "," << step.x << "," << step.z << "];\n";
00076 output << "patopt.norm = ";
00077 switch(normopt) {
00078 case NORM_NONE: output << 0 << ";\n"; break;
00079 case NORM_ZM: output << 1 << ";\n"; break;
00080 case NORM_ZMUV: output << 2 << ";\n"; break;
00081 }
00082 }
00083
00084
00085 ostream& operator<<(ostream& output, const PatchOptions& opt) {
00086
00087 opt.dump(output);
00088 return output;
00089 }