Beispiel #1
0
void Gear_ClusteredDither::internalInit()
{
  _clusterSize = CLAMP((int)_CLUSTER_SIZE_IN->type()->value(), 2, 512);
  _spotType = (eSpotType)CLAMP((int)_SPOT_TYPE_IN->type()->value(), (int)SQUARE, (int)LINE);
  _width = _clusterSize * 3;
  _sizeX = _sizeY = 0;
  _angle[0] = DEG2RAD(CLAMP((int)_ANGLE_RED_IN->type()->value(), 0, 360));
  _angle[1] = DEG2RAD(CLAMP((int)_ANGLE_GREEN_IN->type()->value(), 0, 360));
  _angle[2] = DEG2RAD(CLAMP((int)_ANGLE_BLUE_IN->type()->value(), 0, 360));
  updateThreshold();
  updatePolarCoordinates();
  updateAngle(0);
  updateAngle(1);
  updateAngle(2);
  ASSERT_WARNING(_threshold);
  ASSERT_WARNING(_order);
}
Beispiel #2
0
void Detector::evaluateCores() {
    for (unsigned i = 0; i < cores.size(); i++) {
        if (evaluateNextIter[i]) {
            // Share evaluation
            CoreEvaluation* evaluationMsg = new CoreEvaluation(
                    "Core evaluation");
            evaluationMsg->setReporter(IP);
            evaluateCore(i, evaluationMsg);
            evaluationMsg->setCore(
                    std::vector<inet::IPv4Address>(cores[i].begin(),
                            cores[i].end()));
            evaluationMsg->setBogus(faulty);
            send(evaluationMsg, "detectionOut");
            thresholds[i] = updateThreshold(thresholds[i], evaluationMsg);
        }
        evaluateNextIter[i] = getEvaluateNextIter(i);
    }
    //Notify the detector about which cores are to be evaluated next:

    monitor->setShareSummaries(evaluateNextIter);
}
void DetectorWindow::on_maxThresholdSlider_valueChanged(int value)
{
  updateThreshold();
}
void DetectorWindow::setThresholdValues(int min_value, int max_value)
{
  ui->minThresholdSlider->setValue(min_value);
  ui->maxThresholdSlider->setValue(max_value);
  updateThreshold();
}
Beispiel #5
0
void Gear_ClusteredDither::runVideo()
{
  _image = _VIDEO_IN->type();
  if (_image->isNull())
    return;

  _outImage = _VIDEO_OUT->type();
  _outImage->resize(_image->width(), _image->height());
  
  _data = _image->data();    
  _outData = _outImage->data();
  
  unsigned char *iterData = (unsigned char*)_data;
  unsigned char *iterOutData = (unsigned char*)_outData;

  int prevSizeX = _sizeX;
  int prevSizeY = _sizeY;
  _sizeX = _image->width();
  _sizeY = _image->height();
  
  NOTICE("Changing cluster");
  // If cluster size has changed, recompute threshold matrix.
  int prevClusterSize = _clusterSize;
  _clusterSize = CLAMP((int)_CLUSTER_SIZE_IN->type()->value(), 2, MAX((int)_image->height(),4));
  bool clusterChanged = (prevClusterSize != _clusterSize);
  if (clusterChanged)
    _width = _clusterSize * 3;
  
  // XXX computeThreshold deux fois!!!
  // Set spot type.
  eSpotType prevSpotType = _spotType;
  _spotType = (eSpotType)CLAMP((int)_SPOT_TYPE_IN->type()->value(), (int)SQUARE, (int)LINE);
  bool spotTypeChanged = (prevSpotType != _spotType);
  
  if (clusterChanged || spotTypeChanged)
    updateThreshold();
  NOTICE("...done");

  if (_sizeX != prevSizeX || _sizeY != prevSizeY)
  {
    NOTICE("Updating polar coordinates");
    updatePolarCoordinates();
    NOTICE("Changing angles");
    _angle[0] = DEG2RAD(CLAMP((int)_ANGLE_RED_IN->type()->value(), 0, 360));
    _angle[1] = DEG2RAD(CLAMP((int)_ANGLE_GREEN_IN->type()->value(), 0, 360));
    _angle[2] = DEG2RAD(CLAMP((int)_ANGLE_BLUE_IN->type()->value(), 0, 360));
    
    updateAngle(0);
    updateAngle(1);
    updateAngle(2);
    NOTICE("...done");
  }
  else
  {
    NOTICE("Changing angles");
    double angleR = _angle[0];
    _angle[0] = DEG2RAD(CLAMP((int)_ANGLE_RED_IN->type()->value(), 0, 360));
    double angleG = _angle[1];
    _angle[1] = DEG2RAD(CLAMP((int)_ANGLE_GREEN_IN->type()->value(), 0, 360));
    double angleB = _angle[2];
    _angle[2] = DEG2RAD(CLAMP((int)_ANGLE_BLUE_IN->type()->value(), 0, 360));

    if (clusterChanged || _angle[0] != angleR)
      updateAngle(0);
    
    if (clusterChanged || _angle[1] != angleG)
      updateAngle(1);
    
    if (clusterChanged || _angle[2] != angleB)
      updateAngle(2);
    NOTICE("...done");
  }
  
  iterData = (unsigned char*) _data;
  iterOutData = (unsigned char*) _outData;

  Array2DType<std::pair<int, int> >::iterator
    rIt = _rChannel[0].begin(),
    gIt = _rChannel[1].begin(),
    bIt = _rChannel[2].begin();
  
  for (int y=0; y<_sizeY; ++y)
  {
    for (int x=0; x<_sizeX; ++x, ++rIt, ++gIt, ++bIt)
    {
      *iterOutData++ = getValue(*iterData++, rIt->first, rIt->second);
      *iterOutData++ = getValue(*iterData++, gIt->first, gIt->second);
      *iterOutData++ = getValue(*iterData++, bIt->first, bIt->second);
      iterOutData++;
      iterData++;
    }
  }  

}