void secondMetric(){ ofstream outputFile("Second_Metric.txt"); outputFile << "Util\tRM\tRMdev\tSJF\tSJFdev\tMUF\tMUFdev" << endl; cout << "Util\tRM\tRMdev\tSJF\tSJFdev\tMUF\tMUFdev" << endl; for (double u=0.1; u < 1; u += 0.1){ vector<double> rmPercentageCompletions; vector<double> sjfPercentageCompletions; vector<double> mufPercentageCompletions; for (int taskSetCounter = 0; taskSetCounter < 100; taskSetCounter++) { vector<Task> taskSet = TaskSetFactory::generateTaskSet(u, METRIC2_SET_SIZE, METRIC2_PERIOD_MIN, METRIC2_PERIOD_MAX); sjfPercentageCompletions.push_back(simulateExecution(taskSet, SJF)); mufPercentageCompletions.push_back(simulateExecution(taskSet, MUF)); rmPercentageCompletions.push_back(simulateExecution(taskSet, RM)); } double rmMean = accumulate(rmPercentageCompletions.begin(), rmPercentageCompletions.end(), 0.0) /rmPercentageCompletions.size(); double rmStdDev = stdDev(rmPercentageCompletions, rmMean); double sjfMean = accumulate(sjfPercentageCompletions.begin(), sjfPercentageCompletions.end(), 0.0) / sjfPercentageCompletions.size(); double sjfStdDev = stdDev(sjfPercentageCompletions, sjfMean); double mufMean = accumulate(mufPercentageCompletions.begin(), mufPercentageCompletions.end(), 0.0) / mufPercentageCompletions.size(); double mufStdDev = stdDev(mufPercentageCompletions, mufMean); outputFile << u << "\t" << rmMean << "\t" << rmStdDev << "\t" << sjfMean << "\t" << sjfStdDev << "\t" << mufMean << "\t" << mufStdDev << endl; cout << u << "\t" << rmMean << "\t" << rmStdDev << "\t" << sjfMean << "\t" << sjfStdDev << "\t" << mufMean << "\t" << mufStdDev << endl; } cout << "Data file created: Second_Metric.txt" << endl; }
/** *@brief ŒÆËãÍŒÏñµÄ¹ýÂËÖµ *@param *@return */ bool CalHOT::GetHalfData(hotType *blueBand,hotType *redBand,int x ,int y, float* halfData) { int count0 = 0; double sum = 0.0, avg = 0.0,stdev = 0.0; float *scaleData = (float *)CPLMalloc(sizeof(float) * x * y); for (int i = 0; i < x * y; i++) { if (redBand[i] != 0) { scaleData[i] = ((float)blueBand[i]) / redBand[i]; sum += scaleData[i]; } else { count0++; } } int len = x * y - count0; //ÆœŸùÖµ avg = sum / len; stdev = stdDev(scaleData,len,avg); cout<<"ÆœŸùÖµ£º"<<avg<<" Ÿù·œ²î£º"<<stdev<<endl; //ÔÚŸù·œ²îÖÜΧ1/2²š¶¯ float gtHalf = avg + stdev * 1 / 2; float mtHalf = avg - stdev * 1 / 2; count0 = 0; for(int j = 0; j < x * y; j++) { if(blueBand[j]!= 0) { sum += blueBand[j]; } else { count0++; } } len = x * y - count0; //ÆœŸùÖµ float bandAvg = sum / len;; //·œ²î float bandDev = stdDev(blueBand,len,bandAvg); //²š¶ÎÖÐÐèÒª¹»ÂʵôµÄÖµ float bandFilter = bandAvg + bandDev * 1 / 2; cout<<"¹ýÂ˵ÄÖµ£º"<<bandFilter<<endl; CPLFree(scaleData); halfData[0] = gtHalf; halfData[1] = mtHalf; halfData[2] = bandFilter; return true; }
void Objectness::illustrate() { Mat xP1f, xN1f; CV_Assert(matRead(_modelName + ".xP", xP1f) && matRead(_modelName + ".xN", xN1f)); CV_Assert(xP1f.cols == xN1f.cols && xP1f.cols == _W*_W && xP1f.type() == CV_32F && xN1f.type() == CV_32F); Mat meanP, meanN, stdDevP, stdDevN; meanStdDev(xP1f, meanP, stdDevP); meanStdDev(xN1f, meanN, stdDevN); Mat meanV(_W, _W*2, CV_32F), stdDev(_W, _W*2, CV_32F); meanP.reshape(1, _W).copyTo(meanV.colRange(0, _W)); meanN.reshape(1, _W).copyTo(meanV.colRange(_W, _W*2)); stdDevP.reshape(1, _W).copyTo(stdDev.colRange(0, _W)); stdDevN.reshape(1, _W).copyTo(stdDev.colRange(_W, _W*2)); normalize(meanV, meanV, 0, 255, NORM_MINMAX, CV_8U); CmShow::showTinyMat(_voc.resDir + "PosNeg.png", meanV); FILE* f = fopen(_S(_voc.resDir + "PosNeg.m"), "w"); CV_Assert(f != NULL); fprintf(f, "figure(1);\n\n"); PrintVector(f, getVector(meanP), "MeanP"); PrintVector(f, getVector(meanN), "MeanN"); PrintVector(f, getVector(stdDevP), "StdDevP"); PrintVector(f, getVector(stdDevN), "StdDevN"); PrintVector(f, getVector(_svmFilter), "Filter"); fprintf(f, "hold on;\nerrorbar(MeanP, StdDevP, 'r');\nerrorbar(MeanN, StdDevN, 'g');\nhold off;"); fclose(f); }
TEST(RealVectorStatistics, StdDev) { double inputData[] = {100, 300, 500, 700.12, 200, 400, 600, 800}; unsigned numElements = sizeof(inputData)/sizeof(inputData[0]); NimbleDSP::RealVector<double> buf(inputData, numElements); EXPECT_TRUE(FloatsEqual(244.9664736827704, stdDev(buf))); }
double SampleStatistic::confidence(double p_value) const { // IT_IT("SampleStatistic::confidence(double p_value)"); int df = n - 1; if (df <= 0) return HUGE_VAL; double t = tval((1.0 + p_value) * 0.5, df); if (t == HUGE_VAL) return t; else return (t * stdDev()) / sqrt(double(n)); }
VectorDouble MatrixDouble::getStdDev() const{ VectorDouble mean = getMean(); VectorDouble stdDev(cols,0); for(unsigned int j=0; j<cols; j++){ for(unsigned int i=0; i<rows; i++){ stdDev[j] += (dataPtr[i][j]-mean[j])*(dataPtr[i][j]-mean[j]); } stdDev[j] = sqrt( stdDev[j] / double(rows-1) ); } return stdDev; }
VectorFloat MatrixFloat::getStdDev() const{ VectorFloat mean = getMean(); VectorFloat stdDev(cols,0); for(unsigned int j=0; j<cols; j++){ for(unsigned int i=0; i<rows; i++){ stdDev[j] += (dataPtr[i*cols+j]-mean[j])*(dataPtr[i*cols+j]-mean[j]); } stdDev[j] = sqrt( stdDev[j] / Float(rows-1) ); } return stdDev; }
double SampleStatistic::confidence(int interval) const { // IT_IT("SampleStatistic::confidence(int interval)"); int df = n - 1; if (df <= 0) return HUGE_VAL; double t = tval(double(100 + interval) * 0.005, df); if (t == HUGE_VAL) return t; else return (t * stdDev()) / sqrt(double(n)); }
void Toolbox::initWeightsGaussian(DataSet &X) { //Initialise weights. We use the seed (or clock) to initiliaze random number //generator if (seed==0){ srand( (unsigned)time( NULL ) ); } else { srand(seed); } int nbRawFeatures = X.getNumberofRawFeatures(); double specificWeight; //Initialise weights dVector w(pFeatureGenerator->getNumberOfFeatures()); double widthRangeWeight = fabs(maxRangeWeights - minRangeWeights); // mean and std_dev dVector mean(nbRawFeatures); dVector stdDev(nbRawFeatures); calculateGlobalMeanAndStd(X,mean,stdDev); //Initialize weights with global mean and standard deviation // Only initialize the values especific to the HMM-like HCRF featureVector* vecFeatures = getAllFeatures(X); feature* pFeature = vecFeatures->getPtr(); for(int j = 0; j < vecFeatures->size(); j++, pFeature++) { switch(pFeature->nodeIndex) { case SQUARE_RAW_FEATURE_ID: specificWeight = -1.0/(2.0*pow(stdDev[(int)pFeature->value],2)); w.setValue(pFeature->globalId,specificWeight); break; case ONE_FEATURE_ID: specificWeight = (( (-pow( mean[(int)pFeature->value], 2))/ (2.0*pow(mean[(int)pFeature->value],2))) -(log(sqrt(3.141516*stdDev[(int)pFeature->value])))); w.setValue(pFeature->globalId,specificWeight); break; case RAW_FEATURE_ID: specificWeight = (mean[(int)pFeature->value])/(stdDev[(int)pFeature->value]); w.setValue(pFeature->globalId,specificWeight); break; default: w.setValue(pFeature->globalId,(((double)rand())/(double)RAND_MAX)*widthRangeWeight+minRangeWeights); } } pModel->setWeights(w); }
VectorFloat ClassificationData::getStdDev() const{ VectorFloat mean = getMean(); VectorFloat stdDev(numDimensions,0); for(UINT j=0; j<numDimensions; j++){ for(UINT i=0; i<totalNumSamples; i++){ stdDev[j] += SQR(data[i][j]-mean[j]); } stdDev[j] = sqrt( stdDev[j] / Float(totalNumSamples-1) ); } return stdDev; }
VectorDouble LabelledClassificationData::getStdDev(){ VectorDouble mean = getMean(); VectorDouble stdDev(numDimensions,0); for(UINT j=0; j<numDimensions; j++){ for(UINT i=0; i<totalNumSamples; i++){ stdDev[j] += SQR(data[i][j]-mean[j]); } stdDev[j] = sqrt( stdDev[j] / double(totalNumSamples-1) ); } return stdDev; }
int main(int argc, char** argv) { //the options struct holds all run-time options. options opt; opt.overwrite = false ; opt.gaussBool = false ; //Initialize --overwrite flag to false. Probably should handle //this in read_options. opt.polyFit = false ; vector<double> data ; double avg, std ; vector <vector<double> > hist ; read_options(argc, argv, opt) ; //Print run-time parameters cout << "inFile : " << opt.inFile << endl ; cout << "outFile: " << opt.outFile << endl ; cout << "numBins: " << opt.numBins << endl ; cout << "overwrite : " ; if (opt.overwrite) { cout << "True" << endl ; } else { cout << "False" << endl; } if ( opt.gaussBool ) { cout << "Gaussian fit file : " << opt.gaussFile << endl; } if ( opt.polyFit ) { cout << "Polynomial fit file : " << opt.polyfitFile << endl; cout << "Number of terms : " << opt.numTerms << endl ; } //Begin program data = read_data(opt.inFile) ; cout << endl; avg = average(data) ; cout << "average = " << avg << endl; std = stdDev(data,avg) ; cout << "std = " << std << endl ; hist = histogram(data, opt.numBins) ; print(hist,opt.outFile); if (opt.gaussBool) print_gauss(hist, opt.gaussFile, std, avg) ; if (opt.polyFit) fit_polynomial(hist,avg, opt.numTerms, opt.polyfitFile) ; return 0; }
//°ÑÑÚÄ€ŒÓÈ뵜͌ÏñÖÐ void CalHOT::InsertScaleToBandArray(hotType *bandArray,float *scaleData) { //ÆœŸùÖµ float bandAvg = stdAvg(bandArray); //·œ²î float bandDev = stdDev(bandArray,effectLen,bandAvg); //²š¶ÎÖÐÐèÒª¹»ÂʵôµÄÖµ float bandFilter = bandAvg + bandDev * 1 / 2; cout<<"计算"<<bandFilter<<endl; for (int i = 0; i < x * y; i++) { if (scaleData[i] == unEffectValue || bandArray[i] > bandFilter) { bandArray[i] = unEffectValue; } } }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> void QcPlugin::generateAlert(const QcBuffer *shortBuffer, const QcBuffer *longBuffer) const { if ( shortBuffer->empty() || longBuffer->empty() ) return; //shortBuffer->info(); Short Term buffer info //lta->info(); Long Term buffer info double sta = mean(shortBuffer); //double staStdDev = stdDev(shortBuffer, sta); double lta = mean(longBuffer); double ltaStdDev = stdDev(longBuffer, lta); double relative = 0.0; //! HACK if (ltaStdDev != 0.0) relative = 100.0 - ( (ltaStdDev - fabs(lta - sta)) / ltaStdDev ) * 100.0; string f = "\033[32m"; // green colour if (fabs(relative) > *(_qcConfig->alertThresholds().begin())) { // HACK multi thresholds not yet implemented! DataModel::WaveformQuality* obj = new DataModel::WaveformQuality(); obj->setWaveformID(getWaveformID(_streamID)); obj->setCreatorID(_app->creatorID()); obj->setCreated(Core::Time::GMT()); obj->setStart(shortBuffer->startTime()); obj->setEnd(shortBuffer->endTime()); obj->setType("alert"); obj->setParameter(_parameterNames[0]); obj->setValue(sta); obj->setLowerUncertainty(relative); obj->setUpperUncertainty(lta); obj->setWindowLength((double)shortBuffer->length()); pushObject(obj); f = "\033[31m"; // red colour SEISCOMP_WARNING("%s %s %s %.0f%% \033[30m %.3f %.3f", _streamID.c_str(), _parameterNames[0].c_str(), f.c_str(), relative, fabs(relative), lta); } }
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> void QcPlugin::generateReport(const QcBuffer *buf) const { if ( buf->empty() ) return; double mean_ = mean(buf); double stdDev_ = stdDev(buf, mean_); DataModel::WaveformQuality* obj = new DataModel::WaveformQuality(); obj->setWaveformID(getWaveformID(_streamID)); obj->setCreatorID(_app->creatorID()); obj->setCreated(Core::Time::GMT()); obj->setStart(buf->startTime()); obj->setEnd(buf->endTime()); obj->setType("report"); obj->setParameter(_parameterNames[0]); obj->setValue(mean_); obj->setLowerUncertainty(stdDev_); obj->setUpperUncertainty(stdDev_); obj->setWindowLength((double)buf->length()); pushObject(obj); }
MatrixFloat ClassificationData::getClassStdDev() const{ MatrixFloat mean = getClassMean(); MatrixFloat stdDev(getNumClasses(),numDimensions); VectorFloat counter(getNumClasses(),0); stdDev.setAllValues( 0 ); for(UINT i=0; i<totalNumSamples; i++){ UINT classIndex = getClassLabelIndexValue( data[i].getClassLabel() ); for(UINT j=0; j<numDimensions; j++){ stdDev[classIndex][j] += SQR(data[i][j]-mean[classIndex][j]); } counter[ classIndex ]++; } for(UINT k=0; k<getNumClasses(); k++){ for(UINT j=0; j<numDimensions; j++){ stdDev[k][j] = sqrt( stdDev[k][j] / Float(counter[k]-1) ); } } return stdDev; }
/// stdDevValue double TimeSeriesFloodPlotData::stdDevValue() const { return stdDev(m_timeSeries.values()); }
void process ( std::vector<OutputFeatures> & outBuffer ) { if (m_inputBuffer.size() < m_deltaFilter.size()) return; const int inputBufSize = m_inputBuffer.size(); const int deltaFilterSize = m_deltaFilter.size(); // compute deltas for new inputs and populate delta buffer const int lastInputToProcess = inputBufSize - deltaFilterSize; for (int idx = m_deltaBuffer.size(); idx <= lastInputToProcess; ++idx) { DeltaFeatures deltaFeatures; deltaFeatures[ENTROPY_DELTA] = delta( vector(ENTROPY, idx, deltaFilterSize) ); deltaFeatures[MFCC2_DELTA] = delta( vector(MFCC2, idx, deltaFilterSize) ); deltaFeatures[MFCC3_DELTA] = delta( vector(MFCC3, idx, deltaFilterSize) ); deltaFeatures[MFCC4_DELTA] = delta( vector(MFCC4, idx, deltaFilterSize) ); m_deltaBuffer.push_back( deltaFeatures ); } // compute statistics on inputs & deltas const int lastDeltaToProcess = (int) m_deltaBuffer.size() - m_windowSize; int idx; for (idx = 0; idx <= lastDeltaToProcess; idx += m_stepSize) { int input_idx = idx + m_halfFilterLen; Vector gate_vector = vector(ENERGY_GATE, input_idx, m_windowSize); #define INPUT_VECTOR( feature ) \ vector(feature, input_idx, m_windowSize), gate_vector #define DELTA_VECTOR( feature ) \ vector(feature, idx, m_windowSize), gate_vector OutputFeatures output; output[ENTROPY_MEAN] = mean( INPUT_VECTOR( ENTROPY ) ); output[PITH_DENSITY_MEAN] = mean( INPUT_VECTOR( PITCH_DENSITY ) ); output[TONALITY_MEAN] = mean( INPUT_VECTOR( TONALITY ) ); output[TONALITY1_MEAN] = mean( INPUT_VECTOR( TONALITY1 ) ); output[FOUR_HZ_MOD_MEAN] = mean( INPUT_VECTOR( FOUR_HZ_MOD ) ); output[MFCC2_MEAN] = mean( INPUT_VECTOR( MFCC2 ) ); output[MFCC3_MEAN] = mean( INPUT_VECTOR( MFCC3 ) ); output[MFCC4_MEAN] = mean( INPUT_VECTOR( MFCC4 ) ); output[ENTROPY_DELTA_VAR] = variance( DELTA_VECTOR( ENTROPY_DELTA ) ); float tonalityMean = output[TONALITY_MEAN]; float tonalityVar = variance( INPUT_VECTOR( TONALITY ), tonalityMean ); output[TONALITY_FLUCT] = tonalityMean != 0.f ? tonalityVar / (tonalityMean * tonalityMean) : 0.f; output[MFCC2_STD] = stdDev( INPUT_VECTOR( MFCC2 ), output[MFCC2_MEAN] ); output[MFCC3_STD] = stdDev( INPUT_VECTOR( MFCC3 ), output[MFCC3_MEAN] ); output[MFCC4_STD] = stdDev( INPUT_VECTOR( MFCC4 ), output[MFCC4_MEAN] ); output[MFCC2_DELTA_STD] = stdDev( DELTA_VECTOR( MFCC2_DELTA ) ); output[MFCC3_DELTA_STD] = stdDev( DELTA_VECTOR( MFCC3_DELTA ) ); output[MFCC4_DELTA_STD] = stdDev( DELTA_VECTOR( MFCC4_DELTA ) ); float gate_mean = 0.f; float *gate_data = gate_vector.data; for (int i = 0; i < gate_vector.samples; ++i, gate_data += gate_vector.observations) gate_mean += *gate_data; gate_mean /= gate_vector.samples; output[ENERGY_GATE_MEAN] = gate_mean; outBuffer.push_back(output); #undef INPUT_VECTOR #undef DELTA_VECTOR } // remove processed inputs & deltas m_inputBuffer.erase( m_inputBuffer.begin(), m_inputBuffer.begin() + idx ); m_deltaBuffer.erase( m_deltaBuffer.begin(), m_deltaBuffer.begin() + idx ); }
int main (int argc, char *argv[]) { FILE *inAFile, *inBFile, *inMaskFile; FILE *outAFile, *outBFile; uint16_t bufA[BUFF_SIZE]; uint16_t bufB[BUFF_SIZE]; uint16_t bufMask[BUFF_SIZE]; int histoA[DSP_RANGE]; int histoB[DSP_RANGE]; int maskedHistoA[DSP_RANGE]; int maskedHistoB[DSP_RANGE]; //negative of A mask int count = 0; int maxA = 0; int maxB = 0; int maskedMaxA = 0; int maskedMaxB = 0; int minA = 60000; int minB = 60000; int maskedMinA = 60000; int maskedMinB = 60000; int blackPointA = 0; int blackPointB = 0; int whitePointA = 0; int whitePointB = 0; int clippedBlackA = 0; int clippedWhiteA = 0; int clippedBlackB = 0; int clippedWhiteB = 0; float averageA = 0; float maskedAverageA = 0; float maskedAverageB = 0; float stdDevA = 0; float maskedStdDevA = 0; float maskedStdDevB = 0; float averageB = 0; float stdDevB = 0; int offsetA = OFFSET_A; int offsetB = OFFSET_B; int maskedOffsetA = MASKED_OFFSET_A; int maskedOffsetB = MASKED_OFFSET_B; float sigmaA = SIGMA_A; float sigmaB = SIGMA_B; float maskedSigmaA = MASKED_SIGMA_A; float maskedSigmaB = MASKED_SIGMA_B; if (argc != 4) { printf("\nError: need infile and outfile"); exit(1); } outAFile = fopen("outA.dat", "w"); if (outAFile == 0) { printf("\nError: could not open shit"); exit (1); } outBFile = fopen("outB.dat", "w"); if (outBFile == 0) { printf("\nError: could not open shit"); exit (1); } //inAFile = fopen("rawB.dat", "r"); inAFile = fopen(argv[1], "r"); if (inAFile == 0) { printf("\nError: could not open inAfile"); exit(1); } printf("\n opening the file"); inBFile = fopen(argv[2], "r"); if (inBFile == 0) { printf("\nError: could not open inBfile"); exit(1); } //printf("\n opening the last file"); inMaskFile = fopen(argv[3], "r"); //printf("\n opened it "); if (inMaskFile == 0) { printf("\nError: could not open outfile"); exit(1); } printf("\ngot the right arguments all files opened"); // int k = 0; //while ((count = fillBuff(bufA, inAFile)) == fillBuff(bufB, inBFile) && // (count == fillBuff(bufMask, inMaskFile)) && // count != 0) ///////////////////////////////////////////////////dddddddddddddddddddd printf("\nstarting hard shit"); clearHisto(histoA); clearHisto(histoB); clearHisto(maskedHistoA); clearHisto(maskedHistoB); while (((count = fillBuff(bufA, inAFile)) != 0 ) && (fillBuff(bufMask, inMaskFile) != 0)) //while ((count = fillBuff(bufA, inAFile)) == fillBuff(bufB, inBFile) && // (count == fillBuff(bufMask, inMaskFile)) && // count != 0) { makeHisto (bufA, histoA, &maxA, &minA); makeMaskedHisto(bufA, bufMask, maskedHistoA, &maskedMaxA, &maskedMinA); } rewind(inMaskFile); while (((count = fillBuff(bufB, inBFile)) != 0 ) && (fillBuff(bufMask, inMaskFile) != 0)) //while ((count = fillBuff(bufA, inAFile)) == fillBuff(bufB, inBFile) && // (count == fillBuff(bufMask, inMaskFile)) && // count != 0) { makeHisto (bufB, histoB, &maxB, &minB); negateMask(bufMask); //mask fire makeMaskedHisto(bufB, bufMask, maskedHistoB, &maskedMaxB, &maskedMinB); //makeHisto (bufB, histoB, &maxB, &minB); //printf("\nread = %d", bufA[2]); //printf("\n maxA = %d, minA = %d", maxA, minA); //makeHisto (bufB, histoB, &maxB, &minB); //makeMaskedHisto(bufA, bufMask, maskedHistoA, &maxA, &minA); //makeMaskedHisto(bufB, bufMask, maskedHistoB, &maxB, &minB); } count = 0; int i; for (i=0;i<DSP_RANGE;i++) count += histoA[i]; printf("\nread %d pixels", count); averageA = averageHisto(histoA); maskedAverageA = averageHisto(maskedHistoA); maskedAverageB = averageHisto(maskedHistoB); averageB = averageHisto(histoB); stdDevA = stdDev(histoA, averageA); maskedStdDevA = stdDev(maskedHistoA, maskedAverageA); maskedStdDevB = stdDev(maskedHistoB, maskedAverageB); stdDevB = stdDev(histoB, averageB); printf("\nmaxA = %d minA = %d", maxA, minA); printf("\naverage A = %f", averageA); printf("\nstddev A = %f, sigmaA = %f, offsetA = %d", stdDevA, sigmaA, offsetA); printf("\nmaskedmaxA = %d maskedminA = %d", maskedMaxA, maskedMinA); printf("\nmasked average A = %f", maskedAverageA); printf("\nsmasked tddev A = %f, masked sigma = %f, masked offset = %d", maskedStdDevA, maskedSigmaA, maskedOffsetA); printf("\nmaxB = %d minB = %d", maxB, minB); printf("\naverage B = %f", averageB); printf("\nstddev B = %f, sigmab = %f, offsetb = %d", stdDevB, sigmaB, offsetB); printf("\nmaskedmaxB = %d maskedminB = %d", maskedMaxB, maskedMinB); printf("\nmasked average B = %f", maskedAverageB); printf("\nsmasked tddev B = %f, masked sigma = %f, masked offset = %d", maskedStdDevB, maskedSigmaB, maskedOffsetB); // buildLUT(histoA, averageA, stdDevA, offsetA, sigmaA); buildLUT(maskedHistoA, maskedAverageA, maskedStdDevA, maskedOffsetA, maskedSigmaA); //buildLUT(histoB, averageB, stdDevB, offsetB, sigmaB); buildLUT(maskedHistoB, maskedAverageB, maskedStdDevB, maskedOffsetB, maskedSigmaB); averageA = averageHisto(histoA); maskedAverageA = averageHisto(maskedHistoA); averageB = averageHisto(histoB); maskedAverageB = averageHisto(maskedHistoB); printf("\naverage A pixel value = %f", averageA); printf("\nmasked average A pixel value = %f", maskedAverageA); printf("\naverage B pixel value = %f", averageB); // printf("\nblackpoint A = %d, whitepoint A = %d", blackPointA, //whitePointA); //stretch the data rewind(inAFile); rewind(inBFile); // rewind(inMaskFile); while (((count = fillBuff(bufA, inAFile)) != 0 ) && (fillBuff(bufB, inBFile) !=0)) { //contrastStretch(bufA, histoA,&clippedBlackA, // &clippedWhiteA, outAFile); contrastStretch(bufA, maskedHistoA,&clippedBlackA, &clippedWhiteA, outAFile); contrastStretch(bufB, maskedHistoB,&clippedBlackB, &clippedWhiteB, outBFile); } printf("\nContrast stretch complete"); printf("\nclippedblackA %d, clippedwhiteA %d", clippedBlackA, clippedWhiteA); printf("\nclippedblackB %d, clippedwhiteB %d", clippedBlackB, clippedWhiteB); /* fclose(inAFile); fclose(inBFile); fclose(outAFile); */ return 0; }
void NormalizedPatchModel::meanAndStdDev(const std::vector<float>& v, float& m, float& s) { m = mean(v); s = stdDev(v, m); }