Exemplo n.º 1
0
/**
 * im_video_test:
 * @im: write image here
 * @brightness: brightness setting
 * @error: set this to make the function return an error
 *
 * Make a test video image. Set @error to trigger an error.
 *
 * Returns: 0 on success, -1 on error
 */
int
im_video_test( IMAGE *im, int brightness, int error )
{
	if( error ) {
		im_error( "im_video_test", "%s", _( "error requested" ) );
		return( -1 );
	}
	else
		return( im_gaussnoise( im, 720, 576, brightness, 20 ) );
}
Exemplo n.º 2
0
/**
 * im_addgnoise:
 * @in: input image
 * @out: output image
 * @sigma: standard deviation of noise
 *
 * Add gaussian noise with mean 0 and variance sigma to @in.
 * The noise is generated by averaging 12 random numbers,
 * see page 78, PIETGEN, 1989. 
 *
 * See also: im_gaussnoise().
 *
 * Returns: 0 on success, -1 on error
 */
int
im_addgnoise( IMAGE *in, IMAGE *out, double sigma )
{
	IMAGE *t;

	if( !(t = im_open_local( out, "im_addgnoise", "p" )) ||
		im_gaussnoise( t, in->Xsize, in->Ysize, 0, sigma ) ||
		im_add( in, t, out ) )
		return( -1 );

	return( 0 );
}
Exemplo n.º 3
0
/* Call im_gaussnoise via arg vector.
 */
static int
gaussnoise_vec( im_object *argv )
{
	int xsize = *((int *) argv[1]);
	int ysize = *((int *) argv[2]);
	double mean = *((double *) argv[3]);
	double sigma = *((double *) argv[4]);

	if( im_gaussnoise( argv[0], xsize, ysize, mean, sigma ) )
		return( -1 );
	
	return( 0 );
}
Exemplo n.º 4
0
int
im_addgnoise( IMAGE *in, IMAGE *out, double sigma ){
#define FUNCTION_NAME "im_addgnoise"

  if( im_piocheck( in, out ))
    return -1;
  {
    int i;
    IMAGE **temps= IM_ARRAY( out, in-> Bands, IMAGE* );
    IMAGE *joined_temps= im_open_local( out, FUNCTION_NAME ": joined_temps", "p" );

    if( ! temps || ! joined_temps || im_open_local_array( out, temps, in-> Bands, FUNCTION_NAME ": temps", "p" ))
      return -1;

    for( i= 0; i < in-> Bands; ++i )
      if( im_gaussnoise( temps[i], in-> Xsize, in-> Ysize, 0.0, sigma ))
        return -1;

    return im_gbandjoin( temps, joined_temps, in-> Bands ) || im_add( in, joined_temps, out );
  }
#undef FUNCTION_NAME
}