Ejemplo n.º 1
0
void Colony::printDebugImage()
{
    static int step = 0;
    Image* img = _environment->getPheromoneImage();//imgCreate( _environment->getWidth(), _environment->getHeight(), 3 );

    int nAnts = _ants.size();
    for (int i = 0; i < nAnts; ++i)
    {
        Ant* ant = _ants[i];
        if (_ants[i]->isAlive())
        {
            // each ant has a color
            //imgSetPixel3f( img, ant->_position.x, ant->_position.y, 1.0f - i/(float)nAnts, (0.0f + i) / nAnts, 0.0f );
            
            //all ants are red
            imgSetPixel3f( img, ant->_position.x, ant->_position.y, 1,0,0 );
        }
        else
        {
            imgSetPixel3f( img, ant->_position.x, ant->_position.y, 0.0f, 0.0f, 1.0f );
        }
    }

    char filename[100];
    sprintf( filename, "debugImages/debugImage%04d.bmp", ++step );
    imgWriteBMP( filename, img );
    imgDestroy( img );
}
Ejemplo n.º 2
0
/* salva a imagem gerada */
int save_cb(Ihandle *self)
{
  char* filename = get_new_file_name( );  /* chama o dialogo de abertura de arquivo */
  if (filename==NULL) return 0;
  imgWriteBMP(filename,image);
  //imgAdjust2eN(image);
  return IUP_DEFAULT;
}
Ejemplo n.º 3
0
void Colony::generateProbabilityImages()
{
     Image* vis = _environment->getVisibilityImage(); imgWriteBMP( (char*)"gammaone.bmp", vis );
     
     Image* visGammaDown = imgCopy( vis );
     imgGamma( visGammaDown, 0.5f ); imgWriteBMP( (char*)"gammadown.bmp", visGammaDown );
     Image* gammaDownProb = generateProbabilityImage( visGammaDown );
     imgDestroy( visGammaDown );
     _probabilityDistributions.push_back( gammaDownProb );
     
     Image* visGammaUp = imgCopy( vis );
     imgGamma( visGammaUp, 1.5f ); imgWriteBMP( (char*)"gammaup.bmp", visGammaUp );
     Image* gammaUpProb = generateProbabilityImage( visGammaUp );
     imgDestroy( visGammaUp );
     _probabilityDistributions.push_back( gammaUpProb );
     
     Image* prob = generateProbabilityImage( vis );
     imgDestroy( vis );
     _probabilityDistributions.push_back( prob );
}
Ejemplo n.º 4
0
void Colony::printDebugImage()
{
    static int step = 0;
    Image* imgIn = _environment->getPheromoneImage();
    imgNormalize( imgIn, 2 );
    
    Image* img = imgCreate( _environment->getWidth(), _environment->getHeight(), 3 );
    
    for (int x = 0; x < _environment->getWidth(); ++x)
    {
        for (int y = 0; y < _environment->getHeight(); ++y)
        {
            float lum = imgGetPixelf( imgIn, x, y );
            imgSetPixelf( img, x, y, lum );
        }
    }  
    
    int nAnts = _ants.size();
    for (int i = 0; i < nAnts; ++i)
    {
        Ant* ant = _ants[i];
        if (ant->isAlive())
        {
            // each ant has a color
            imgSetPixel3f( img, ant->_position.x, ant->_position.y, 1.0f - i/(float)nAnts, (0.0f + i) / nAnts, 0.0f );
            
            //all ants are red
            //imgSetPixel3f( img, ant->_position.x, ant->_position.y, 1,0,0 );
        }
        else
        {
            imgSetPixel3f( img, ant->_position.x, ant->_position.y, 0.0f, 0.0f, 1.0f );
        }
    }

    
    //postProcessing( &img );
    char filename[150];
    sprintf( filename, "debugImg/debugImage%04d.bmp", ++step );
    imgWriteBMP( filename, img );
    imgDestroy( img );
}
Ejemplo n.º 5
0
Colony::Colony(Image* image, DirectionalField* directionalFied)
{
    if (imgGetDimColorSpace( image ) != 1)
    {
        Image* aux = imgGrey( image );
        imgDestroy( image );
        image = aux;
        aux = 0;
    }
    
    // Normalize image
    //imgNormalize( image, 2 );
    
    // Apply gaussian filter for noise reduction
    //imgGauss( image );
    
    imgWriteBMP( (char*)"debugImg/inputAfterGaussian.bmp", image );
    
    _environment = new Environment( INITIAL_PHEROMONE, MIN_PHEROMONE, EVAPORATION_RATE, image, directionalFied );
    
    generateProbabilityImages();
}