Esempio n. 1
0
/**
 * Example of a test. To be completed.
 *
 */
bool testMagickReader()
{
  unsigned int nbok = 0;
  unsigned int nb = 0;
  
  trace.beginBlock ( "Testing MagickReader ..." );

  typedef SpaceND<2> Space2;
  typedef HyperRectDomain<Space2> TDomain;
  typedef TDomain::Vector Vector;
  
  //Default image selector = STLVector
  typedef ImageSelector<TDomain, unsigned char>::Type Image;

  std::string filename = testPath + "samples/color64.png";

  trace.info()<<"Importing: "<<filename<<endl;

  MagickReader<Image> reader;
  Image img = reader.importImage( filename );

  nbok += img.isValid() ? 1 : 0; 
  nb++;
  trace.info() << "(" << nbok << "/" << nb << ") "
	       << "img.isValid() == true"
	       << std::endl;

  nbok += img.extent() == Image::Vector( 64, 64 ) ? 1 : 0; 
  nb++;
  trace.info() << "(" << nbok << "/" << nb << ") "
	       << "img.extent() = " << img.extent() 
	       << "( == {64,64} )"
	       << std::endl;

  DGtalBoard board;
  typedef HueShadeColorMap<unsigned char,2> HueTwice;
  

  board.setUnit(LibBoard::Board::UCentimeter);

  img.selfDraw<HueTwice>(board,0,255);
  board.saveSVG("testMagick-export.svg");
    
  trace.endBlock();
  
  return nbok == nb;
}
Esempio n. 2
0
int main()
{
  
  typedef SpaceND<2> Space2;
  typedef HyperRectDomain<Space2> TDomain;
  typedef TDomain::Vector Vector;

  //Default image selector = STLVector
  typedef ImageSelector<TDomain, unsigned char>::Type Image;
  

  // Creating FreemanChain from file
  std::string freemanChainFilename = examplesPath + "samples/contourS.fc";
  fstream fst;
  fst.open (freemanChainFilename.c_str(), ios::in);
  FreemanChain<Space::Integer> fc(fst);
  fst.close();
  
  
  // Importing image with MagickReader
  MagickReader<Image> reader;
  std::string filenameImage = examplesPath + "samples/contourS.gif";
  Image img = reader.importImage( filenameImage );
  
  Point ptInf = img.lowerBound(); 
  Point ptSup = img.upperBound(); 
  unsigned int width = abs(ptSup.at(0)-ptInf.at(0)+1);
  unsigned int height = abs(ptSup.at(1)-ptInf.at(1)+1);
  
  // Draw the freemanchain and the contour 
  Board2D dgBoard;
  
  dgBoard.drawImage(filenameImage, 0,height-1, width, height );
  dgBoard << fc;
  
  dgBoard.saveEPS("freemanChainDisplay.eps");
  dgBoard.saveSVG("freemanChainDisplay.svg");
  dgBoard.saveFIG("freemanChainDisplay.fig");
  
  
  return 0;
}