예제 #1
0
int TBackgroundVuMeter::SetParameterValue(int nInd, std::string csNew)
{
  int nErr = 0;

  int nNb;

  nNb = TBackground::GetParameterCount();

  if(nInd >= nNb)
  {
    nInd -= nNb;

    switch(nInd)
    {
      case 0 : SetBinSize(atoi(csNew.c_str())); break;
      case 1 : SetAlpha(atof(csNew.c_str())); break;
      case 2 : SetThreshold(atof(csNew.c_str())); break;
      default : nErr = 1;
    }
  }
  else 
    nErr = TBackground::SetParameterValue(nInd, csNew);

  return nErr;
}
예제 #2
0
void Step()
{
	size_t lim = (GCSTEPSIZE/100) * StepMul;
	size_t olim;
	if (lim == 0)
	{
		lim = (~(size_t)0) / 2;		// no limit
	}
	Dept += AllocBytes - Threshold;
	do
	{
		olim = lim;
		lim -= SingleStep();
	} while (olim > lim && State != GCS_Pause);
	if (State != GCS_Pause)
	{
		if (Dept < GCSTEPSIZE)
		{
			Threshold = AllocBytes + GCSTEPSIZE;	// - lim/StepMul
		}
		else
		{
			Dept -= GCSTEPSIZE;
			Threshold = AllocBytes;
		}
	}
	else
	{
		assert(AllocBytes >= Estimate);
		SetThreshold();
	}
	StepCount++;
}
예제 #3
0
oamlCompressor::oamlCompressor() {
	SetThreshold(-3);
	SetRatio(4.0);

	attackTime = 10.0;	// 10ms
	releaseTime = 200.0;	// 200ms

	att = 0.0;
	rel = 0.0;
	env = 0.0;
}
예제 #4
0
// Author & Date:   Ehsan Azar     29 March 2011
// Purpose: Handle vertical slider control message
void CSDKSampleDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
    switch (pScrollBar->GetDlgCtrlID())
    {
    case IDC_THRESHOLD_SLIDER:
        if (nSBCode == SB_ENDSCROLL)
            SetThreshold(-m_sldThresh.GetPos());
        break;
    }

    CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
예제 #5
0
파일: analyze.C 프로젝트: ikeshel/anapanda
void analyze( Char_t *szFin, 
	      Int_t first=2,
	      Int_t lastt=0)
{
  ReadFile(szFin);
  InitAll();

  SetThreshold( 3000, 3000 ); // set the thresholds

  event_first = first;  
  event_lastt=h2D[0]->GetNbinsY()-1;
  if( lastt>1 && lastt<event_lastt )
    event_lastt = lastt;
  event = event_first;
  
  ftimer.Start();

  return;
} 
예제 #6
0
	void OnStart() override
	{
		auto scene = std::make_shared<asd::Scene>();
		auto layer = std::make_shared<asd::Layer2D>();
		auto obj= std::make_shared<asd::TextureObject2D>();
		scene->SetHDRMode(true);
		scene->AddLayer(layer);
		layer->AddObject(obj);
		asd::Engine::ChangeScene(scene);

		auto g = asd::Engine::GetGraphics();
		auto texture = g->CreateTexture2D(asd::ToAString("Data/Texture/Sample1.png").c_str());
		obj->SetTexture(texture);
		obj->SetScale(asd::Vector2DF(1, 1));

		auto pe = std::make_shared<asd::PostEffectLightBloom>();
		pe->SetIntensity(5.0f);
		pe->SetThreshold(0.2f);
		pe->SetExposure(3.0f);
		layer->AddPostEffect(pe);
	}
예제 #7
0
void FullGC()
{
	if (State <= GCS_Propagate)
	{
		// Reset sweep mark to sweep all elements (returning them to white)
		SweepPos = &Root;
		// Reset other collector lists
		Gray = NULL;
		State = GCS_Sweep;
	}
	// Finish any pending sweep phase
	while (State != GCS_Finalize)
	{
		SingleStep();
	}
	MarkRoot();
	while (State != GCS_Pause)
	{
		SingleStep();
	}
	SetThreshold();
}
예제 #8
0
int CAEN_V814::Init()
{
  int status=0;
  ostringstream s; s << "[CAEN_V814]::[INFO]::++++++ CAEN V814 INIT ++++++";
  Log(s.str(),1);
  if (handle_<0)
    return ERR_CONF_NOT_FOUND;
  if (!IsConfigured())
    return ERR_CONF_NOT_FOUND;

  //Read Version to check connection
  WORD data=0;
  status |= CAENVME_ReadCycle(handle_,configuration_.baseAddress+CAEN_V814_VERSION_ADD,&data,CAEN_V814_ADDRESSMODE,CAEN_V814_DATAWIDTH);
  if (status)
    {
      s.str(""); s << "[CAEN_V814]::[ERROR]::Cannot open V814 board @0x" << std::hex << configuration_.baseAddress << std::dec << " " << status; 
      Log(s.str(),1);
      return ERR_OPEN;
    }    

  int version = (data&0xF000)>>12;
  int serial =  (data&0x0FFF);

  s.str(""); s << "[CAEN_V814]::[INFO]::Open V814 board @0x" << std::hex << configuration_.baseAddress << std::dec << " Version " << version << " S/N " << serial; 
  Log(s.str(),1);

  status |= SetPatternInhibit();

#ifdef CAEN_V814_VERBOSE
  s.str(""); s << "[CAEN_V814]::[INFO]::Pattern Mask has been set to " << configuration_.patternMask;
  Log(s.str(),1);
#endif
  status |= SetThreshold(-1);
#ifdef CAEN_V814_VERBOSE
  s.str(""); s << "[CAEN_V814]::[INFO]::All Thresholds have been set";
  Log(s.str(),1);
#endif

  for (unsigned i=0;i<CAEN_V814_CHANNELS;++i)
    if (configuration_.chThreshold[i]>0)
      {
	status |= SetThreshold(i);
#ifdef CAEN_V814_VERBOSE
	s.str(""); s << "[CAEN_V814]::[INFO]::Set specific threshold for Ch" <<i << " to 0x" << configuration_.chThreshold[i];
	Log(s.str(),1);
#endif
      }

  status|=SetMajorityThreshold(); // single 0x6 double 0x13 triple 0x1F

#ifdef CAEN_V814_VERBOSE
  s.str(""); s << "[CAEN_V814]::[INFO]::Majority Threshold has been set to 0x" << configuration_.majorityThreshold;
  Log(s.str(),1);
#endif

  status|=SetOutputWidth();

#ifdef CAEN_V814_VERBOSE
  s.str(""); s << "[CAEN_V814]::[INFO]::Output Width has been set to 0x" << configuration_.outputWidth;
  Log(s.str(),1);
#endif

  if (status)
    {
      s.str(""); s << "[CAEN_V814]::[ERROR]::Cannot config V814 @0x" << std::hex << configuration_.baseAddress << std::dec; 
      Log(s.str(),1);
      return ERR_OPEN;
    }    
  
  s.str(""); s << "[CAEN_V814]::[INFO]::++++++ CAEN V814 CONFIGURED ++++++";  
  Log(s.str(),1);
  
  return 0;
}
ISimpleSubtractorImpl::ISimpleSubtractorImpl(float in_threshold) :
	m_model(nullptr), m_num_rows(0), m_num_cols(0), m_step(0), m_alpha(0.03)
{
	SetThreshold(in_threshold);
}
// bool TePDIIsosegClas::Implementation(const TePDIParameters& params)
bool TePDIIsosegClas::RunImplementation()
{
  // Setting the parameters
  TePDITypes::TePDIRasterVectorType input_rasters;
  params_.GetParameter("input_rasters", input_rasters);

  vector<int> bands;
  params_.GetParameter("bands", bands);

  W = input_rasters[0]->params().ncols_;
  H = input_rasters[0]->params().nlines_;

  TePDITypes::TePDIPolygonSetPtrType input_polygonset;
  params_.GetParameter("input_polygonset", input_polygonset);

  TePDITypes::TePDIRasterPtrType output_raster;
  params_.GetParameter("output_raster", output_raster);

  double  acceptance_limiar;
  params_.GetParameter("acceptance_limiar", acceptance_limiar);

  /* Setting the output raster */
  TeRasterParams output_raster_params = output_raster->params();

  output_raster_params.setDataType( TeDOUBLE, -1 );
  output_raster_params.nBands( 1 );
  if( input_rasters[0]->projection() != 0 ) {
    TeSharedPtr< TeProjection > proj( TeProjectionFactory::make(
      input_rasters[0]->projection()->params() ) );
    output_raster_params.projection( proj.nakedPointer() );
  }
  output_raster_params.boxResolution( input_rasters[0]->params().box().x1(),
    input_rasters[0]->params().box().y1(), input_rasters[0]->params().box().x2(),
    input_rasters[0]->params().box().y2(), input_rasters[0]->params().resx_,
    input_rasters[0]->params().resy_ );
  // output_raster_params.setPhotometric( TeRasterParams::TeRGB, -1 );

  TEAGN_TRUE_OR_RETURN( output_raster->init( output_raster_params ),
    "Output raster reset error" );

  for (unsigned pols = 0; pols < input_polygonset->size(); pols++)
  {
    TePolygon polygon(input_polygonset->operator[](pols));

    // this iterator "walks" in the image, on the region defined by a specific polygon
    TeRaster::iteratorPoly it = input_rasters[0]->begin(polygon, TeBoxPixelIn, 0);
    TeRaster::iteratorPoly it_end = input_rasters[0]->end(polygon, TeBoxPixelIn, 0);

    long area = (long)TeGeometryArea(polygon);
    // pixel vector for each band
    vector<vector<double> > pixels_per_band(bands.size());
    vector<double> sums(bands.size());
    vector<double> tmp(1);
    for (unsigned band = 0; band < bands.size(); band++)
      pixels_per_band.push_back(tmp);

    long npix = 0;
    double tmp_pixel;
    while(it != it_end)
    {
      int col = it.currentColumn(),
          lin = it.currentLine();

      if ((col >= 0 && col < W) && (lin >=0 && lin < H))
      {
        for (unsigned band = 0; band < bands.size(); band++)
        {
          input_rasters[band]->getElement(col, lin, tmp_pixel, band);
          pixels_per_band[band].push_back(tmp_pixel);
          sums[band] += tmp_pixel;
        }
        npix++;
      }

      ++it;
    }

    vector<double> tmp_mean;
    tmp_mean.reserve(bands.size());
    for (unsigned band = 0; band < bands.size(); band++)
    {
      tmp_mean.push_back(sums[band]/npix);
    }

    // sets the covarariance matrix
    TeMatrix tmp_covar;
    int nbands = bands.size();
    TEAGN_TRUE_OR_RETURN(tmp_covar.Init(nbands, nbands, 0.0), "Unable to Init tmp_covar");
    double sum;
    for(int i = 0; i < nbands; i++)
      for(int j = 0; j < nbands; j++)
      {
        sum = 0.0;
        for (int p = 0; p < npix; p++)
          sum += (pixels_per_band[i][p] - tmp_mean[i]) * (pixels_per_band[j][p] - tmp_mean[j]);
        if (npix == 1)
          tmp_covar(i,j) = 0.0;
        else
          tmp_covar(i,j) = (double)(sum / (npix - 1));
      }

    TePDIRegion tmp_region(pols);
    TEAGN_TRUE_OR_RETURN(tmp_region.Init(bands.size(), npix, tmp_mean, tmp_covar), "Unable to Init tmp_region");
    regions.insert(pair<double, TePDIRegion>(area, tmp_region));
  }
  total_regions = regions.size();

  TEAGN_TRUE_OR_RETURN(SetThreshold(acceptance_limiar, bands.size()), "Unable to SetThreshold");
  TEAGN_TRUE_OR_RETURN(GenerateClusters(), "Unable to GenerateClusters");
  TEAGN_TRUE_OR_RETURN(MergeClusters(), "Unable to MergeClusters");

// remap cluster values to 1 -> N
  std::set<unsigned int> ulabels;
  std::set<unsigned int>::iterator lit;
  std::map<unsigned int, unsigned int> colormap;

  for (int pols = 0; pols < total_regions; pols++)
  {
    TePolygon polygon(input_polygonset->operator[](pols));

    // searches for the region with Id = pols
    multimap<double, TePDIRegion, greater<double> >::iterator regions_it;

    for (regions_it = regions.begin(); regions_it != regions.end(); ++regions_it)
      if (regions_it->second.GetId() == pols)
        break;

    ulabels.insert(regions_it->second.GetClass());
  }

  unsigned int color = 1;
  for (lit = ulabels.begin(); lit != ulabels.end(); ++lit)
    colormap[*lit] = color++;

// paint output_raster with the correspondent classes
  for (int pols = 0; pols < total_regions; pols++)
  {
    TePolygon polygon(input_polygonset->operator[](pols));

    // this iterator "walks" in the image, on the region defined by a specific polygon
    TeRaster::iteratorPoly it = input_rasters[0]->begin(polygon, TeBoxPixelIn, 0);
    TeRaster::iteratorPoly it_end = input_rasters[0]->end(polygon, TeBoxPixelIn, 0);

    // searches for the region with Id = pols
    multimap<double, TePDIRegion, greater<double> >::iterator  regions_it,
                        regions_tmp = regions.begin();
    for (regions_it = regions.begin(); regions_it != regions.end(); ++regions_it)
      if (regions_it->second.GetId() == pols)
      {
        regions_tmp = regions_it;
        break;
      }

    unsigned bit_class = colormap[regions_it->second.GetClass()];

/*
    // here, a set of colors for up to 81 classes, C(3, 4) = tree bands, four levels
    vector<int> levels;
    levels.push_back(0);
    levels.push_back(50);
    levels.push_back(100);
    levels.push_back(150);
    levels.push_back(200);
    levels.push_back(255);
	int change = levels.size();
    vector<int> colors_R, colors_G, colors_B;
    for (int c = 0, i = 0, j = 0, k = 0; c < 81; c++)
    {
      colors_R.push_back(levels[i]);
      colors_G.push_back(levels[j]);
      colors_B.push_back(levels[k]);

      i++;
      if (i >= change)
      {
        i = 0;
        j++;
      }
      if (j >= change)
      {
        j = 0;
        k++;
      }
      if (k >= change)
        k = 0;
    }

	if (bit_class >= colors_R.size())
		bit_class = 0;

    double  R = colors_R[bit_class],
        G = colors_G[bit_class],
        B = colors_B[bit_class];
*/
    // paint output_raster with specific color class
    while(it != it_end)
    {
      int  i = it.currentColumn(),
           j = it.currentLine();

      output_raster->setElement(i, j, bit_class);
      ++it;
    }
  }

  return true;
}