void ossimHistogramEqualization::computeAccumulationHistogram()
{
   if(getHistogram().valid())
   {
      theAccumulationHistogram = getHistogram()->createAccumulationLessThanEqual();
   }
}
ossimHistogramEqualization::ossimHistogramEqualization(ossimImageSource* inputSource,
                                                       ossimRefPtr<ossimMultiResLevelHistogram> histogram)
   : ossimImageSourceHistogramFilter(inputSource, histogram),
     theTile(0),
     theAccumulationHistogram(0),
     theInverseFlag(false)
{
   if(getHistogram().valid())
   {
      theAccumulationHistogram = getHistogram()->createAccumulationLessThanEqual();
      initializeLuts();
   }
}
rspfHistogramEqualization::rspfHistogramEqualization(rspfImageSource* inputSource,
                                                       rspfRefPtr<rspfMultiResLevelHistogram> histogram,
                                                       bool inverseFlag)
   : rspfImageSourceHistogramFilter(inputSource, histogram),
     theTile(NULL),
     theAccumulationHistogram(0),
     theInverseFlag(inverseFlag)
{
   if(getHistogram().valid())
   {
      theAccumulationHistogram = getHistogram()->createAccumulationLessThanEqual();
      initializeLuts();
   }
}
Esempio n. 4
0
void FrameDisplay::paintEvent(QPaintEvent * ev) {
   int* values;
   if (frameData!=NULL) {
      // if we have a frame...
      applyRawMode();
      painter_->begin(this);
      painter_->setClipRegion(ev->region());
      // load frame in widget
      QImage* tmpImage=new QImage((unsigned char*)frameData->data[0],frameWidth,frameHeight,QImage::Format_RGB888);
      painter_->drawImage(0,0,*tmpImage);
      delete tmpImage;
      painter_->end();

      values=getHistogram(frameWidth,frameHeight,(unsigned char*)frameData->data[0]);
      if(histogram!=NULL) {
         histogram->setValues(values);
         histogram->repaint();
      }
      free(values);
   } else {
      // no frame...
      painter_->begin(this);
      painter_->setClipRegion(ev->region());
      // black rect
      painter_->fillRect(0,0,width(),height(),Qt::black);
      painter_->end();
      values=(int*)malloc(256*sizeof(int));
      memset(values,0,256*sizeof(int));
      if(histogram!=NULL) {
         histogram->setValues(values);
         histogram->repaint();
      }
      free(values);
   }
}
//--------------------------------------------------------------------------------------------------
//
cv::Mat
Histogram1D::getHistogramImage( const cv::Mat& image )
{
	// Compute histogram first
	cv::MatND hist = getHistogram( image );

	// Get min and max bin values
	double maxVal{ };
	double minVal{ };

	cv::minMaxLoc( hist, &minVal, &maxVal, 0, 0 );

	// Image on which to display histogram
	cv::Mat histImg( histSize_[0], histSize_[0], CV_8U, cv::Scalar( 255 ) );

	// set highest point at 90% of nbins
	int hpt = static_cast<int>( 0.9 * histSize_[0] );

	// Draw vertical line for each bin
	for( int h = 0; h < histSize_[0]; ++h )
	{
		float binVal = hist.at< float >( h );
		int intensity = static_cast<int>( binVal * hpt / maxVal );

		cv::line( histImg, cv::Point( h, histSize_[0] ),
		          cv::Point( h, histSize_[0] - intensity ), cv::Scalar::all( 0 ) );
	}

	return histImg;
}
Esempio n. 6
0
void Image::gaussianNoise(double mean, double standardDeviation) {
    int w = img->width();
    int h = img->height();
    int r, g, b;
    QRgb rgb;
    double noise;

    srand(unsigned(time(NULL)));
    for (int i = 0; i < w; ++i)
        for (int j = 0; j < h; ++j) {
            noise = gaussGenerator(mean, standardDeviation); 

            rgb = tempImg->pixel(i, j);
            r = qRed(rgb); 
            g = qGreen(rgb);
            b = qBlue(rgb);

            r += (int)noise;
            g += (int)noise;
            b += (int)noise;

            r = r > 255 ? 255 : r;
            r = r <   0 ?   0 : r;
            g = g > 255 ? 255 : g;
            g = g <   0 ?   0 : g;
            b = b > 255 ? 255 : b;
            b = b <   0 ?   0 : b;

            img->setPixel(i, j, qRgb(r, g, b));
        }

    getHistogram();
    update();
}
Esempio n. 7
0
void Image::impulseNoise(double pa, double pb) {
    int w = img->width();
    int h = img->height();
    int r, g, b;
    QRgb rgb;
    double noise;

    srand(unsigned(time(NULL)));
    for (int i = 0; i < w; ++i)
        for (int j = 0; j < h; ++j) {
            noise = impulseGenerator(pa, pb);

            rgb = tempImg->pixel(i, j);

            r = qRed(rgb); 
            g = qGreen(rgb);
            b = qBlue(rgb);

            if (noise == -1)
                r = g = b = 0;
            else if (noise == 1)
                r = g = b = 255;

            r = r > 255 ? 255 : r;
            r = r <   0 ?   0 : r;
            g = g > 255 ? 255 : g;
            g = g <   0 ?   0 : g;
            b = b > 255 ? 255 : b;
            b = b <   0 ?   0 : b;

            img->setPixel(i, j, qRgb(r, g, b));
        }
    getHistogram();
    update();
}
Esempio n. 8
0
int main () {
    char *buffer="hataraitara makekana to omotteiru. "
    "I believe I'm loss if I work. This is a test sentence."
    " Be Storj with you!\n";
    long hist[256];
    int i=0;
    for(i=0;i<256;i++) hist[i]=0;

    getHistogram((unsigned char*)buffer,hist,strlen(buffer));
    ok(hist[' '] == 19,"simple sentence histogram test #space");
    ok(hist['e'] == 10,"simple sentence histogram test #e");
    ok(hist['z'] == 0, "simple sentence histogram test #z");
    ok(hist['\n'] == 1,"simple sentence histogram test #CR");

    double chi=calcChi(hist,strlen(buffer));
    ok( 1955.43<chi && chi<1955.45,"chi test for a simple sentence");

    chi=getFileChi("data/ac59ab5a282afd3de22062c7d62b5367");
    ok( 236.71<chi && chi<236.73,"chi test for 30MB file");
    
    int isEncrypted=isFileEncrypted(
        "data/ac59ab5a282afd3de22062c7d62b5367");
    ok( isEncrypted,
        "whole file encryption detector test for 30MB encrypted file");

    dies_ok({isFileEncrypted("nofile");},
        "no exist file for isFileEncrypted function");
Esempio n. 9
0
cv::Mat Histogram1D::stretch(const cv::Mat &image, int minValue){
	cv::MatND hist = getHistogram(image);
	int imin = 0;
	for( ; imin < m_histSize[0]; imin++){
		//std::cout << hist.at<float>(imin) << std::endl;
		if( hist.at<float>(imin) > minValue )
			break;
	}
	int imax = m_histSize[0] - 1;
	for( ; imax >= 0; imax-- ){
		if(hist.at<float>(imax) > minValue )
			break;
	}

	int dim(256);
	cv::Mat lookup(1, 
					&dim, 
					CV_8U
					);
	for(int i = 0; i < 256; i++){
		if( i < imin ) lookup.at<uchar>(i) = 0;
		else if ( i > imax ) lookup.at<uchar>(i) = 255;
		else lookup.at<uchar>(i) = static_cast<uchar>(
											255.0*(i - imin)/ (imax-imin) + 0.5);

	}
	cv::Mat result;
	result = applyLookUp(image, lookup);
	return result;
}
Esempio n. 10
0
RemapContainer::RemapContainer(QWidget *parent) :
  QWidget(parent)
{
  m_rawVolume.setFile("test.raw");

  m_histogramWidget = new RemapHistogramWidget(this);

  QVBoxLayout *layout = new QVBoxLayout();
  layout->addWidget(m_histogramWidget);
  setLayout(layout);

  setRawMinMax();

  connect(m_histogramWidget, SIGNAL(getHistogram()),
	  this, SLOT(getHistogram()));  
}
TH1* getHistogram(TFile* inputFile, const std::string& channel, double massPoint, 
		  const std::string& directory, const std::string& histogramName, double metResolution)
{
  std::string process = "";
  if   ( massPoint <  95. ) process = "ZToTauTau";
  else                      process = Form("HToTauTau_M-%1.0f", massPoint);
  
  std::string metResolution_label = "";
  if ( metResolution > 0. ) metResolution_label = Form("pfMEtRes%1.0f", metResolution);
  else metResolution_label = "pfMEtResMC";

  std::vector<TH1*> histograms;
  std::string directory_process = 
    //Form("DQMData/%s/%s/%s/%s/plotEntryType1", process.data(), channel.data(), metResolution_label.data(), directory.data());
    Form("DQMData/%s/%s/%s/plotEntryType1", process.data(), channel.data(), directory.data());
  histograms.push_back(getHistogram(inputFile, directory_process, histogramName));
  TH1* histogramSum = NULL;
  for ( std::vector<TH1*>::const_iterator histogram = histograms.begin();
	histogram != histograms.end(); ++histogram ) {
    if ( !histogramSum ) {
      std::string histogramSumName = std::string((*histogram)->GetName()).append("_summed");
      histogramSum = (TH1*)(*histogram)->Clone(histogramSumName.data());
    } else {
      histogramSum->Add(*histogram);
    }
  }

  assert(histogramSum);

  if ( !histogramSum->GetSumw2N() ) histogramSum->Sumw2();
  if ( histogramSum->Integral() > 0. ) histogramSum->Scale(1./histogramSum->Integral());
  
  return histogramSum;
}
Esempio n. 12
0
void BetaGrid::getFlatDescription(std::vector<double>& description) const {
    description.clear();
    double sum = 0.;
    for(unsigned int i = 0; i < m_histogram.size(); i++) {
        for(unsigned int j = 0; j < m_histogram[i].size(); j++) {
            double mean = (getHit()[i][j]+1)/(getHit()[i][j] + getMiss()[i][j]+2);
            double variance = (getHit()[i][j]+1) * (getMiss()[i][j]+1)/
                              ( (getHit()[i][j] + getMiss()[i][j]+2) * (getHit()[i][j] + getMiss()[i][j]+2) *
                                (getHit()[i][j] + getMiss()[i][j] + 3));
            mean = getHistogram()[i][j];
            description.push_back(mean);
// 	    description.push_back(m_hit[i][j]);
            sum += description.back();
        }
    }
    if(sum < 10e-6) {
        for(std::vector<double>::iterator it = description.begin(); it != description.end(); it++) {
            *it = 10e-10;
        }
    } else {
        for(std::vector<double>::iterator it = description.begin(); it != description.end(); it++) {
            *it /= sum;
        }
    }
}
Esempio n. 13
0
	double Phase::getMaxServiceTime() const
	{
	    if ( hasMaxServiceTimeExceeded() ) {
		return getHistogram()->getMax();
	    } else {
		return 0.0;
	    }
	}
TH1* getHistogram(TFile* inputFile, const TString& meName, const TString& process, const TString& region)
{
  TString suffix = "all";
  if      ( region.Contains("p") ) suffix = "passed";
  else if ( region.Contains("f") ) suffix = "failed";
  TString meName_full = Form(meName.Data(), process.Data(), region.Data(), suffix.Data());
  return getHistogram(inputFile, "", meName_full);
}
void makeCaloMEtTriggerEffPlots_Ztautau()
{
//--- stop ROOT from keeping references to all histograms
  TH1::AddDirectory(false);

//--- suppress the output canvas 
  gROOT->SetBatch(true);

  TString inputFilePath = "/data1/veelken/tmp/muonPtGt17/V10_5tauEnRecovery_L1ETM20Eff_v3/2011RunB/tauIdEfficiency/";
  
  TString inputFileName = "analyzeTauIdEffHistograms_all_2011Oct30V10_5tauEnRecovery.root";

  TString dqmDirectory = "";

  TString meName_numerator_data = "%s_%s_numCaloMEt_HLT_IsoMu15_L1ETM20_tauDiscrHPScombLooseDBcorr_%s";
  TString meName_numerator_mc   = "%s_%s_numCaloMEt_L1_ETM20_tauDiscrHPScombLooseDBcorr_%s"; 
  TString meName_denominator    = "%s_%s_denomCaloMEt_tauDiscrHPScombLooseDBcorr_%s"; 

  TObjArray processes;
  processes.Add(new TObjString("Ztautau"));
  processes.Add(new TObjString("Zmumu"));
  processes.Add(new TObjString("WplusJets"));
  processes.Add(new TObjString("QCD"));
  processes.Add(new TObjString("TTplusJets"));

  TString region_passed = "C1p";
  TString region_failed = "C1f";

  TString inputFileName_full = inputFilePath;
  if ( !inputFileName_full.EndsWith("/") ) inputFileName_full.Append("/");
  inputFileName_full.Append(inputFileName);
  std::cout << "opening inputFile = " << inputFileName_full.Data() << std::endl;
  TFile* inputFile = new TFile(inputFileName_full.Data());

  TH1* histogram_numerator_Data_passed    = getHistogram(inputFile, meName_numerator_data, "Data",    region_passed);
  TH1* histogram_denominator_Data_passed  = getHistogram(inputFile, meName_denominator,    "Data",    region_passed);
  TH1* histogram_numerator_mcSum_passed   = getHistogram(inputFile, meName_numerator_mc,   processes, region_passed);
  TH1* histogram_denominator_mcSum_passed = getHistogram(inputFile, meName_denominator,    processes, region_passed);

  TH1* histogram_numerator_Data_failed    = getHistogram(inputFile, meName_numerator_data, "Data",    region_failed);
  TH1* histogram_denominator_Data_failed  = getHistogram(inputFile, meName_denominator,    "Data",    region_failed);
  TH1* histogram_numerator_mcSum_failed   = getHistogram(inputFile, meName_numerator_mc,   processes, region_failed);
  TH1* histogram_denominator_mcSum_failed = getHistogram(inputFile, meName_denominator,    processes, region_failed);

  TString outputFileName = Form("makeCaloMEtTriggerEffPlots_Ztautau.png");
  makePlot_wrapper("",
		   histogram_numerator_Data_passed, histogram_denominator_Data_passed, 
		   histogram_numerator_mcSum_passed, histogram_denominator_mcSum_passed,
		   histogram_numerator_Data_failed, histogram_denominator_Data_failed,  
		   histogram_numerator_mcSum_failed, histogram_denominator_mcSum_failed,
		   "Data", "Simulation", region_passed, region_failed,
		   outputFileName);

  delete inputFile;
}
Esempio n. 16
0
int ImageProcessor::getEntropyThreshold()
{
    // lazy calculation
    if (!isEntropyCaled) {
        // Make sure histogram is calculate
        getHistogram();

        // Sum of x * log(x) with index below thresholdValue
        double belowSumXLogX = 0;
        // Sum of x * log(x) with index upper than threshold value
        double upperSumXLogX = 0;
        for (int i = 0; i < RANGE_OF_8BITS; ++i)
        {
            if (histogram[i] != 0)
            {
                // Log on base e
                upperSumXLogX += histogram[i] * qLn((double)histogram[i]);
            }
        }

        double maxEntropy = 0;

        for (int thresholdValue = 0; thresholdValue < RANGE_OF_8BITS; ++thresholdValue)
        {
            if (histogram[thresholdValue] == 0)
            {
                continue;
            }

            int upperSum = accHistogram[RANGE_OF_8BITS - 1]
                    - accHistogram[thresholdValue];
            if (upperSum == 0)
            {
                break;
            }

            double xLogX = histogram[thresholdValue] * qLn(histogram[thresholdValue]);
            belowSumXLogX += xLogX;
            upperSumXLogX -= xLogX;

            double belowEntropy = qLn(accHistogram[thresholdValue])
                    - belowSumXLogX / accHistogram[thresholdValue];
            double upperEntropy = qLn(upperSum)
                    - upperSumXLogX / upperSum;
            double entropy = belowEntropy + upperEntropy;

            if (entropy > maxEntropy)
            {
                entropyThreshold = thresholdValue;
                maxEntropy = entropy;
            }
        }
        isEntropyCaled = true;
    }
    return entropyThreshold;
}
Esempio n. 17
0
//--------------------------------------------------------------------------------------------------
//
cv::Mat
Histogram1D::stretch( const cv::Mat& image, int32_t minValue )
{
	// Compute histogram first
	cv::MatND hist = getHistogram( image );

	// find left extremity of the histogram
	int imin = 0;

	for( ; imin < histSize_[0]; imin++ )
	{
		std::cout << hist.at< float >( imin ) << std::endl;

		if( hist.at< float >( imin ) > minValue )
		{
			break;
		}
	}

	// find right extremity of the histogram
	int imax = histSize_[0] - 1;
	for( ; imax >= 0; imax-- )
	{
		if( hist.at< float >( imax ) > minValue )
		{
			break;
		}
	}

	// Create lookup table
	int dims[1] = { 256 };
	cv::MatND lookup( 1, dims, CV_8U );

	for( int i = 0; i < 256; ++i )
	{
		if( i < imin )
		{
			lookup.at< uchar >( i ) = 0;
		}
		else if( i > imax )
		{
			lookup.at< uchar >( i ) = 255;
		}
		else
		{
			lookup.at< uchar >( i ) = static_cast<uchar>( 255.0 * (i - imin) /
			                                              (imax - imin) + 0.5 );
		}
	}

	// Apply lookup table
	cv::Mat result;
	result = applyLookUp( image, lookup );

	return result;
}
Esempio n. 18
0
void getHistogramFeatures(const Mat& image, Mat& features) {
  Mat grayImage;
  cvtColor(image, grayImage, CV_RGB2GRAY);

  //grayImage = histeq(grayImage);

  Mat img_threshold;
  threshold(grayImage, img_threshold, 0, 255,
            CV_THRESH_OTSU + CV_THRESH_BINARY);
  features = getHistogram(img_threshold);
}
Esempio n. 19
0
void getHistogramFeatures(const Mat& image, Mat& features) {
  Mat grayImage;
  cvtColor(image, grayImage, CV_RGB2GRAY);

  //grayImage = histeq(grayImage);

  Mat img_threshold;
  threshold(grayImage, img_threshold, 0, 255, CV_THRESH_OTSU + CV_THRESH_BINARY);
  //Mat img_threshold = grayImage.clone();
  //spatial_ostu(img_threshold, 8, 2, getPlateType(image, false));

  features = getHistogram(img_threshold);
}
Esempio n. 20
0
QImage* ImageProcessor::getContrastImage(int contrast)
{
    // make sure histogram is calculated
    getHistogram();

    if (contrastImage) {
        delete contrastImage;
    }

    const uchar* originPtr = originImage->constBits();
    int height = originImage->height();
    int width = originImage->width();

    contrastImage = new QImage(width, height, originImage->format());
    uchar* newPtr = contrastImage->bits();

    int averageBrightness;
    int originColor = 0;
    int adjustedColor = 0;

    // compute averageBrightness
    long brightnessSum = 0;
    for (int i = 0; i < RANGE_OF_8BITS; ++i) {
        brightnessSum += histogram[i];
    }
    averageBrightness = brightnessSum / width / height;

    // adjust each pixel
    for (int i = 0; i < width; ++i) {
        for (int j = 0; j < height; ++j) {
            for (int rgb = 0; rgb < 3; ++rgb) {
                originColor = *(originPtr +
                                PIXEL_SIZE * (width * j + i) + rgb);
                adjustedColor = (int)((double)averageBrightness + (double)
                                      (originColor - averageBrightness)
                                      * (double)contrast / 100);
                if (adjustedColor < 0) {
                    adjustedColor = 0;
                }
                if (adjustedColor > MAX_OF_8BITS) {
                    adjustedColor = MAX_OF_8BITS;
                }
                *(newPtr + PIXEL_SIZE * (width * j + i) + rgb) =
                        adjustedColor;
            }
        }
    }
    return contrastImage;
}
Esempio n. 21
0
void Document::grayWorld()
{
    qDebug() << "Grayworld()";
    const uint N = m_selection.width() * m_selection.height();

    double avg[4];
    for (int i = 1; i <= 3; ++i) {
        const uint* freq = getHistogram(i);
        avg[i] = 0;
        for (int color = 0; color < NCOLORS; ++color)
            avg[i] += (double) freq[color] / N * color;
    }
    avg[0] = (avg[1] + avg[2] + avg[3]) / 3;

    concurrentMap(GrayWorld(avg));
}
Esempio n. 22
0
void ossimHistogramRemapper::setNullCount()
{
   // This will set the null bucket for all res zero bands to zero!
   if (getHistogram(0).valid())
   {
      const ossim_uint32 BANDS = theHistogram->getNumberOfBands();
      for (ossim_uint32 band = 0; band < BANDS; ++band)
      {
         ossimRefPtr<ossimHistogram> h = theHistogram->getHistogram(band);
         if (h.valid())
         {
            h->SetCount(0, 0);
         }
      }
   }
}
Esempio n. 23
0
QImage* ImageProcessor::getBinaryImage()
{
    // make sure histogram is calculated
    getHistogram();

    int lower = getLowerThreshold();
    int higher = getHigherThreshold();

    int width = grayScaleImage->width();
    int height = grayScaleImage->height();
    int size = width * height;
    if (binaryImage) {
        delete binaryImage;
    }
    binaryImage = new QImage(width, height, originImage->format());

    const uchar* grayPtr = grayScaleImage->constBits();
    uchar* binaryPtr = binaryImage->bits();

    for (int i = 0; i < size; ++i) {
        if (*grayPtr < lower || *grayPtr >= higher) {
            // set two sides of threshold white
            // blue
            *binaryPtr = MAX_OF_8BITS;
            // green
            *(binaryPtr + 1) = MAX_OF_8BITS;
            // red
            *(binaryPtr + 2) = MAX_OF_8BITS;
            // alpha
            *(binaryPtr + 3) = MAX_OF_8BITS;
        } else {
            // blue
            *binaryPtr = 0;
            // green
            *(binaryPtr + 1) = 0;
            // red
            *(binaryPtr + 2) = 0;
            // alpha
            *(binaryPtr + 3) = MAX_OF_8BITS;
        }
        grayPtr += PIXEL_SIZE;
        binaryPtr += PIXEL_SIZE;
    }
    return binaryImage;
}
Esempio n. 24
0
void ossimHistogramRemapper::setLowClipPoint(const ossim_float64& clip,
                                             ossim_uint32 zero_based_band)
{
   // allow the call to getHistogram to happen this way we can calculate a histogram if 
   // a histosource is connected to this object
   //
   //   if (!theHistogram) return;
	
   ossimRefPtr<ossimHistogram> h = getHistogram(zero_based_band);
   if (h.valid())
   {
      ossim_float64 d = h->getLowFractionFromValue(clip);
      if (ossim::isnan(d) == false)
      {
         setLowNormalizedClipPoint(d, zero_based_band);
      }
   }
}
Esempio n. 25
0
QImage* ImageProcessor::getEqualImage()
{
    if (equalImage) {
        return equalImage;
    }
    getHistogram();
    getGrayScaleImage();

    // min level of rgb, within [0, 256)
    int minLevel;
    for (int i = 0; i < RANGE_OF_8BITS; ++i) {
        if (histogram[i] > 0) {
            minLevel = i;
            break;
        }
    }
    // max level of rgb, within [0, 256)
    int maxLevel;
    for (int i = RANGE_OF_8BITS - 1; i >= 0; --i) {
        if (histogram[i] > 0) {
            maxLevel = i;
            break;
        }
    }

    equalImage = new QImage(originImage->width(), originImage->height(),
                            originImage->format());
    uchar* bits = equalImage->bits();
    const uchar* oBits = grayScaleImage->constBits();
    int size = equalImage->width() * equalImage->height();
    for (int i = 0; i < size; ++i) {
        uchar value = (double)accHistogram[*oBits] / size * MAX_OF_8BITS;
        for (int rgb = 0; rgb < 3; ++rgb) {
            *bits = value;
            ++bits;
            ++oBits;
        }
        ++bits;
        ++oBits;
    }
    return equalImage;
}
Esempio n. 26
0
void getLBPplusHistFeatures(const Mat& image, Mat& features) {
  // TODO
  Mat grayImage;
  cvtColor(image, grayImage, CV_RGB2GRAY);

  Mat lbpimage;
  lbpimage = libfacerec::olbp(grayImage);
  Mat lbp_hist = libfacerec::spatial_histogram(lbpimage, 64, 8, 4);
  //features = lbp_hist.reshape(1, 1);

  Mat greyImage;
  cvtColor(image, greyImage, CV_RGB2GRAY);
  //Mat src_hsv;
  //cvtColor(image, src_hsv, CV_BGR2HSV);
  //std::vector<cv::Mat> hsvSplit;
  //split(src_hsv, hsvSplit);

  /*std::vector<cv::Mat> bgrSplit;
  split(image, bgrSplit);*/

  //grayImage = histeq(grayImage);
  Mat img_threshold;
  threshold(greyImage, img_threshold, 0, 255,
    CV_THRESH_OTSU + CV_THRESH_BINARY);
  Mat histomFeatures = getHistogram(img_threshold);

  /*Mat img_threshold2;
  threshold(bgrSplit[1], img_threshold2, 0, 255,
  CV_THRESH_OTSU + CV_THRESH_BINARY);
  Mat greenHistomFeatures = getTheFeatures(img_threshold2);

  Mat histomFeatures;
  hconcat(blueHistomFeatures.reshape(1, 1), greenHistomFeatures.reshape(1, 1), histomFeatures);*/

  //Mat histomFeatures = getTheColorFeatures(greyImage);

  //features.push_back(histomFeatures.reshape(1, 1));

  hconcat(lbp_hist.reshape(1, 1), histomFeatures.reshape(1, 1), features);
  //std::cout << features << std::endl;
  //features = histomFeatures;
}
cv::Mat StrategyColorHistogram::getHistogramImage(const cv::Mat &image, cv::Scalar color)
{
    cv::MatND hist = getHistogram(image);

    double maxVal = 0;
    double minVal = 0;
    cv::minMaxLoc(hist, &minVal, &maxVal, 0 , 0);

    cv::Mat histImg(m_histSize[0], m_histSize[0], CV_8UC3, cv::Scalar(0, 0, 0));
    int hpt = static_cast<int>(0.9 * m_histSize[0]);

    for(int h = 0; h < m_histSize[0]; h++)
    {
        float binVal = hist.at<float>(h);
        int intensity = static_cast<int>(binVal * hpt / maxVal);
        cv::line(histImg, cv::Point(h, m_histSize[0]),
                cv::Point(h, m_histSize[0] - intensity), color);
    }

    return histImg;
}
TH1* getHistogram(TFile* inputFile, const TString& meName, TObjArray& processes, const TString& region)
{
  TH1* histogram_sum = 0;
  
  int numProcesses = processes.GetEntries();
  for ( int iProcess = 0; iProcess < numProcesses; ++iProcess ) {
    TObjString* process = dynamic_cast<TObjString*>(processes.At(iProcess));
    assert(process);
    TH1* histogram = getHistogram(inputFile, meName, process->GetString(), region);
    if ( !histogram_sum ) {
      TString histogramName_sum = histogram->GetName();
      histogramName_sum = histogramName_sum.ReplaceAll(process->GetString(), "sum");
      histogram_sum = (TH1*)histogram->Clone(histogramName_sum.Data());
      if ( !histogram_sum->GetSumw2N() ) histogram_sum->Sumw2();
    } else {
      histogram_sum->Add(histogram);
    }
  }

  return histogram_sum;
}
Esempio n. 29
0
void getLBPplusHistFeatures(const Mat& image, Mat& features) {
  Mat grayImage;
  cvtColor(image, grayImage, CV_RGB2GRAY);

  Mat lbpimage;
  lbpimage = libfacerec::olbp(grayImage);
  Mat lbp_hist = libfacerec::spatial_histogram(lbpimage, 64, 8, 4);
  //features = lbp_hist.reshape(1, 1);

  Mat greyImage;
  cvtColor(image, greyImage, CV_RGB2GRAY);

  //grayImage = histeq(grayImage);
  Mat img_threshold;
  threshold(greyImage, img_threshold, 0, 255,
    CV_THRESH_OTSU + CV_THRESH_BINARY);
  Mat histomFeatures = getHistogram(img_threshold);

  hconcat(lbp_hist.reshape(1, 1), histomFeatures.reshape(1, 1), features);
  //std::cout << features << std::endl;
  //features = histomFeatures;
}
Esempio n. 30
0
ossim_float64 ossimHistogramRemapper::getHighClipPoint(ossim_uint32 zero_based_band) const
{
   if(zero_based_band >= getNumberOfInputBands() ||
      !theHistogram || zero_based_band >= theNormalizedHighClipPoint.size())
   {
      return ossim::nan();
   }
	
   if (theNormalizedHighClipPoint[zero_based_band] == 1.0)
   {
      return getMaxPixelValue(zero_based_band);
   }
	
   ossimRefPtr<ossimHistogram> h = getHistogram(zero_based_band);
   if (h.valid())
   {
      ossim_float64 d =
         h->HighClipVal(1.0-theNormalizedHighClipPoint[zero_based_band]);
      return ceil(d);
   }
   
   return ossim::nan();
}