Пример #1
0
void ComputeEfficiency(char* primaryLabel, TCut primaryCutPass,
                       TCut primaryCutFail, char* secondaryLabel="", 
                       TCut secondaryCutPass="", TCut secondaryCutFail="",
                       char* tertiaryLabel="", 
                       TCut tertiaryCutPass = "", TCut tertiaryCutFail = "") 
{
   TFile* f = new TFile("../allTPtrees_mc.root");
  TTree* scTree = (TTree*) f->Get("PhotonToGsf/fitter_tree");
  TTree* gsfTree = (TTree*) f->Get("GsfToIso/fitter_tree");
  char namePass[50];
  char nameFail[50];

  sprintf(namePass,"Zmass%sPass%s%s",primaryLabel,secondaryLabel,tertiaryLabel);
  sprintf(nameFail,"Zmass%sFail%s%s",primaryLabel,secondaryLabel,tertiaryLabel);
  TH1F* histPass = createHistogram(namePass, 30);
  TH1F* histFail = createHistogram(nameFail, 12);
  gsfTree->Draw("event_nPV>>"+TString(namePass), primaryCutPass && secondaryCutPass && 
  tertiaryCutPass,"goff");
  TString checkForSCTree(primaryLabel);
  TString plotVar = "event_nPV>>"+TString(nameFail);
  if(checkForSCTree.Contains("Gsf"))
     scTree->Draw(plotVar,primaryCutFail && secondaryCutFail && tertiaryCutFail,"goff");
  else 
     gsfTree->Draw(plotVar,primaryCutFail && secondaryCutFail && tertiaryCutFail,"goff");
  ComputeEfficiency(*histPass, *histFail);

  delete histPass;
  delete histFail;
}
Пример #2
0
HistogramWindow::HistogramWindow(QWidget *parent, const QVector<QVector<int> > &data) :
    QMainWindow(parent),
    ui(new Ui::HistogramWindow)
{
    ui->setupUi(this);

    createHistogram(data[0], plotRed, histRed, RED);
    createHistogram(data[1], plotGreen, histGreen, GREEN);
    createHistogram(data[2], plotBlue, histBlue, BLUE);

    ui->verticalLayout->addWidget(plotRed);
    ui->verticalLayout->addWidget(plotGreen);
    ui->verticalLayout->addWidget(plotBlue);
}
void RPColorImageProcessor::createSkinHueTrainingExample(cv::Rect& face_rectangle, const cv_bridge::CvImage::ConstPtr& color_image, std::vector<double>& hue_histogram)
{
    // Slightly shrink the face rectangle for the positive training example (to 95% of the size)
    cv::Rect shrunk_face_rectangle = RPUtils::resizeRectangle(face_rectangle, 0.95);
    RPUtils::clampRectangleToFrame(&shrunk_face_rectangle);

    // Resize the face rectangle to width/height ratio of 2/3
    double new_width = (double)shrunk_face_rectangle.height * 2.0 / 3.0;
    double width_delta = (double)shrunk_face_rectangle.width - new_width;
    shrunk_face_rectangle.x += width_delta / 2.0;
    shrunk_face_rectangle.width = new_width;

    // Create a face ROI
    cv::Mat face_region(color_image->image, shrunk_face_rectangle);

    // Create an elliptical mask
    cv::Mat elliptical_mask = cv::Mat::zeros(shrunk_face_rectangle.height, shrunk_face_rectangle.width, CV_8UC3);
    int shrunk_face_rectangle_horizontal_axis = shrunk_face_rectangle.width / 2;
    int shrunk_face_rectangle_vertical_axis = shrunk_face_rectangle.height / 2;
    cv::ellipse(elliptical_mask, cv::Point(shrunk_face_rectangle_horizontal_axis, shrunk_face_rectangle_vertical_axis), cv::Size(shrunk_face_rectangle_horizontal_axis, shrunk_face_rectangle_vertical_axis), 0.0, 0.0, 360.0, cv::Scalar(255, 255, 255), -1);

    // Convert the face region to HSV
    cv::Mat face_region_hsv;
    cv::cvtColor(face_region, face_region_hsv, CV_BGR2HSV);

    // Apply the elliptical mask to HSV face region
    cv::bitwise_and(face_region_hsv, elliptical_mask, face_region_hsv);
    createHistogram(face_region_hsv, hue_histogram);
}
Пример #4
0
void ossimImageUtil::createHistogram(ossimRefPtr<ossimImageHandler>& ih)
{
   static const char M[] = "ossimImageUtil::createHistogram #1";
   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
   }
   
   if ( ih.valid() )
   {
      // Get the entry list:
      std::vector<ossim_uint32> entryList;
      ih->getEntryList(entryList);
      
      bool useEntryIndex = false;
      if ( entryList.size() )
      {
         if ( (entryList.size() > 1) || (entryList[0] != 0) ) useEntryIndex = true;
      }

      for(ossim_uint32 idx = 0; idx < entryList.size(); ++idx)
      {
         createHistogram(ih, entryList[idx], useEntryIndex);
      }
   }

   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG) << M << " exited...\n";
   }
}
Пример #5
0
QVi RegionService::calcTolerance(const MatSet& matSet, QLP region, QVi averages) {

    QVis histograms = createHistogram(matSet, region);
    QVi tolerance(9,0);
    for(int i=0; i<9; i++) {
      tolerance[i] = findTolerance(averages[i], histograms[i], region.size());
    }
    
    return tolerance;
}
void TransFuncIntensityGradientPainter::setHistogramVisible(bool v) {
    showHistogram_ = v;
    if (showHistogram_ && !histogram_) {
        QApplication::setOverrideCursor(Qt::WaitCursor);
        createHistogram();
        createHistogramTexture();
        QApplication::restoreOverrideCursor();

        // update texture of transfer function because the scaling factor changed
        updateTF();
    }
}
Пример #7
0
void Mandelbrot::Initialize() {
	glewInit();

	createBuffer( &this->buffer, this->iSize);
	createTexture( &this->tex, this->iWidth, this->iHeight );
	createHistogram( 128 );

	cudaMalloc( ( void** ) &this->devCounts, this->iWidth * this->iHeight * sizeof( int ) );
	cudaMalloc( ( void** ) &this->devData,   this->iWidth * this->iHeight * sizeof( double ) * 2 );
	cudaMalloc( ( void** ) &this->devArray,  this->iWidth * this->iHeight * this->iDepth * sizeof( GLubyte ) );
	cudaMalloc( ( void** ) &this->devCalcArray, this->iWidth * this->iHeight * this->iDepth * sizeof( GLubyte ) );
}
Пример #8
0
ossimHistogramMode ossimImageUtil::getHistogramMode() const
{
   ossimHistogramMode result = OSSIM_HISTO_MODE_UNKNOWN;
   if ( createHistogram() || createHistogramR0() )
   {
      result = OSSIM_HISTO_MODE_NORMAL;
   }
   else if ( createHistogramFast() )
   {
      result = OSSIM_HISTO_MODE_FAST;
   }
   return result;
}
Пример #9
0
Descriptor TrueClusterHistogram::extract_( MyImage *image,
					  bool save,
					   Magick::Image * representaton){
  Descriptor concatinated_histograms;
  const size_t width = image->get_width();
  const size_t height = image->get_height();
  const size_t segment_width = width / nsegments;
  const size_t segment_height = height / nsegments;
  for(size_t x = 0; x < nsegments; x++)
    for(size_t y = 0; y < nsegments; y++){
      concatinated_histograms = concatinated_histograms + 
	createHistogram(image, 
			x * segment_width, width, 
			y * segment_height, height);
    }
  return concatinated_histograms;
}
Пример #10
0
void Mandelbrot::Update(int iterations) {
	
	if (this->bIsFinished) {

		if ( this->iOldIterations != iterations ) {
			createHistogram(iterations);
			this->iOldIterations = iterations;
		}
	
		this->bIsFinished = false;
		this->bIsFlushed = false;

		boost::thread(&Mandelbrot::calculate, this, iterations);

		//calculate(iterations);
	}
}
Пример #11
0
QString KstIfaceImpl::createHistogram(const QString& name,
    const QString& vector,
    double min,
    double max,
    int numBins,
    int normalizationType,
    const QColor& color) {

  QStringList objList = createHistogram(name, vector, min, max, numBins, normalizationType);

  if (objList.isEmpty())
  {
    return QString::null;
  }
  
  // also create the curve for the histogram
  QString n = objList[0] + "-C";
  KST::vectorList.lock().readLock();
  KstVectorPtr vx = *KST::vectorList.findTag(objList[1]);
  KstVectorPtr vy = *KST::vectorList.findTag(objList[2]);
  KST::vectorList.lock().unlock();

  KST::dataObjectList.lock().readLock();
  while (KST::dataObjectList.findTag(n) != KST::dataObjectList.end()) {
    n += "'";
  }
  KST::dataObjectList.lock().unlock();

  KstVCurvePtr c = new KstVCurve(n, vx, vy, 0L, 0L, 0L, 0L, color);
  c->setHasPoints(false);
  c->setHasLines(false);
  c->setHasBars(true);
  c->setBarStyle(1);
  
  KST::dataObjectList.lock().writeLock();
  KST::dataObjectList.append(KstDataObjectPtr(c));
  KST::dataObjectList.lock().unlock();

  _doc->forceUpdate();
  _doc->setModified();
  return c->tagName(); //return the curve name so user can plot it
}
void RPColorImageProcessor::createNonSkinHueTrainingExample(cv::Rect& face_rectangle, const cv_bridge::CvImage::ConstPtr& color_image, std::vector<double>& hue_histogram)
{
    // Expand the face rectangle for negative training example
    cv::Rect outer_face_rectangle = RPUtils::resizeRectangle(face_rectangle, FACE_REGION_EXPANSION_FACTOR * FACE_REGION_EXPANSION_FACTOR);
    cv::Rect inner_face_rectangle = RPUtils::resizeRectangle(face_rectangle, FACE_REGION_EXPANSION_FACTOR);
    RPUtils::clampRectangleToFrame(&outer_face_rectangle);
    RPUtils::clampRectangleToFrame(&inner_face_rectangle);

    cv::Mat expanded_face_region(color_image->image, outer_face_rectangle);

    // Create a rectangular mask
    cv::Mat rectangular_mask = cv::Mat::zeros(outer_face_rectangle.height, outer_face_rectangle.width, CV_8UC3);
    cv::Point rectangular_mask_tl = inner_face_rectangle.tl() - outer_face_rectangle.tl();
    cv::rectangle(rectangular_mask, cv::Rect(rectangular_mask_tl, inner_face_rectangle.size()), cv::Scalar(255, 255, 255), -1);

    // Convert the face region to HSV
    cv::Mat face_region_hsv;
    cv::cvtColor(expanded_face_region, face_region_hsv, CV_BGR2HSV);

    // Invert and apply the expanded mask
    cv::bitwise_not(rectangular_mask, rectangular_mask);
    cv::bitwise_and(face_region_hsv, rectangular_mask, face_region_hsv);
    createHistogram(face_region_hsv, hue_histogram);
}
Пример #13
0
// conduct the UnMarshalled Octet performance test using separate
// send_n calls with Nagle's algorithm disabled
ACE_SCTP::HIST runUnmarshalledOctetTest(ACE_CDR::Octet *buf, size_t seqLen, ACE_SOCK_Stream & stream){

  ACE_CDR::ULong const testIterations = Options_Manager::test_iterations;

  size_t bt;
  ACE_CDR::ULong cnt = 0;
  // variables for the timing measurements
  ACE_hrtime_t startTime, endTime;
  ACE_CDR::Double messageLatency_usec = 0.0;
  ACE_CDR::ULong msgLen = seqLen*ACE_CDR::OCTET_SIZE;

  // explicity configure Nagling. Default is
  // Options_Manager::test_enable_nagle=0 so default configurations is
  // NO NAGLING
  ACE_CDR::Long nagle;
  if (Options_Manager::test_enable_nagle)
    nagle=0;
  else
    nagle=1;
  if (Options_Manager::test_transport_protocol == IPPROTO_SCTP){
    // default - sctp case
    if (-1 == stream.set_option(IPPROTO_SCTP, SCTP_NODELAY, &nagle, sizeof nagle))
      ACE_ERROR_RETURN ((LM_ERROR,
                         "%p\n",
                         "set_option"),
                        0);
  } else {
    // tcp case
    if (-1 == stream.set_option(IPPROTO_TCP, TCP_NODELAY, &nagle, sizeof nagle))
      ACE_ERROR_RETURN ((LM_ERROR,
                         "%p\n",
                         "set_option"),
                        0);
  }

  // prime the client and server before starting the test
  for(cnt=0;cnt<primerIterations;++cnt){

    // send message size
    // TODO : The message length should be CDR encoded
    ACE_CDR::ULong msgLenExpressed = ACE_HTONL(msgLen);
    if (-1 == stream.send_n (&msgLenExpressed, ACE_CDR::LONG_SIZE, 0, &bt))
      ACE_ERROR_RETURN ((LM_ERROR,
                         "%p\n",
                         "send_n"),
                        0);

    // send a message
    if (-1 == stream.send_n (buf, msgLen, 0, &bt))
      ACE_ERROR_RETURN ((LM_ERROR,
                         "%p\n",
                         "send_n"),
                        0);

    // block for a Short reply
    ACE_CDR::Short reply;
    if ((stream.recv_n(&reply, ACE_CDR::SHORT_SIZE, 0, &bt)) == -1)
      ACE_ERROR_RETURN((LM_ERROR,
                        "%p\n",
                        "recv_n"),
                       0);
  }

  // AFTER PRIMING THE PUMP CREATE THE HISTOGRAM
  ACE_SCTP::HIST aceStream_hist = 0;
  aceStream_hist = createHistogram(msgLen);
  if (0 == aceStream_hist)
    ACE_ERROR_RETURN((LM_ERROR,
                      "%p\n",
                      "histogram create failed"),
                     0);

  iovec iov[2];
  // PERFORMANCE TEST LOOP
  for (cnt = 0; cnt < testIterations; ++cnt){

    // get the start time
    startTime = ACE_OS::gethrtime();
    if (!startTime)
      ACE_ERROR_RETURN((LM_ERROR,
                        "%p\n",
                        "ACE_OS::gethrtime()"),
                       0);


    ACE_CDR::ULong msgLenExpressed = ACE_HTONL(msgLen);
    iov[0].iov_base = reinterpret_cast<char *> (&msgLenExpressed);
    iov[0].iov_len = ACE_CDR::LONG_SIZE;
    iov[1].iov_base = reinterpret_cast<char *> (buf);
    iov[1].iov_len = msgLen;

    if (-1 == stream.sendv_n (iov, 2))
      ACE_ERROR_RETURN ((LM_ERROR,
                         "%p\n",
                         "send_n"),
                        0);

    // block for a Short reply
    ACE_CDR::Short reply;
    if ((stream.recv_n(&reply, ACE_CDR::SHORT_SIZE, 0, &bt)) == -1)
      ACE_ERROR_RETURN((LM_ERROR,
                        "%p\n",
                        "recv_n"),
                       0);

    // get the end time
    endTime = ACE_OS::gethrtime();
    if (!endTime)
      ACE_ERROR_RETURN((LM_ERROR,
                        "%p\n",
                        "ACE_OS::gethrtime()"),
                       0);

    // compute the message latency in micro-seconds
    messageLatency_usec =

      (static_cast<double> (ACE_UINT64_DBLCAST_ADAPTER(endTime)) -
       static_cast<double> (ACE_UINT64_DBLCAST_ADAPTER(startTime)))

      / microsec_clock_scale_factor;

    // record the message latency in the histogram
    ACE_SCTP::record(messageLatency_usec, aceStream_hist);
  }

  // THE HEADER MESSAGE SENT TO THE SERVER CONTAINED THE NUMBER OF
  // PRIMER AND TEST MESSAGES TO BE SENT AFTER WHICH THE SERVER WILL
  // CLOSE THE STREAM SO ONCE WE REACH THIS POINT THE STREAM IS NO
  // LONGER VALID AND WE CLOSE IT.
  stream.close();

  // allocated by runTest
  delete[] buf;
  return aceStream_hist;
}
int main(int argc,char* argv[])
	{
	/* Set default values for all parameters: */
	unsigned int memoryCacheSize=512;
	unsigned int tempOctreeMaxNumPointsPerNode=4096;
	std::string tempOctreeFileNameTemplate="/tmp/Pointe_Preprocessor_TempOctree";
	unsigned int maxNumPointsPerNode=4096;
	std::string tempPointFileNameTemplate="/tmp/Pointe_Preprocessor_TempPoints";
	
	const char * fileName=0;
	float valueMinimum=Math::Constants<float>::max;
	float valueMaximum=Math::Constants<float>::min;
	float * histogram;

	try
		{
		/* Open Pointe-Samhlaigh's configuration file: */
		Misc::ConfigurationFile configFile(POINTE_CONFIGFILENAME);
		Misc::ConfigurationFileSection cfg=configFile.getSection("/Pointe_Preprocessor");
		
		/* Override program settings from configuration file: */
		memoryCacheSize=cfg.retrieveValue<unsigned int>("./memoryCacheSize",memoryCacheSize);
		tempOctreeMaxNumPointsPerNode=cfg.retrieveValue<unsigned int>("./tempOctreeMaxNumPointsPerNode",tempOctreeMaxNumPointsPerNode);
		tempOctreeFileNameTemplate=cfg.retrieveValue<std::string>("./tempOctreeFileNameTemplate",tempOctreeFileNameTemplate);
		maxNumPointsPerNode=cfg.retrieveValue<unsigned int>("./maxNumPointsPerNode",maxNumPointsPerNode);
		tempPointFileNameTemplate=cfg.retrieveValue<std::string>("./tempPointFileNameTemplate",tempPointFileNameTemplate);
		}
	catch(std::runtime_error err)
		{
		/* Just ignore the error */
		}
	
	/* Initialize transient parameters: */
	const char* outputFileName=0;
	PointFileType pointFileType=XYZI;
	bool havePoints=false;
	
	/* Parse the command line and load all input files: */
	Misc::Timer loadTimer;
	PointeAccumulator pa;
	pa.setMemorySize(memoryCacheSize,tempOctreeMaxNumPointsPerNode);
	pa.setTempOctreeFileNameTemplate(tempOctreeFileNameTemplate+"XXXXXX");
	for(int i=1;i<argc;++i)
		{
		if(argv[i][0]=='-')
			{
			if(strcasecmp(argv[i]+1,"o")==0)
				{
				++i;
				if(i<argc)
					outputFileName=argv[i];
				else
					std::cerr<<"Dangling -o flag on command line"<<std::endl;
				}
			else if(strcasecmp(argv[i]+1,"np")==0)
				{
				++i;
				if(i<argc)
					maxNumPointsPerNode=(unsigned int)(atoi(argv[i]));
				else
					std::cerr<<"Dangling -np flag on command line"<<std::endl;
				}
			else if(strcasecmp(argv[i]+1,"cs")==0)
				{
				++i;
				if(i<argc)
					{
					memoryCacheSize=(unsigned int)(atoi(argv[i]));
					pa.setMemorySize(memoryCacheSize,tempOctreeMaxNumPointsPerNode);
					}
				else
					std::cerr<<"Dangling -cs flag on command line"<<std::endl;
				}
			else if(strcasecmp(argv[i]+1,"to")==0)
				{
				++i;
				if(i<argc)
					{
					if(!havePoints)
						{
						tempOctreeFileNameTemplate=argv[i];
						pa.setTempOctreeFileNameTemplate(tempOctreeFileNameTemplate+"XXXXXX");
						}
					else
						std::cerr<<"Ignoring -to flag; must be specified before any input point sets are read"<<std::endl;
					}
				else
					std::cerr<<"Dangling -to flag on command line"<<std::endl;
				}
			else if(strcasecmp(argv[i]+1,"tp")==0)
				{
				++i;
				if(i<argc)
					tempPointFileNameTemplate=argv[i];
				else
					std::cerr<<"Dangling -tp flag on command line"<<std::endl;
				}
			else if(strcasecmp(argv[i]+1,"xyzi")==0)
				pointFileType=XYZI;
			else
				std::cerr<<"Unrecognized command line option "<<argv[i]<<std::endl;
			}
		else
			{
			PointFileType thisPointFileType=pointFileType;
			switch(thisPointFileType)
				{
				case XYZI:
					std::cout<<"Processing XYZI input file "<<argv[i]<<"..."<<std::flush;
					histogram = new float[256];
					fileName=argv[i];
					loadPointFileXyzi(pa, fileName, &valueMaximum, &valueMinimum);
					for(int index=0;index<256;index++)
						histogram[index]=0.0f;
					createHistogram(fileName, histogram, valueMaximum, valueMinimum);
					havePoints=true;
					std::cout<<" done."<<std::endl;
					break;

				default:
					std::cerr<<"Input file "<<argv[i]<<" has an unrecognized file format"<<std::endl;
				}
			}
		}
	
	/* Check if an output file name was given: */
	if(outputFileName==0)
		{
		std::cerr<<"Usage: "<<argv[0]<<"-o <output file name> -np <max points per node> <input file spec>"<<std::endl;
		std::cerr<<"Input file spec:  <format spec> <file name>"<<std::endl;
		std::cerr<<"Format spec: -XYZI"<<std::endl;
		std::cerr<<"             -XYZRGB"<<std::endl;
		return 1;
		}
	
	/* Finish reading points: */
	pa.finishReading();
	loadTimer.elapse();
	
	/* Construct an octree with less than maxPointsPerNode points per leaf: */
	Misc::Timer createTimer;
	OctreeCreator tree(pa.getMaxNumCacheablePoints(),maxNumPointsPerNode,pa.getTempOctrees(),tempPointFileNameTemplate+"XXXXXX", histogram, valueMaximum, valueMinimum);
	
	/* Delete the temporary point octrees: */
	pa.deleteTempOctrees();
	createTimer.elapse();
	
	/* Write the octree structure and data to the destination file: */
	Misc::Timer writeTimer;
	tree.write(outputFileName);
	writeTimer.elapse();

	std::cout<<"Time to load input data: "<<loadTimer.getTime()<<"s, time to create octree: "<<createTimer.getTime()<<"s, time to write final octree files: "<<writeTimer.getTime()<<"s"<<std::endl;
	
	return 0;
	}
Пример #15
0
//---
// This method is called back by the ossimFileWalker::walk method for each file it finds that it
// deems can be processed.
//---
void ossimImageUtil::processFile(const ossimFilename& file)
{
   static const char M[] = "ossimImageUtil::processFile";
   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << M << " entered...\n" << "file: " << file << "\n";
   }

   bool processFileFlag = true;
   if ( !getOverrideFilteredImagesFlag() )
   {
      processFileFlag = !isFiltered( file );
   }

   if ( processFileFlag )
   {
      ossimNotify(ossimNotifyLevel_NOTICE) << "Processing file: " << file << std::endl;

      m_mutex.lock();
      ossimRefPtr<ossimImageHandler> ih =
         ossimImageHandlerRegistry::instance()->open(file, true, true);
      m_mutex.unlock();
      
      if ( ih.valid() && !ih->hasError() )
      {
         if ( isDirectoryBasedImage( ih.get() ) )
         {
            // Tell the walker not to recurse this directory.
            m_mutex.lock();
            m_fileWalker->setRecurseFlag(false);
            m_mutex.unlock();
         }
         
         // Set any reader props:
         ossimPropertyInterface* pi = dynamic_cast<ossimPropertyInterface*>(ih.get());
         if ( pi ) setProps(pi);
         
         bool consumedHistogramOptions  = false;
         bool consumedCmmOptionsOptions = false;
         
         if ( getOutputFileNamesFlag() )
         {
            // Simply output the file name of any images we can open:
            ossimNotify(ossimNotifyLevel_NOTICE) << ih->getFilename().expand(); 
         }
         
         if ( createOverviews() )
         {
            // Skip shape files...
            if ( ih->getClassName() != "ossimOgrGdalTileSource" )
            {
               createOverview(ih, consumedHistogramOptions, consumedCmmOptionsOptions);
            }
         }
         
         // Build stand alone histogram.  Note the overview sequencer may have computed for us.
         if ( hasHistogramOption() && !consumedHistogramOptions)
         {
            createHistogram( ih );
         }
      }
      else
      {
         ossimNotify(ossimNotifyLevel_WARN) << M << "\nCould not open: " << file << std::endl;
      }
   }
   else // Matches: if ( processFileFlag )
   {
      ossimNotify(ossimNotifyLevel_NOTICE)
         << "Filtered file, not processing: " << file << std::endl;
   }
   
   if(traceDebug())
   {
      // Since ossimFileWalker is threaded output the file so we know which job exited.
      ossimNotify(ossimNotifyLevel_DEBUG) << M << "\nfile: " << file << "\nexited...\n";
   }
}
Пример #16
0
bool ossimImageUtil::hasHistogramOption() const
{
   return ( createHistogram() || createHistogramFast() || createHistogramR0() );
}
Пример #17
0
// Create overview for entry:
void ossimImageUtil::createOverview(ossimRefPtr<ossimImageHandler>& ih,
                                    ossimRefPtr<ossimOverviewBuilderBase>& ob,
                                    ossim_uint32 entry,
                                    bool useEntryIndex,
                                    bool& consumedHistogramOptions)
{
   static const char M[] = "ossimImageUtil::createOverview #2";
   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n";
   }
   
   if ( ih.valid() && ob.valid() )
   {
      if (useEntryIndex)
      {
         // Set entry before deriving file name.
         ih->setCurrentEntry(entry);
         ossimNotify(ossimNotifyLevel_NOTICE) << "entry number: "<< entry << std::endl;
      }
      
      ossimFilename outputFile =
         ih->getFilenameWithThisExtension(ossimString(".ovr"), useEntryIndex);
      
      if ( rebuildOverviews() )
      {
         ih->closeOverview(); 
         if ( outputFile.exists() )
         {
            outputFile.remove();
         }
      }

      if ( getInternalOverviewsFlag() )
      {
         if ( ih->getClassName() == "ossimTiffTileSource")
         {
            //---
            // INTERNAL_OVERVIEWS_FLAG_KW is set to true:
            // Tiff reader can handle internal overviews.  Set the output file to
            // input file.  Do it after the above remove so that if there were
            // external overviews they will get removed.
            //---
            outputFile = ih->getFilename();
         }
         else 
         {
            ossimNotify(ossimNotifyLevel_NOTICE)
               << "Internal overviews not supported for reader type: "
               <<ih->getClassName()
               << "\nIgnoring option..."
               << endl;
         }
      }

      if ( hasRequiredOverview( ih, ob ) == false )
      {
         //---
         // Set create histogram code...
         //
         // Notes:
         // 1) Must put this logic after any removal of external overview file.
         // 
         // 2) Base file could have built in overviews, e.g. jp2 files.  So the sequensor could
         //    start at R6 even if there is no external overview file.
         //
         // 3) If user want the histogram from R0 the overview builder can do as long as
         //    ossimImageHandler::getNumberOfDecimationLevels returns 1.  If we are starting
         //    overview building at R6 then we must do the create histogram in a separate path.
         //---
         ossimHistogramMode histoMode = OSSIM_HISTO_MODE_UNKNOWN;
         if ( createHistogram() ||
              ( createHistogramR0() && ( ih->getNumberOfDecimationLevels() == 1 ) ) )
         {
            histoMode = OSSIM_HISTO_MODE_NORMAL;
         }
         else if ( createHistogramFast() )
         {
            histoMode = OSSIM_HISTO_MODE_FAST;
         }
         
         if(traceDebug())
         {
            ossimNotify(ossimNotifyLevel_DEBUG) << "Histogram mode: " << histoMode << "\n";
         }
         
         if ( histoMode != OSSIM_HISTO_MODE_UNKNOWN )
         {
            consumedHistogramOptions = true;
            ob->setHistogramMode(histoMode);
            
            ossimNotify(ossimNotifyLevel_NOTICE)
               << "Creating overviews with histogram for file: " << ih->getFilename() << std::endl;
         }
         else
         {
            if ( histoMode != OSSIM_HISTO_MODE_UNKNOWN )
            {
               consumedHistogramOptions = false;  
               ossimNotify(ossimNotifyLevel_NOTICE)
                  << "Creating overviews for file: " << ih->getFilename() << std::endl;
            }
         }
         
         ob->setOutputFile(outputFile);
         ob->setInputSource(ih.get());
         
         // Create the overview for this entry in this file:
         if ( ob->execute() == false )
         {
            setErrorStatus( ossimErrorCodes::OSSIM_ERROR );
            ossimNotify(ossimNotifyLevel_WARN)
               << "Error returned creating overviews for file: " << ih->getFilename() << std::endl;
         }
      }
      else
      {
         consumedHistogramOptions = false;
         ossimNotify(ossimNotifyLevel_NOTICE)
            << "Image has required reduced resolution data sets." << std::endl;
      }
   }

   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG) << M << " exited...\n";
   }
}
Пример #18
0
/**
* 指定領域の9チャンネルのHistogramを作成して返す
*
*/
QVis RegionService::createHistogram(Mat srcBGRImg, QLP region) {
  
    MatSet matSet(srcBGRImg);
    return createHistogram(matSet, region);
}
Пример #19
0
void analyzeContinuously(HumdrumFile& infile, int windowsize,
      double stepsize, double* majorKey, double* minorKey) {

   Array<Array<double> > segments;
   infile.analyzeRhythm("4");
   int segmentCount = int(infile.getTotalDuration() / stepsize + 0.5);

   if (segmentCount < windowsize) {
      cout << "Not enough data for requested analysis" << endl;
      return;
   }

   segments.setSize(segmentCount);
   segments.allowGrowth(0);
   int i;
   for (i=0; i<segments.getSize(); i++) {
      segments[i].setSize(12);
      segments[i].allowGrowth(0);
      segments[i].setAll(0);
   }
	    
   loadHistograms(segments, infile, segmentCount);

   if (debugQ) {
      printHistogramTotals(segments);
   }

   Array<Array<double> > pitchhist; 
   Array<Array<double> > correlations;

   pitchhist.setSize(segmentCount-windowsize);
   correlations.setSize(segmentCount-windowsize);
   pitchhist.allowGrowth(0);
   correlations.allowGrowth(0);
   for (i=0; i<segmentCount-windowsize; i++) {
      pitchhist[i].setSize(13);  //last spot for best key
      pitchhist[i].allowGrowth(0);
      correlations[i].setSize(24);
      correlations[i].allowGrowth(0);
   }

   for (i=0; i<segmentCount - windowsize; i++) {
      createHistogram(pitchhist[i], i, windowsize, segments);
      identifyKeyDouble(pitchhist[i], correlations[i], majorKey, minorKey);
   }


   Array<double> measures;
   getLocations(measures, infile, segmentCount);

   cout << "**key\t**rval\t**conf\t**start\t**mid\t**end\n";
   for (i=0; i<pitchhist.getSize(); i++) {
      printBestKey(int(pitchhist[i][12] + 0.5));
      cout << "\t";
      printCorrelation(correlations[i][int(pitchhist[i][12]+ 0.1)], roundQ);
      cout << "\t";
      cout << getConfidence(correlations[i], int(pitchhist[i][12]+0.1));
      cout << "\t";
      cout << "=" << measures[i];
      cout << "\t";
      cout << "=" << int((measures[i] + measures[i+windowsize])/2+0.49);
      cout << "\t";
      cout << "=" << measures[i+windowsize];
      cout << endl;
   }
   cout << "*-\t*-\t*-\t*-\t*-\t*-\n";

}