svm_node* ImgProcessing::imgProcess(IplImage* src){ std::vector<unsigned int> hist; // Mat face = findFace(src); // If we need to find the face Mat face(src); // Otherwise let's just assign the IplImg* to a matrix /** prepare vector **/ hist.clear(); /** Divide image in areas **/ int img_w = face.cols; int img_h = face.rows; int wdh = (int) floor((double)(img_w / NB_COLS)); int hgt = (int) floor((double)(img_h / NB_ROWS)); for (int j = 0; j < NB_ROWS; j++) { for (int i = 0; i < NB_COLS; i++) { int start_w = i * wdh - 1; int end_w = (i+1) * wdh + 1; int start_h = j * hgt - 1; int end_h = (j+1) * hgt + 1; if (j == 0) start_h = 0; if (j == NB_ROWS - 1) end_h = img_h; if (i == 0) start_w = 0; if (i == NB_COLS - 1) end_w = img_w; /** Process sub-area **/ CvRect roi = cvRect(start_w, start_h, (end_w - start_w), (end_h - start_h)); Mat dst = processLbp(face(roi)); /** Compute histogram **/ std::vector<unsigned int> tmp = histogramProcess(dst); for (unsigned int k = 0; k < tmp.size(); k++) { hist.push_back(tmp[k]); } } } std::vector<double> scHist = scaleHist(hist); return dataProcess(scHist); }
void HwwNoteFigs(TString filename = "../histo_tmva_new-ntuples-1_160_0.root", int mass = 170, int ReBin = 4, int ysel = 0) { TFile* infile = new TFile(filename.Data(),"READ"); setTDRStyle(0); //BDTD dists TCanvas* c1 = new TCanvas("c1","c1",0,-200,500,500); TH1F* histoBg = histo4->Clone(); histoBg->Add(histo3); histoBg->Add(histo2); histoBg->Add(histo1); TH1F* histo_4 = histo4->Clone(); histo3->Add(histo_4); TH1F* histo_3 = histo3->Clone(); histo2->Add(histo_3); TH1F* histo_2 = histo2->Clone(); histo1->Add(histo_2); histo1->Rebin(ReBin); histo1->SetFillColor(kBlue); histo1->SetFillStyle(1001); histo1->SetLineStyle(0); histo1->SetLineWidth(0); histo2->Rebin(ReBin); histo2->SetFillColor(kMagenta); histo2->SetFillStyle(1001); histo2->SetLineStyle(0); histo2->SetLineWidth(0); histo3->Rebin(ReBin); histo3->SetFillColor(kGreen); histo3->SetFillStyle(1001); histo3->SetLineStyle(0); histo3->SetLineWidth(0); histo4->Rebin(ReBin); histo4->SetFillColor(kCyan); histo4->SetFillStyle(1001); histo4->SetLineStyle(0); histo4->SetLineWidth(0); char YTitle[300]; sprintf(YTitle,"events / bin"); char XTitle[300]; sprintf(XTitle,"BDT Output"); histo0->SetYTitle(YTitle); histo1->SetYTitle(YTitle); histo2->SetYTitle(YTitle); histo3->SetYTitle(YTitle); histo4->SetYTitle(YTitle); histo0->SetXTitle(XTitle); histo1->SetXTitle(XTitle); histo2->SetXTitle(XTitle); histo3->SetXTitle(XTitle); histo4->SetXTitle(XTitle); histo1->SetTitleSize(0.05, "X"); histo1->GetXaxis()->SetTitleFont(62); histo1->GetXaxis()->SetLabelFont(61); histo1->GetYaxis()->SetLabelFont(61); histo1->GetYaxis()->SetTitleOffset(1.3); histo1->SetLabelSize(0.04, "Y"); histo1->SetLabelSize(0.04, "X"); int min = histoBg->FindBin(-1.5); int max = histoBg->FindBin(1.5); histoBg->GetXaxis()->SetRange(min,max); histoBg->SetMarkerStyle(20); histoBg->SetMarkerSize(1.0); histoBg->GetYaxis()->SetTitleOffset(1.40); histo0->SetMarkerStyle(21); histo0->SetMarkerSize(1.0); histoBg->Rebin(ReBin); histo0->Rebin(ReBin); histoBg->SetLineColor(4); histo0->SetLineColor(1); scaleHist(histoBg); scaleHist(histo0); cout << "bg events: " << histoBg->GetSumOfWeights() << endl; cout << "si events: " << histo0->GetSumOfWeights() << endl; histoBg->SetYTitle("Events"); histo1->SetMinimum(0.01); if(ysel == 0) { histo1->Draw("hist"); } else { histo0->Draw("E"); histo1->Draw("hist,same"); } histo2->Draw("hist,same"); histo3->Draw("hist,same"); histo4->Draw("hist,same"); histo0->Draw("E, same"); //histoBg->DrawCopy("hist"); //histo0->DrawCopy("hist,same"); TLegend* leg = new TLegend(0.63, 0.75, 0.92, 0.92); leg->SetFillColor(0); char theSLine[100]; if(mass != 999) sprintf(theSLine,"Signal, m_{H}=%d GeV",mass); else sprintf(theSLine,"WW"); cout << theSLine << endl; leg ->AddEntry(histo0,theSLine); leg ->AddEntry(histo4,"W+Jets, W#gamma","F"); leg ->AddEntry(histo3,"di-boson","F"); leg ->AddEntry(histo2,"t#bar{t}, tW","F"); leg ->AddEntry(histo1,"Drell-Yan","F"); leg->Draw("same"); TString fileOutput1(filename.Data()); TString theLine = "_"; theLine = theLine + "plot.eps"; fileOutput1.ReplaceAll(".root",theLine.Data()); fileOutput1.ReplaceAll("../",""); fileOutput1.ReplaceAll("rootfiles_fastsim/",""); fileOutput1.ReplaceAll("rootfiles_fullsim/",""); c1->SaveAs(fileOutput1.Data()); //return; //-------------------------------- TCanvas* c3 = new TCanvas("c3","c3",550,-200,500,500); c3->SetLogx(); c3->SetLogy(); gPad->SetGrid(1,1); TGraphErrors* gBDTD = makeGraphFromHists(histo0, histoBg); gBDTD->Draw("APXl"); TH1* zBDTD = gBDTD->GetHistogram(); zBDTD->SetXTitle("Signal Events"); zBDTD->SetYTitle("Signal/Background"); //zBDTD->SetYTitle("Background Events"); //zBDTD->DrawCopy(); TLegend* leg3 = new TLegend(0.7, 0.7, 0.9, 0.9); leg3->SetFillColor(0); leg3->AddEntry(gBDTD,theSLine,"lp"); leg3->Draw("same"); TString fileOutput2(filename.Data()); theLine = "_"; theLine = theLine + "counts.eps"; fileOutput2.ReplaceAll(".root",theLine.Data()); fileOutput2.ReplaceAll("../",""); fileOutput2.ReplaceAll("rootfiles_fastsim/",""); fileOutput2.ReplaceAll("rootfiles_fullsim/",""); c3->SaveAs(fileOutput2.Data()); }