Пример #1
0
void draw( const TImage aImg, const double& aMaxValue, std::string aBasename) 
{
  typedef typename TImage::Domain::ConstIterator ConstIteratorOnPoints; 
  typedef typename TImage::Domain::Point Point; 
  HueShadeColorMap<double, 2> colorMap(0,aMaxValue);

  Board2D b; 
  b.setUnit ( LibBoard::Board::UCentimeter );
 
  for (ConstIteratorOnPoints it = aImg.domain().begin(), itEnd = aImg.domain().end();
       it != itEnd; ++it)
    {
      Point p = *it; 
      b << CustomStyle( p.className(), new CustomFillColor( colorMap( aImg(p) ) ) );
      b << p;
    }

  {
    std::stringstream s; 
    s << aBasename << ".eps"; 
    b.saveEPS(s.str().c_str());
  }
  #ifdef WITH_CAIRO
  {
    std::stringstream s; 
    s << aBasename << ".png"; 
    b.saveCairo(s.str().c_str(), Board2D::CairoPNG);
  }
  #endif
} 
Пример #2
0
void 
computerBasicNormalsFromHeightField(const TImage &anHeightMap, TImageVector &vectorField)
{
  for(typename TImage::Domain::ConstIterator it = anHeightMap.domain().begin(); 
      it != anHeightMap.domain().end(); it++){
    if(anHeightMap.domain().isInside(*it+Z2i::Point::diagonal(1))&&
       anHeightMap.domain().isInside(*it-Z2i::Point::diagonal(1))){
      double dx = (anHeightMap(*it-Z2i::Point(1,0))-anHeightMap(*it+Z2i::Point(1,0)))/2.0;
      double dy = (anHeightMap(*it-Z2i::Point(0,1))-anHeightMap(*it+Z2i::Point(0,1)))/2.0;
      Z3i::RealPoint n (dx, dy, 1);
      n /= n.norm();
      vectorField.setValue(*it,n);
    }
  }
}
Пример #3
0
static QImage 
getImage(const TImage &anImage, double gridSize=1.0 ){
  typedef ConstImageAdapter<TImage, typename TImage::Domain, 
                            functors::BasicDomainSubSampler<typename TImage::Domain, int, double>,  
                            typename TImage::Value,
                            functors::Identity > ConstImageAdapterForSubSampling;
  
  std::vector<double> scales;
  scales.push_back(gridSize);
  scales.push_back(gridSize);
  
  functors::BasicDomainSubSampler<typename TImage::Domain, int, double> subSampler (anImage.domain(), scales, Z2i::Point(0,0)); 
  typename TImage::Domain newDomain = subSampler.getSubSampledDomain();
  functors::Identity id;
  ConstImageAdapterForSubSampling  scaledImage (anImage, newDomain, subSampler, id ); 
  
  unsigned int height = scaledImage.domain().upperBound()[1]+1;
  unsigned int width = scaledImage.domain().upperBound()[0]+1;
  uchar * data = new uchar [height*width*4];
  for(unsigned int i=0; i<height; i++){
    for(unsigned int j=0; j<width; j++){
      data[(j+width*i)*4]=scaledImage(Z2i::Point(j,i));
      data[(j+width*i)*4+1]=scaledImage(Z2i::Point(j,i));
      data[(j+width*i)*4+2]=scaledImage(Z2i::Point(j,i));
      data[(j+width*i)*4+3]=scaledImage(Z2i::Point(j,i));
    }
  }
   QImage result(  data, width,  height, QImage::Format_RGB32 );
   return result;
}