From e493e7136ada4813617d59f57f37afc22e726cb5 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 2 Feb 2010 21:55:29 +0000 Subject: [PATCH] polishing --- doc/reference/libvips-docs.sgml.in | 2 +- libvips/conversion/conver_dispatch.c | 32 +-------------------------- libvips/conversion/im_clip2fmt.c | 12 +++++----- libvips/conversion/im_copy.c | 2 -- libvips/conversion/im_embed.c | 2 +- libvips/conversion/im_extract.c | 5 ++--- libvips/conversion/im_mask2vips.c | 2 +- libvips/conversion/im_system.c | 2 +- libvips/conversion/im_system_image.c | 8 +++---- libvips/conversion/im_vips2mask.c | 4 ++-- libvips/conversion/im_wrap.c | 2 +- libvips/convolution/convol_dispatch.c | 30 +++++++++++++++++++++++++ libvips/include/vips/conversion.h | 5 ++--- libvips/include/vips/convolution.h | 2 ++ 14 files changed, 54 insertions(+), 56 deletions(-) diff --git a/doc/reference/libvips-docs.sgml.in b/doc/reference/libvips-docs.sgml.in index cd9b09c3..a0ff1f2f 100644 --- a/doc/reference/libvips-docs.sgml.in +++ b/doc/reference/libvips-docs.sgml.in @@ -36,11 +36,11 @@ + VIPS operation API by section (no gtkdoc comments yet) - diff --git a/libvips/conversion/conver_dispatch.c b/libvips/conversion/conver_dispatch.c index fa691dfc..423f9301 100644 --- a/libvips/conversion/conver_dispatch.c +++ b/libvips/conversion/conver_dispatch.c @@ -56,7 +56,7 @@ * matrices and back, change header fields, and a few others. * * The second group move pixels about in some way. You can flip, rotate, - * extract, insert and join pairs of iamges in various ways. + * extract, insert and join pairs of images in various ways. * */ @@ -202,35 +202,6 @@ static im_function gaussnoise_desc = { gaussnoise_args /* Arg list */ }; -/* Args to im_addgnoise. - */ -static im_arg_desc addgnoise_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_DOUBLE( "sigma" ) -}; - -/* Call im_addgnoise via arg vector. - */ -static int -addgnoise_vec( im_object *argv ) -{ - double sigma = *((double *) argv[2]); - - return( im_addgnoise( argv[0], argv[1], sigma ) ); -} - -/* Description of im_addgnoise. - */ -static im_function addgnoise_desc = { - "im_addgnoise", /* Name */ - "add gaussian noise with mean 0 and std. dev. sigma", - IM_FN_PIO, /* Flags */ - addgnoise_vec, /* Dispatch function */ - IM_NUMBER( addgnoise_args ), /* Size of arg list */ - addgnoise_args /* Arg list */ -}; - /* Args to im_extract. */ static im_arg_desc extract_args[] = { @@ -1397,7 +1368,6 @@ static im_function embed_desc = { /* Package up all these functions. */ static im_function *conv_list[] = { - &addgnoise_desc, &gaussnoise_desc, &bandjoin_desc, &black_desc, diff --git a/libvips/conversion/im_clip2fmt.c b/libvips/conversion/im_clip2fmt.c index d3741055..afc70a2c 100644 --- a/libvips/conversion/im_clip2fmt.c +++ b/libvips/conversion/im_clip2fmt.c @@ -433,28 +433,28 @@ clip_gen( REGION *or, void *vseq, void *a, void *b ) * Returns: 0 on success, -1 on error */ int -im_clip2fmt( IMAGE *in, IMAGE *out, VipsBandFmt ofmt ) +im_clip2fmt( IMAGE *in, IMAGE *out, VipsBandFmt fmt ) { Clip *clip; if( im_check_uncoded( "im_clip2fmt", in ) || im_piocheck( in, out ) ) return( -1 ); - if( ofmt < 0 || ofmt > IM_BANDFMT_DPCOMPLEX ) { - im_error( "im_clip2fmt", "%s", _( "ofmt out of range" ) ); + if( fmt < 0 || fmt > IM_BANDFMT_DPCOMPLEX ) { + im_error( "im_clip2fmt", "%s", _( "fmt out of range" ) ); return( -1 ); } /* Trivial case: fall back to im_copy(). */ - if( in->BandFmt == ofmt ) + if( in->BandFmt == fmt ) return( im_copy( in, out ) ); - if( !(clip = clip_new( in, out, ofmt )) ) + if( !(clip = clip_new( in, out, fmt )) ) return( -1 ); if( im_cp_desc( out, in ) ) return( -1 ); - out->BandFmt = ofmt; + out->BandFmt = fmt; if( im_demand_hint( out, IM_THINSTRIP, in, NULL ) || im_generate( out, clip_start, clip_gen, clip_stop, in, clip ) ) diff --git a/libvips/conversion/im_copy.c b/libvips/conversion/im_copy.c index 7c5779f2..d0f74e32 100644 --- a/libvips/conversion/im_copy.c +++ b/libvips/conversion/im_copy.c @@ -310,8 +310,6 @@ im_copy_swap8_gen( PEL *in, PEL *out, int width, IMAGE *im ) * im_copy_swap: * @in: input image * @out: output image - * @field: metadata field to set - * @value: value to set for the field * * Copy an image, swapping byte order between little and big endian. This * really does change image pixels and does not just alter the header. diff --git a/libvips/conversion/im_embed.c b/libvips/conversion/im_embed.c index d7e37b55..b6af24ad 100644 --- a/libvips/conversion/im_embed.c +++ b/libvips/conversion/im_embed.c @@ -438,7 +438,7 @@ embed( IMAGE *in, IMAGE *out, int flag, int x, int y, int w, int h ) * * * - * See also: im_extract(), im_insert(). + * See also: im_extract_area(), im_insert(). * * Returns: 0 on success, -1 on error. */ diff --git a/libvips/conversion/im_extract.c b/libvips/conversion/im_extract.c index 466fb36a..d5f61605 100644 --- a/libvips/conversion/im_extract.c +++ b/libvips/conversion/im_extract.c @@ -241,7 +241,7 @@ im_extract_areabands( IMAGE *in, IMAGE *out, * @in: input image * @out: output image * @left: left edge of rectangle - * @top: top edge rectangle + * @top: top edge of rectangle * @width: width of rectangle * @height: height of rectangle * @@ -286,8 +286,7 @@ im_extract_bands( IMAGE *in, IMAGE *out, int band, int nbands ) * im_extract_band: * @in: input image * @out: output image - * @band: first band to extract - * @nbands: number of bands to extract + * @band: band to extract * * Extract a single band from an image. * Extracting outside @in will trigger an error. diff --git a/libvips/conversion/im_mask2vips.c b/libvips/conversion/im_mask2vips.c index 2f1978de..d7067daa 100644 --- a/libvips/conversion/im_mask2vips.c +++ b/libvips/conversion/im_mask2vips.c @@ -54,7 +54,7 @@ * @in: input mask * @out output image * - * Write a one-band, #IM_BANDFMT_DOUBLE image to @out based on mask @in. + * Write a one-band, %IM_BANDFMT_DOUBLE image to @out based on mask @in. * * See also: im_vips2mask(). * diff --git a/libvips/conversion/im_system.c b/libvips/conversion/im_system.c index b509ba81..44fa3d56 100644 --- a/libvips/conversion/im_system.c +++ b/libvips/conversion/im_system.c @@ -72,7 +72,7 @@ * @out: stdout of command is returned here * * im_system() runs a command on an image, returning the command's output as a - * string. The command is executed with popen(), the first '%s' in the + * string. The command is executed with popen(), the first '%%s' in the * command being substituted for a filename. * * If the IMAGE is a file on disc, then the filename will be the name of the diff --git a/libvips/conversion/im_system_image.c b/libvips/conversion/im_system_image.c index 1212507a..8121faa1 100644 --- a/libvips/conversion/im_system_image.c +++ b/libvips/conversion/im_system_image.c @@ -95,14 +95,14 @@ system_image( IMAGE *im, * back. The command's stdout is returned in @log. * * First, @im is written to a file. The filename is formed by substituting - * something like "vips-49857-1" for the first %s in @in_format, then + * something like "vips-49857-1" for the first %%s in @in_format, then * prepending "/tmp". If the environment variable TMPDIR is defined, it * can be used to set a different temporary directory. If @in_format is - * something like "%s.png", the file will be written in PNG format. + * something like "%%s.png", the file will be written in PNG format. * * Next an output filename is created in the same way using @out_format. The - * command string to run is made by substituting the first %s in @cmd_format - * for the name of the input file and the second %s for the output filename. + * command string to run is made by substituting the first %%s in @cmd_format + * for the name of the input file and the second %%s for the output filename. * * The command is executed with popen() and the output captured in @log. If * the command fails, the temporary files are deleted and im_system_image() diff --git a/libvips/conversion/im_vips2mask.c b/libvips/conversion/im_vips2mask.c index a657bc4f..fadc8299 100644 --- a/libvips/conversion/im_vips2mask.c +++ b/libvips/conversion/im_vips2mask.c @@ -57,7 +57,7 @@ * @in: input image * @outname: name for output mask * - * Make a mask from an image. All images are cast to #IM_BANDFMT_DOUBLE + * Make a mask from an image. All images are cast to %IM_BANDFMT_DOUBLE * before processing. There are two cases for handling bands: * * If the image has a single band, im_vips2mask() will write a mask the same @@ -66,7 +66,7 @@ * If the image has more than one band, it must be one pixel high or wide. In * this case the output mask uses that axis to represent band values. * - * See also: im_mask2vips(), im_measure(). + * See also: im_mask2vips(), im_measure_area(). * * Returns: a #DOUBLEMASK with @outname set as the name, or NULL on error */ diff --git a/libvips/conversion/im_wrap.c b/libvips/conversion/im_wrap.c index ae571cc9..ee794baf 100644 --- a/libvips/conversion/im_wrap.c +++ b/libvips/conversion/im_wrap.c @@ -72,7 +72,7 @@ im_wrap( IMAGE *in, IMAGE *out, int x, int y ) y = y < 0 ? -y % in->Ysize : in->Ysize - y % in->Ysize; if( !(t = im_open_local( out, "im_wrap", "p" )) || - im_replicate( in, t[0], 2, 2 ) || + im_replicate( in, t, 2, 2 ) || im_extract_area( t, out, x, y, in->Xsize, in->Ysize ) ) return( -1 ); diff --git a/libvips/convolution/convol_dispatch.c b/libvips/convolution/convol_dispatch.c index 2ebc7c77..e6f1f1cd 100644 --- a/libvips/convolution/convol_dispatch.c +++ b/libvips/convolution/convol_dispatch.c @@ -68,6 +68,35 @@ static im_arg_desc two_in_one_out[] = { IM_OUTPUT_IMAGE( "out" ) }; +/* Args to im_addgnoise. + */ +static im_arg_desc addgnoise_args[] = { + IM_INPUT_IMAGE( "in" ), + IM_OUTPUT_IMAGE( "out" ), + IM_INPUT_DOUBLE( "sigma" ) +}; + +/* Call im_addgnoise via arg vector. + */ +static int +addgnoise_vec( im_object *argv ) +{ + double sigma = *((double *) argv[2]); + + return( im_addgnoise( argv[0], argv[1], sigma ) ); +} + +/* Description of im_addgnoise. + */ +static im_function addgnoise_desc = { + "im_addgnoise", /* Name */ + "add gaussian noise with mean 0 and std. dev. sigma", + IM_FN_PIO, /* Flags */ + addgnoise_vec, /* Dispatch function */ + IM_NUMBER( addgnoise_args ), /* Size of arg list */ + addgnoise_args /* Arg list */ +}; + /* Args to im_contrast_surface. */ static im_arg_desc contrast_surface_args[] = { @@ -400,6 +429,7 @@ static im_function spcor_desc = { /* Package up all these functions. */ static im_function *convol_list[] = { + &addgnoise_desc, &compass_desc, &contrast_surface_desc, &conv_desc, diff --git a/libvips/include/vips/conversion.h b/libvips/include/vips/conversion.h index c7b4a0d4..8ea1d34e 100644 --- a/libvips/include/vips/conversion.h +++ b/libvips/include/vips/conversion.h @@ -50,7 +50,7 @@ int im_copy_swap( IMAGE *in, IMAGE *out ); int im_copy_native( IMAGE *in, IMAGE *out, gboolean is_msb_first ); int im_copy_file( IMAGE *in, IMAGE *out ); -int im_clip2fmt( IMAGE *in, IMAGE *out, VipsBandFmt ofmt ); +int im_clip2fmt( IMAGE *in, IMAGE *out, VipsBandFmt fmt ); int im_scale( IMAGE *in, IMAGE *out ); int im_msb( IMAGE *in, IMAGE *out ); int im_msb_band( IMAGE *in, IMAGE *out, int band ); @@ -63,8 +63,7 @@ int im_c2real( IMAGE *in, IMAGE *out ); int im_scaleps( IMAGE *in, IMAGE *out ); int im_falsecolour( IMAGE *in, IMAGE *out ); -int im_addgnoise( IMAGE *, IMAGE *, double ); -int im_gaussnoise( IMAGE *, int, int, double, double ); +int im_gaussnoise( IMAGE *out, int x, int y, double mean, double sigma ); int im_black( IMAGE *out, int width, int height, int bands ); int im_text( IMAGE *out, const char *text, const char *font, diff --git a/libvips/include/vips/convolution.h b/libvips/include/vips/convolution.h index 49e7fc6d..7b0d1be8 100644 --- a/libvips/include/vips/convolution.h +++ b/libvips/include/vips/convolution.h @@ -60,6 +60,8 @@ int im_gradcor( IMAGE *in, IMAGE *ref, IMAGE *out ); int im_contrast_surface( IMAGE *in, IMAGE *out, int half_win_size, int spacing ); +int im_addgnoise( IMAGE *in, IMAGE *out, double sigma ); + #ifdef __cplusplus } #endif /*__cplusplus*/