Beispiel #1
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 );
}
int save_image_cb(void)
{
	if(gc.image == NULL) {

		IupSetfAttribute(gc.msgbar, "TITLE", "There's no image to save");
		return IUP_DEFAULT;
	}

	image_copy = imgCopy(gc.image);
	IupSetfAttribute(gc.msgbar, "TITLE", "State of the image saved"); 

    return IUP_DEFAULT;
}
int load_image_cb(void) {

	if(image_copy == NULL) {

		IupSetfAttribute(gc.msgbar, "TITLE", "There's no copy of image saved");
		return IUP_DEFAULT;
	}

	gc.image = imgCopy(image_copy);
	repaint_cb(gc.canvas);
	IupSetfAttribute(gc.msgbar, "TITLE", "Last state saved is loaded");

	return IUP_DEFAULT;
}
Beispiel #4
0
Image* Colony::generateProbabilityImage( Image* input )
{
    if (imgGetDimColorSpace( input ) != 1) return 0;
    
    Image* output = imgCopy( input );
    float* data = imgGetData( output );
    int size = imgGetWidth( output ) * imgGetHeight( output );
    float sum = 0;
    for (int i = 0; i < size; ++i)
    {
        sum += data[i];
    }
    for (int i = 0; i < size; ++i)
    {
        data[i] /= sum;
    }
    
    return output;
}
Beispiel #5
0
Image* Colony::generateProbabilityImage( Image* input )
{
    if (imgGetDimColorSpace( input ) != 1) return 0;
    
    Image* output = imgCopy( input );
    float* data = imgGetData( output );
    int size = imgGetWidth( output ) * imgGetHeight( output );
    float sum = 0;
    for (int i = 0; i < size; ++i)
    {
//        if (isnan(data[i]))
//        {
//            printf( "Cannot generate probability image, NAN detected! on pixel %d\n", i );
//        }
        sum += data[i];
    }
    for (int i = 0; i < size; ++i)
    {
        data[i] /= sum;
    }
    
    return output;
}