From 42b73f0dc8e7cf35f23a02e94466259e235dba3f Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 3 Nov 2009 19:03:47 +0000 Subject: [PATCH] stuff --- TODO | 4 + configure.in | 2 +- doc/reference/Makefile.am | 2 +- doc/reference/libvips-docs.sgml.in | 8 +- libvips/Makefile.am | 4 +- libvips/conversion/Makefile.am | 1 + libvips/conversion/conver_dispatch.c | 37 + .../{convolution => conversion}/im_embed.c | 0 libvips/convolution/Makefile.am | 15 +- libvips/convolution/convol_dispatch.c | 728 +----------------- libvips/freq_filt/Makefile.am | 1 + libvips/freq_filt/freq_dispatch.c | 28 + .../im_phasecor_fft.c | 0 libvips/histograms_lut/Makefile.am | 1 + libvips/histograms_lut/hist_dispatch.c | 30 + .../im_mpercent.c | 0 libvips/include/vips/Makefile.am | 60 +- libvips/include/vips/conversion.h | 2 + libvips/include/vips/convolution.h | 13 - libvips/include/vips/freq_filt.h | 52 ++ libvips/include/vips/histograms_lut.h | 81 ++ libvips/include/vips/mask.h | 33 +- libvips/include/vips/morphology.h | 59 ++ libvips/include/vips/proto.h | 101 --- libvips/include/vips/resample.h | 65 ++ libvips/include/vips/vips.h | 12 +- libvips/iofuncs/package.c | 4 +- libvips/{matrix => mask}/Makefile.am | 10 +- libvips/{convolution => mask}/im_gaussmasks.c | 0 libvips/{convolution => mask}/im_logmasks.c | 0 libvips/{matrix => mask}/im_matcat.c | 0 libvips/{matrix => mask}/im_matinv.c | 0 libvips/{matrix => mask}/im_matmul.c | 0 libvips/{matrix => mask}/im_mattrn.c | 0 libvips/mask/mask_dispatch.c | 577 ++++++++++++++ libvips/{matrix => mask}/matalloc.c | 0 libvips/{convolution => mask}/rotmask.c | 0 libvips/{convolution => mask}/rw_mask.c | 0 libvips/matrix/matrix_dispatch.c | 181 ----- libvips/morphology/Makefile.am | 3 + libvips/{convolution => morphology}/im_rank.c | 0 .../im_rank_image.c | 0 .../{convolution => morphology}/im_zerox.c | 0 libvips/morphology/morph_dispatch.c | 136 ++++ libvips/resample/Makefile.am | 3 + .../im_resize_linear.c | 0 libvips/{convolution => resample}/im_shrink.c | 0 .../{convolution => resample}/im_stretch3.c | 0 libvips/resample/resample_dispatch.c | 98 ++- 49 files changed, 1268 insertions(+), 1083 deletions(-) rename libvips/{convolution => conversion}/im_embed.c (100%) rename libvips/{convolution => freq_filt}/im_phasecor_fft.c (100%) rename libvips/{convolution => histograms_lut}/im_mpercent.c (100%) create mode 100644 libvips/include/vips/freq_filt.h create mode 100644 libvips/include/vips/histograms_lut.h create mode 100644 libvips/include/vips/morphology.h create mode 100644 libvips/include/vips/resample.h rename libvips/{matrix => mask}/Makefile.am (52%) rename libvips/{convolution => mask}/im_gaussmasks.c (100%) rename libvips/{convolution => mask}/im_logmasks.c (100%) rename libvips/{matrix => mask}/im_matcat.c (100%) rename libvips/{matrix => mask}/im_matinv.c (100%) rename libvips/{matrix => mask}/im_matmul.c (100%) rename libvips/{matrix => mask}/im_mattrn.c (100%) create mode 100644 libvips/mask/mask_dispatch.c rename libvips/{matrix => mask}/matalloc.c (100%) rename libvips/{convolution => mask}/rotmask.c (100%) rename libvips/{convolution => mask}/rw_mask.c (100%) delete mode 100644 libvips/matrix/matrix_dispatch.c rename libvips/{convolution => morphology}/im_rank.c (100%) rename libvips/{convolution => morphology}/im_rank_image.c (100%) rename libvips/{convolution => morphology}/im_zerox.c (100%) rename libvips/{convolution => resample}/im_resize_linear.c (100%) rename libvips/{convolution => resample}/im_shrink.c (100%) rename libvips/{convolution => resample}/im_stretch3.c (100%) diff --git a/TODO b/TODO index 848a21c2..8b74b6c2 100644 --- a/TODO +++ b/TODO @@ -2,6 +2,10 @@ avg is different? used to 120.134, now 120.151 +- mask isn't showing up in docs? + +- _raw() variants should be deprecated? + - more stuff from util.c? too much to do it all now - maybe im_insertplaceset() should be im_insertset()? it's not an inplace diff --git a/configure.in b/configure.in index 5fba31de..afce1bb7 100644 --- a/configure.in +++ b/configure.in @@ -515,7 +515,7 @@ AC_OUTPUT([ libvips/histograms_lut/Makefile libvips/inplace/Makefile libvips/iofuncs/Makefile - libvips/matrix/Makefile + libvips/mask/Makefile libvips/morphology/Makefile libvips/mosaicing/Makefile libvips/other/Makefile diff --git a/doc/reference/Makefile.am b/doc/reference/Makefile.am index 646a4280..0b2b88eb 100644 --- a/doc/reference/Makefile.am +++ b/doc/reference/Makefile.am @@ -59,7 +59,7 @@ EXTRA_HFILES= # Header files to ignore when scanning. Use base file name, no paths # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h -IGNORE_HFILES=merge.h debug.h internal.h intl.h CImg.h im_video_v4l1.h global_balance.h dbh.h base64.h templates.h mosaic.h deprecated.h thread.h private.h internal.h almostdeprecated.h fmask.h inlines.h struct.h disp.h +IGNORE_HFILES=merge.h debug.h internal.h intl.h CImg.h im_video_v4l1.h global_balance.h dbh.h base64.h templates.h mosaic.h deprecated.h thread.h private.h internal.h almostdeprecated.h inlines.h struct.h disp.h # Images to copy into HTML directory. # e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png diff --git a/doc/reference/libvips-docs.sgml.in b/doc/reference/libvips-docs.sgml.in index dde02293..9112c37a 100644 --- a/doc/reference/libvips-docs.sgml.in +++ b/doc/reference/libvips-docs.sgml.in @@ -9,9 +9,9 @@ VIPS Reference Manual for VIPS @IM_VERSION@ - The latest version of this documentation can be found on-line at + The latest version of this documentation can be found on the http://www.vips.ecs.soton.ac.uk/index.php?title=Documentation. + url="http://http://www.vips.ecs.soton.ac.uk/index.php?title=Documentation">VIPS website. @@ -42,6 +42,10 @@ VIPS operation API by section (no gtkdoc comments yet) + + + + diff --git a/libvips/Makefile.am b/libvips/Makefile.am index a276c077..478230e3 100644 --- a/libvips/Makefile.am +++ b/libvips/Makefile.am @@ -25,7 +25,7 @@ SUBDIRS = \ histograms_lut \ inplace \ iofuncs \ - matrix \ + mask \ morphology \ mosaicing \ other \ @@ -53,7 +53,7 @@ libvips_la_LIBADD = \ histograms_lut/libhistograms_lut.la \ inplace/libinplace.la \ iofuncs/libiofuncs.la \ - matrix/libmatrix.la \ + mask/libmask.la \ morphology/libmorphology.la \ mosaicing/libmosaicing.la \ other/libother.la \ diff --git a/libvips/conversion/Makefile.am b/libvips/conversion/Makefile.am index 6164fe0f..9db06186 100644 --- a/libvips/conversion/Makefile.am +++ b/libvips/conversion/Makefile.am @@ -18,6 +18,7 @@ libconversion_la_SOURCES = \ im_fliphor.c \ im_flipver.c \ im_gbandjoin.c \ + im_embed.c \ im_insert.c \ im_lrjoin.c \ im_mask2vips.c \ diff --git a/libvips/conversion/conver_dispatch.c b/libvips/conversion/conver_dispatch.c index dbda8acf..5da61ded 100644 --- a/libvips/conversion/conver_dispatch.c +++ b/libvips/conversion/conver_dispatch.c @@ -1321,6 +1321,42 @@ static im_function wrap_desc = { wrap_args /* Arg list */ }; +/* Args for im_embed. + */ +static im_arg_desc embed_args[] = { + IM_INPUT_IMAGE( "in" ), + IM_OUTPUT_IMAGE( "out" ), + IM_INPUT_INT( "type" ), + IM_INPUT_INT( "x" ), + IM_INPUT_INT( "y" ), + IM_INPUT_INT( "w" ), + IM_INPUT_INT( "h" ) +}; + +/* Call im_embed via arg vector. + */ +static int +embed_vec( im_object *argv ) +{ + int type = *((int *) argv[2]); + int x = *((int *) argv[3]); + int y = *((int *) argv[4]); + int w = *((int *) argv[5]); + int h = *((int *) argv[6]); + + return( im_embed( argv[0], argv[1], type, x, y, w, h ) ); +} + +/* Description of im_embed. + */ +static im_function embed_desc = { + "im_embed", /* Name */ + "embed in within a set of borders", + IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */ + embed_vec, /* Dispatch function */ + IM_NUMBER( embed_args ), /* Size of arg list */ + embed_args /* Arg list */ +}; /* Package up all these functions. */ @@ -1353,6 +1389,7 @@ static im_function *conv_list[] = { &grid_desc, &insert_desc, &insert_noexpand_desc, + &embed_desc, &lrjoin_desc, &mask2vips_desc, &msb_desc, diff --git a/libvips/convolution/im_embed.c b/libvips/conversion/im_embed.c similarity index 100% rename from libvips/convolution/im_embed.c rename to libvips/conversion/im_embed.c diff --git a/libvips/convolution/Makefile.am b/libvips/convolution/Makefile.am index d876fe3f..8b9b47e4 100644 --- a/libvips/convolution/Makefile.am +++ b/libvips/convolution/Makefile.am @@ -1,8 +1,6 @@ noinst_LTLIBRARIES = libconvolution.la libconvolution_la_SOURCES = \ - rotmask.c \ - rw_mask.c \ convol_dispatch.c \ im_addgnoise.c \ im_compass.c \ @@ -12,21 +10,10 @@ libconvolution_la_SOURCES = \ im_convsepf.c \ im_convsub.c \ im_contrast_surface.c \ - im_embed.c \ im_fastcor.c \ - im_gaussmasks.c \ im_gaussnoise.c \ im_gradcor.c \ - im_logmasks.c \ - im_rank_image.c \ - im_mpercent.c \ - im_phasecor_fft.c \ - im_rank.c \ - im_resize_linear.c \ im_sharpen.c \ - im_shrink.c \ - im_spcor.c \ - im_stretch3.c \ - im_zerox.c + im_spcor.c INCLUDES = -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@ diff --git a/libvips/convolution/convol_dispatch.c b/libvips/convolution/convol_dispatch.c index a5b16d90..bcb847a9 100644 --- a/libvips/convolution/convol_dispatch.c +++ b/libvips/convolution/convol_dispatch.c @@ -57,37 +57,6 @@ static im_arg_desc two_in_one_out[] = { IM_OUTPUT_IMAGE( "out" ) }; -/* Args to im_stretch3. - */ -static im_arg_desc stretch3_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_DOUBLE( "xdisp" ), - IM_INPUT_DOUBLE( "ydisp" ) -}; - -/* Call im_stretch3 via arg vector. - */ -static int -stretch3_vec( im_object *argv ) -{ - double xdisp = *((int *) argv[2]); - double ydisp = *((int *) argv[3]); - - return( im_stretch3( argv[0], argv[1], xdisp, ydisp ) ); -} - -/* Description of im_stretch3. - */ -static im_function stretch3_desc = { - "im_stretch3", /* Name */ - "stretch 3%, sub-pixel displace by xdisp/ydisp", - IM_FN_PIO, /* Flags */ - stretch3_vec, /* Dispatch function */ - IM_NUMBER( stretch3_args ), /* Size of arg list */ - stretch3_args /* Arg list */ -}; - /* Args to im_contrast_surface. */ static im_arg_desc contrast_surface_args[] = { @@ -152,81 +121,6 @@ static im_function contrast_surface_raw_desc = { contrast_surface_raw_args /* Arg list */ }; -/* Call im_phasecor_fft via arg vector. - */ -static int -phasecor_fft_vec( im_object *argv ) -{ - return( im_phasecor_fft( argv[0], argv[1], argv[2] ) ); -} - -/* Description of im_phasecor_fft. - */ -static im_function phasecor_fft_desc = { - "im_phasecor_fft", /* Name */ - "non-normalised correlation of gradient of in2 within in1", - IM_FN_TRANSFORM, /* Flags */ - phasecor_fft_vec, /* Dispatch function */ - IM_NUMBER( two_in_one_out ), /* Size of arg list */ - two_in_one_out /* Arg list */ -}; - -/* Args to im_rank. - */ -static im_arg_desc rank_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_INT( "xsize" ), - IM_INPUT_INT( "ysize" ), - IM_INPUT_INT( "n" ) -}; - -/* Call im_rank via arg vector. - */ -static int -rank_vec( im_object *argv ) -{ - int xsize = *((int *) argv[2]); - int ysize = *((int *) argv[3]); - int n = *((int *) argv[4]); - - return( im_rank( argv[0], argv[1], xsize, ysize, n ) ); -} - -/* Description of im_rank. - */ -static im_function rank_desc = { - "im_rank", /* Name */ - "rank filter nth element of xsize/ysize window", - IM_FN_PIO, /* Flags */ - rank_vec, /* Dispatch function */ - IM_NUMBER( rank_args ), /* Size of arg list */ - rank_args /* Arg list */ -}; - -/* Call im_rank_raw via arg vector. - */ -static int -rank_raw_vec( im_object *argv ) -{ - int xsize = *((int *) argv[2]); - int ysize = *((int *) argv[3]); - int n = *((int *) argv[4]); - - return( im_rank_raw( argv[0], argv[1], xsize, ysize, n ) ); -} - -/* Description of im_rank_raw. - */ -static im_function rank_raw_desc = { - "im_rank_raw", /* Name */ - "rank filter nth element of xsize/ysize window, no border", - IM_FN_PIO, /* Flags */ - rank_raw_vec, /* Dispatch function */ - IM_NUMBER( rank_args ), /* Size of arg list */ - rank_args /* Arg list */ -}; - /* Args to im_sharpen. */ static im_arg_desc sharpen_args[] = { @@ -295,37 +189,6 @@ static im_function addgnoise_desc = { addgnoise_args /* Arg list */ }; -/* Args for im_read_dmask() - */ -static im_arg_desc read_dmask_args[] = { - IM_INPUT_STRING( "filename" ), - IM_OUTPUT_DMASK( "mask" ) -}; - -/* Call im_read_dmask via arg vector. - */ -static int -read_dmask_vec( im_object *argv ) -{ - im_mask_object *mo = argv[1]; - - if( !(mo->mask = im_read_dmask( argv[0] )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_read_dmask(). - */ -static im_function read_dmask_desc = { - "im_read_dmask", /* Name */ - "read matrix of double from file", - 0, /* Flags */ - read_dmask_vec, /* Dispatch function */ - IM_NUMBER( read_dmask_args ), /* Size of arg list */ - read_dmask_args /* Arg list */ -}; - /* Args for convolver with imask. */ static im_arg_desc conv_imask[] = { @@ -602,103 +465,6 @@ static im_function fastcor_raw_desc = { two_in_one_out /* Arg list */ }; -/* Args for im_gauss_dmask. - */ -static im_arg_desc gauss_dmask_args[] = { - IM_OUTPUT_DMASK( "mask" ), - IM_INPUT_DOUBLE( "sigma" ), - IM_INPUT_DOUBLE( "min_amp" ) -}; - -/* Call im_gauss_dmask via arg vector. - */ -static int -gauss_dmask_vec( im_object *argv ) -{ - im_mask_object *mo = argv[0]; - double sigma = *((double *) argv[1]); - double min_amp = *((double *) argv[2]); - - if( !(mo->mask = - im_gauss_dmask( mo->name, sigma, min_amp )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_gauss_dmask. - */ -static im_function gauss_dmask_desc = { - "im_gauss_dmask", /* Name */ - "generate gaussian DOUBLEMASK", - 0, /* Flags */ - gauss_dmask_vec, /* Dispatch function */ - IM_NUMBER( gauss_dmask_args ), /* Size of arg list */ - gauss_dmask_args /* Arg list */ -}; - -/* Args for im_gauss_imask. - */ -static im_arg_desc gauss_imask_args[] = { - IM_OUTPUT_IMASK( "mask" ), - IM_INPUT_DOUBLE( "sigma" ), - IM_INPUT_DOUBLE( "min_amp" ) -}; - -/* Call im_gauss_imask via arg vector. - */ -static int -gauss_imask_vec( im_object *argv ) -{ - im_mask_object *mo = argv[0]; - double sigma = *((double *) argv[1]); - double min_amp = *((double *) argv[2]); - - if( !(mo->mask = - im_gauss_imask( mo->name, sigma, min_amp )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_gauss_imask. - */ -static im_function gauss_imask_desc = { - "im_gauss_imask", /* Name */ - "generate gaussian INTMASK", - 0, /* Flags */ - gauss_imask_vec, /* Dispatch function */ - IM_NUMBER( gauss_imask_args ), /* Size of arg list */ - gauss_imask_args /* Arg list */ -}; - -/* Call im_gauss_imask_sep via arg vector. - */ -static int -gauss_imask_sep_vec( im_object *argv ) -{ - im_mask_object *mo = argv[0]; - double sigma = *((double *) argv[1]); - double min_amp = *((double *) argv[2]); - - if( !(mo->mask = - im_gauss_imask_sep( mo->name, sigma, min_amp )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_gauss_imask_sep. - */ -static im_function gauss_imask_sep_desc = { - "im_gauss_imask_sep", /* Name */ - "generate separable gaussian INTMASK", - 0, /* Flags */ - gauss_imask_sep_vec, /* Dispatch function */ - IM_NUMBER( gauss_imask_args ), /* Size of arg list */ - gauss_imask_args /* Arg list */ -}; - /* Args for im_gaussnoise. */ static im_arg_desc gaussnoise_args[] = { @@ -854,167 +620,6 @@ static im_function lindetect_desc = { conv_imask /* Arg list */ }; -/* Args for im_log_imask. - */ -static im_arg_desc log_imask_args[] = { - IM_OUTPUT_IMASK( "mask" ), - IM_INPUT_DOUBLE( "sigma" ), - IM_INPUT_DOUBLE( "min_amp" ) -}; - -/* Call im_log_imask via arg vector. - */ -static int -log_imask_vec( im_object *argv ) -{ - im_mask_object *mo = argv[0]; - double sigma = *((double *) argv[1]); - double min_amp = *((double *) argv[2]); - - if( !(mo->mask = - im_log_imask( mo->name, sigma, min_amp )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_log_imask. - */ -static im_function log_imask_desc = { - "im_log_imask", /* Name */ - "generate laplacian of gaussian INTMASK", - 0, /* Flags */ - log_imask_vec, /* Dispatch function */ - IM_NUMBER( log_imask_args ), /* Size of arg list */ - log_imask_args /* Arg list */ -}; - -/* Args for im_log_dmask. - */ -static im_arg_desc log_dmask_args[] = { - IM_OUTPUT_DMASK( "maskfile" ), - IM_INPUT_DOUBLE( "sigma" ), - IM_INPUT_DOUBLE( "min_amp" ) -}; - -/* Call im_log_dmask via arg vector. - */ -static int -log_dmask_vec( im_object *argv ) -{ - im_mask_object *mo = argv[0]; - double sigma = *((double *) argv[1]); - double min_amp = *((double *) argv[2]); - - if( !(mo->mask = - im_log_dmask( mo->name, sigma, min_amp )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_log_dmask. - */ -static im_function log_dmask_desc = { - "im_log_dmask", /* Name */ - "generate laplacian of gaussian DOUBLEMASK", - 0, /* Flags */ - log_dmask_vec, /* Dispatch function */ - IM_NUMBER( log_dmask_args ), /* Size of arg list */ - log_dmask_args /* Arg list */ -}; - -/* Args for im_resize_linear. - */ -static im_arg_desc resize_linear_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_INT( "X" ), - IM_INPUT_INT( "Y" ) -}; - -/* Call im_resize_linear via arg vector. - */ -static int -resize_linear_vec( im_object *argv ) -{ - int X = *((int *) argv[2]); - int Y = *((int *) argv[3]); - - return( im_resize_linear( argv[0], argv[1], X, Y ) ); -} - -/* Description of im_resize_linear. - */ -static im_function resize_linear_desc = { - "im_resize_linear", /* Name */ - "resize to X by Y pixels with linear interpolation", - 0, /* Flags */ - resize_linear_vec, /* Dispatch function */ - IM_NUMBER( resize_linear_args ), /* Size of arg list */ - resize_linear_args /* Arg list */ -}; - -/* Args for im_mpercent. - */ -static im_arg_desc mpercent_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_INPUT_DOUBLE( "percent" ), - IM_OUTPUT_INT( "thresh" ) -}; - -/* Call im_mpercent via arg vector. - */ -static int -mpercent_vec( im_object *argv ) -{ - double percent = *((double *) argv[1]); - - return( im_mpercent( argv[0], percent, argv[2] ) ); -} - -/* Description of im_mpercent. - */ -static im_function mpercent_desc = { - "im_mpercent", /* Name */ - "find threshold above which there are percent values", - 0, /* Flags */ - mpercent_vec, /* Dispatch function */ - IM_NUMBER( mpercent_args ), /* Size of arg list */ - mpercent_args /* Arg list */ -}; - -/* Args for im_shrink. - */ -static im_arg_desc shrink_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_DOUBLE( "xfac" ), - IM_INPUT_DOUBLE( "yfac" ) -}; - -/* Call im_shrink via arg vector. - */ -static int -shrink_vec( im_object *argv ) -{ - double xshrink = *((double *) argv[2]); - double yshrink = *((double *) argv[3]); - - return( im_shrink( argv[0], argv[1], xshrink, yshrink ) ); -} - -/* Description of im_shrink. - */ -static im_function shrink_desc = { - "im_shrink", /* Name */ - "shrink image by xfac, yfac times", - IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */ - shrink_vec, /* Dispatch function */ - IM_NUMBER( shrink_args ), /* Size of arg list */ - shrink_args /* Arg list */ -}; - /* Call im_spcor via arg vector. */ static int @@ -1053,304 +658,6 @@ static im_function spcor_raw_desc = { two_in_one_out /* Arg list */ }; -/* Args for im_zerox. - */ -static im_arg_desc zerox_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_INT( "flag" ) -}; - -/* Call im_zerox via arg vector. - */ -static int -zerox_vec( im_object *argv ) -{ - int flag = *((int *) argv[2]); - - return( im_zerox( argv[0], argv[1], flag ) ); -} - -/* Description of im_zerox. - */ -static im_function zerox_desc = { - "im_zerox", /* Name */ - "find +ve or -ve zero crossings in image", - IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */ - zerox_vec, /* Dispatch function */ - IM_NUMBER( zerox_args ), /* Size of arg list */ - zerox_args /* Arg list */ -}; - -/* Args for im_embed. - */ -static im_arg_desc embed_args[] = { - IM_INPUT_IMAGE( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_INT( "type" ), - IM_INPUT_INT( "x" ), - IM_INPUT_INT( "y" ), - IM_INPUT_INT( "w" ), - IM_INPUT_INT( "h" ) -}; - -/* Call im_embed via arg vector. - */ -static int -embed_vec( im_object *argv ) -{ - int type = *((int *) argv[2]); - int x = *((int *) argv[3]); - int y = *((int *) argv[4]); - int w = *((int *) argv[5]); - int h = *((int *) argv[6]); - - return( im_embed( argv[0], argv[1], type, x, y, w, h ) ); -} - -/* Description of im_embed. - */ -static im_function embed_desc = { - "im_embed", /* Name */ - "embed in within a set of borders", - IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */ - embed_vec, /* Dispatch function */ - IM_NUMBER( embed_args ), /* Size of arg list */ - embed_args /* Arg list */ -}; - -/* Mask functions! - */ -static im_arg_desc imask_args[] = { - IM_INPUT_IMASK( "in" ), - IM_OUTPUT_IMASK( "out" ) -}; - -static im_arg_desc dmask_args[] = { - IM_INPUT_DMASK( "in" ), - IM_OUTPUT_DMASK( "out" ) -}; - -/* Call im_rotate_imask45 via arg vector. - */ -static int -rotate_imask45_vec( im_object *argv ) -{ - im_mask_object *min = argv[0]; - im_mask_object *mout = argv[1]; - - if( !(mout->mask = im_rotate_imask45( min->mask, mout->name )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_rotate_imask45. - */ -static im_function rotate_imask45_desc = { - "im_rotate_imask45", /* Name */ - "rotate INTMASK clockwise by 45 degrees", - 0, /* Flags */ - rotate_imask45_vec, /* Dispatch function */ - IM_NUMBER( imask_args ), /* Size of arg list */ - imask_args /* Arg list */ -}; - -/* Call im_rotate_imask90 via arg vector. - */ -static int -rotate_imask90_vec( im_object *argv ) -{ - im_mask_object *min = argv[0]; - im_mask_object *mout = argv[1]; - - if( !(mout->mask = im_rotate_imask90( min->mask, mout->name )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_rotate_imask90. - */ -static im_function rotate_imask90_desc = { - "im_rotate_imask90", /* Name */ - "rotate INTMASK clockwise by 90 degrees", - 0, /* Flags */ - rotate_imask90_vec, /* Dispatch function */ - IM_NUMBER( imask_args ), /* Size of arg list */ - imask_args /* Arg list */ -}; - -/* Call im_rotate_dmask45 via arg vector. - */ -static int -rotate_dmask45_vec( im_object *argv ) -{ - im_mask_object *min = argv[0]; - im_mask_object *mout = argv[1]; - - if( !(mout->mask = im_rotate_dmask45( min->mask, mout->name )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_rotate_dmask45. - */ -static im_function rotate_dmask45_desc = { - "im_rotate_dmask45", /* Name */ - "rotate DOUBLEMASK clockwise by 45 degrees", - 0, /* Flags */ - rotate_dmask45_vec, /* Dispatch function */ - IM_NUMBER( dmask_args ), /* Size of arg list */ - dmask_args /* Arg list */ -}; - -/* Call im_rotate_dmask90 via arg vector. - */ -static int -rotate_dmask90_vec( im_object *argv ) -{ - im_mask_object *min = argv[0]; - im_mask_object *mout = argv[1]; - - if( !(mout->mask = im_rotate_dmask90( min->mask, mout->name )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_rotate_dmask90. - */ -static im_function rotate_dmask90_desc = { - "im_rotate_dmask90", /* Name */ - "rotate DOUBLEMASK clockwise by 90 degrees", - 0, /* Flags */ - rotate_dmask90_vec, /* Dispatch function */ - IM_NUMBER( dmask_args ), /* Size of arg list */ - dmask_args /* Arg list */ -}; - -static im_arg_desc maxvalue_args[] = { - IM_INPUT_IMAGEVEC( "in" ), - IM_OUTPUT_IMAGE( "out" ) -}; - -static int -maxvalue_vec( im_object *argv ) -{ - im_imagevec_object *iv = (im_imagevec_object *) argv[0]; - - return( im_maxvalue( iv->vec, argv[1], iv->n ) ); -} - -static im_function maxvalue_desc = { - "im_maxvalue", /* Name */ - "point-wise maximum value", /* Description */ - IM_FN_PIO, /* Flags */ - maxvalue_vec, /* Dispatch function */ - IM_NUMBER( maxvalue_args ), /* Size of arg list */ - maxvalue_args /* Arg list */ -}; - -static im_arg_desc rank_image_args[] = { - IM_INPUT_IMAGEVEC( "in" ), - IM_OUTPUT_IMAGE( "out" ), - IM_INPUT_INT( "index" ) -}; - -static int -rank_image_vec( im_object *argv ) -{ - im_imagevec_object *iv = (im_imagevec_object *) argv[0]; - int index = *((int *) argv[2]); - - return( im_rank_image( iv->vec, argv[1], iv->n, index ) ); -} - -static im_function rank_image_desc = { - "im_rank_image", /* Name */ - "point-wise pixel rank", /* Description */ - IM_FN_PIO, /* Flags */ - rank_image_vec, /* Dispatch function */ - IM_NUMBER( rank_image_args ), /* Size of arg list */ - rank_image_args /* Arg list */ -}; - -static int -imask_xsize_vec( im_object *argv ) -{ - *( (int*) argv[1] )= ( (INTMASK*) ( ( (im_mask_object*) argv[0] )-> mask ) )-> xsize; - return 0; -} - -static int -imask_ysize_vec( im_object *argv ) -{ - *( (int*) argv[1] )= ( (INTMASK*) ( ( (im_mask_object*) argv[0] )-> mask ) )-> ysize; - return 0; -} - -static int -dmask_xsize_vec( im_object *argv ) -{ - *( (int*) argv[1] )= ( (DOUBLEMASK*) ( ( (im_mask_object*) argv[0] )-> mask ) )-> xsize; - return 0; -} - -static int -dmask_ysize_vec( im_object *argv ) -{ - *( (int*) argv[1] )= ( (DOUBLEMASK*) ( ( (im_mask_object*) argv[0] )-> mask ) )-> ysize; - return 0; -} - -static im_arg_desc imask_size_args[] = { - IM_INPUT_IMASK( "mask" ), - IM_OUTPUT_INT( "size" ) -}; - -static im_arg_desc dmask_size_args[] = { - IM_INPUT_DMASK( "mask" ), - IM_OUTPUT_INT( "size" ) -}; - -static im_function imask_xsize_desc = { - "im_imask_xsize", /* Name */ - "horizontal size of an intmask", /* Description */ - 0, /* Flags */ - imask_xsize_vec, /* Dispatch function */ - IM_NUMBER( imask_size_args ), /* Size of arg list */ - imask_size_args /* Arg list */ -}; - -static im_function imask_ysize_desc = { - "im_imask_ysize", /* Name */ - "vertical size of an intmask", /* Description */ - 0, /* Flags */ - imask_ysize_vec, /* Dispatch function */ - IM_NUMBER( imask_size_args ), /* Size of arg list */ - imask_size_args /* Arg list */ -}; - -static im_function dmask_xsize_desc = { - "im_dmask_xsize", /* Name */ - "horizontal size of a doublemask", /* Description */ - 0, /* Flags */ - dmask_xsize_vec, /* Dispatch function */ - IM_NUMBER( dmask_size_args ), /* Size of arg list */ - dmask_size_args /* Arg list */ -}; - -static im_function dmask_ysize_desc = { - "im_dmask_ysize", /* Name */ - "vertical size of a doublemask", /* Description */ - 0, /* Flags */ - dmask_ysize_vec, /* Dispatch function */ - IM_NUMBER( dmask_size_args ), /* Size of arg list */ - dmask_size_args /* Arg list */ -}; - /* Package up all these functions. */ static im_function *convol_list[] = { @@ -1359,51 +666,26 @@ static im_function *convol_list[] = { &contrast_surface_desc, &contrast_surface_raw_desc, &conv_desc, - &conv_raw_desc, &convf_desc, &convf_raw_desc, + &conv_raw_desc, &convsep_desc, - &convsep_raw_desc, &convsepf_desc, &convsepf_raw_desc, + &convsep_raw_desc, &convsub_desc, - &dmask_xsize_desc, - &dmask_ysize_desc, - &embed_desc, &fastcor_desc, &fastcor_raw_desc, - &gauss_dmask_desc, - &gauss_imask_desc, - &gauss_imask_sep_desc, &gaussnoise_desc, - &grad_x_desc, - &grad_y_desc, &gradcor_desc, &gradcor_raw_desc, &gradient_desc, - &imask_xsize_desc, - &imask_ysize_desc, - &rank_image_desc, + &grad_x_desc, + &grad_y_desc, &lindetect_desc, - &log_dmask_desc, - &log_imask_desc, - &maxvalue_desc, - &mpercent_desc, - &phasecor_fft_desc, - &rank_desc, - &rank_raw_desc, - &read_dmask_desc, - &resize_linear_desc, - &rotate_dmask45_desc, - &rotate_dmask90_desc, - &rotate_imask45_desc, - &rotate_imask90_desc, &sharpen_desc, - &shrink_desc, &spcor_desc, - &spcor_raw_desc, - &stretch3_desc, - &zerox_desc + &spcor_raw_desc }; /* Package of functions. diff --git a/libvips/freq_filt/Makefile.am b/libvips/freq_filt/Makefile.am index 7e1755ab..d58d401d 100644 --- a/libvips/freq_filt/Makefile.am +++ b/libvips/freq_filt/Makefile.am @@ -3,6 +3,7 @@ noinst_LTLIBRARIES = libfreq_filt.la libfreq_filt_la_SOURCES = \ fft_sp.c \ fmask4th.c \ + im_phasecor_fft.c \ fmaskcir.c \ freq_dispatch.c \ im_disp_ps.c \ diff --git a/libvips/freq_filt/freq_dispatch.c b/libvips/freq_filt/freq_dispatch.c index bf6bb73c..cfb2d396 100644 --- a/libvips/freq_filt/freq_dispatch.c +++ b/libvips/freq_filt/freq_dispatch.c @@ -53,6 +53,14 @@ static im_arg_desc one_in_one_out[] = { IM_OUTPUT_IMAGE( "out" ) }; +/* Two images in, one out. + */ +static im_arg_desc two_in_one_out[] = { + IM_INPUT_IMAGE( "in1" ), + IM_INPUT_IMAGE( "in2" ), + IM_OUTPUT_IMAGE( "out" ) +}; + /* Args to im_create_fmask(). */ static im_arg_desc create_fmask_args[] = { @@ -288,6 +296,25 @@ static im_function invfftr_desc = { one_in_one_out /* Arg list */ }; +/* Call im_phasecor_fft via arg vector. + */ +static int +phasecor_fft_vec( im_object *argv ) +{ + return( im_phasecor_fft( argv[0], argv[1], argv[2] ) ); +} + +/* Description of im_phasecor_fft. + */ +static im_function phasecor_fft_desc = { + "im_phasecor_fft", /* Name */ + "non-normalised correlation of gradient of in2 within in1", + IM_FN_TRANSFORM, /* Flags */ + phasecor_fft_vec, /* Dispatch function */ + IM_NUMBER( two_in_one_out ), /* Size of arg list */ + two_in_one_out /* Arg list */ +}; + /* Package up all these functions. */ static im_function *freq_list[] = { @@ -299,6 +326,7 @@ static im_function *freq_list[] = { &fwfft_desc, &rotquad_desc, &invfft_desc, + &phasecor_fft_desc, &invfftr_desc }; diff --git a/libvips/convolution/im_phasecor_fft.c b/libvips/freq_filt/im_phasecor_fft.c similarity index 100% rename from libvips/convolution/im_phasecor_fft.c rename to libvips/freq_filt/im_phasecor_fft.c diff --git a/libvips/histograms_lut/Makefile.am b/libvips/histograms_lut/Makefile.am index 050cd31b..7a320a25 100644 --- a/libvips/histograms_lut/Makefile.am +++ b/libvips/histograms_lut/Makefile.am @@ -12,6 +12,7 @@ libhistograms_lut_la_SOURCES = \ im_histindexed.c \ im_histspec.c \ im_hsp.c \ + im_mpercent.c \ im_identity.c \ im_invertlut.c \ im_lhisteq.c \ diff --git a/libvips/histograms_lut/hist_dispatch.c b/libvips/histograms_lut/hist_dispatch.c index e85df786..70b2e9db 100644 --- a/libvips/histograms_lut/hist_dispatch.c +++ b/libvips/histograms_lut/hist_dispatch.c @@ -796,6 +796,35 @@ static im_function tone_map_desc = { tone_map_args /* Arg list */ }; +/* Args for im_mpercent. + */ +static im_arg_desc mpercent_args[] = { + IM_INPUT_IMAGE( "in" ), + IM_INPUT_DOUBLE( "percent" ), + IM_OUTPUT_INT( "thresh" ) +}; + +/* Call im_mpercent via arg vector. + */ +static int +mpercent_vec( im_object *argv ) +{ + double percent = *((double *) argv[1]); + + return( im_mpercent( argv[0], percent, argv[2] ) ); +} + +/* Description of im_mpercent. + */ +static im_function mpercent_desc = { + "im_mpercent", /* Name */ + "find threshold above which there are percent values", + 0, /* Flags */ + mpercent_vec, /* Dispatch function */ + IM_NUMBER( mpercent_args ), /* Size of arg list */ + mpercent_args /* Arg list */ +}; + /* Package up all these functions. */ static im_function *hist_list[] = { @@ -815,6 +844,7 @@ static im_function *hist_list[] = { &identity_ushort_desc, &ismonotonic_desc, &lhisteq_desc, + &mpercent_desc, &lhisteq_raw_desc, &invertlut_desc, &buildlut_desc, diff --git a/libvips/convolution/im_mpercent.c b/libvips/histograms_lut/im_mpercent.c similarity index 100% rename from libvips/convolution/im_mpercent.c rename to libvips/histograms_lut/im_mpercent.c diff --git a/libvips/include/vips/Makefile.am b/libvips/include/vips/Makefile.am index 8523213a..6894dd95 100644 --- a/libvips/include/vips/Makefile.am +++ b/libvips/include/vips/Makefile.am @@ -1,43 +1,47 @@ pkginclude_HEADERS = \ - arithmetic.h \ - relational.h \ - colour.h \ - boolean.h \ - debug.h \ - dispatch.h \ - format.h \ - header.h \ - callback.h \ - error.h \ - fmask.h \ - mosaic.h \ - check.h \ - interpolate.h \ - object.h \ almostdeprecated.h \ - proto.h \ - image.h \ - vips \ + arithmetic.h \ + boolean.h \ + buf.h \ + callback.h \ + check.h \ + colour.h \ conversion.h \ convolution.h \ + debug.h \ + dispatch.h \ + disp.h \ + error.h \ + fmask.h \ + format.h \ + generate.h \ + header.h \ + histograms_lut.h \ + freq_filt.h \ + image.h \ + interpolate.h \ + intl.h \ mask.h \ + memory.h \ + meta.h \ + morphology.h \ + mosaic.h \ + object.h \ + private.h \ + proto.h \ rect.h \ region.h \ - generate.h \ - memory.h \ - struct.h \ - disp.h \ - private.h \ + relational.h \ + resample.h \ semaphore.h \ - transform.h \ + struct.h \ threadgroup.h \ thread.h \ + transform.h \ util.h \ - meta.h \ version.h \ - vips.h \ - intl.h \ - buf.h + vips \ + vips.h vipsc++.h: vips --cpph all > vipsc++.h diff --git a/libvips/include/vips/conversion.h b/libvips/include/vips/conversion.h index 06d3b75c..093d28ca 100644 --- a/libvips/include/vips/conversion.h +++ b/libvips/include/vips/conversion.h @@ -66,6 +66,8 @@ int im_extract_bands( IMAGE *in, IMAGE *out, int band, int nbands ); int im_extract_area( IMAGE *in, IMAGE *out, int x, int y, int w, int h ); int im_extract_areabands( IMAGE *in, IMAGE *out, int left, int top, int width, int height, int band, int nbands ); +int im_embed( IMAGE *in, IMAGE *out, int type, + int left, int top, int width, int height ); int im_subsample( IMAGE *in, IMAGE *out, int x, int y ); int im_zoom( IMAGE *in, IMAGE *out, int x, int y ); diff --git a/libvips/include/vips/convolution.h b/libvips/include/vips/convolution.h index 269d6adf..e9e81fb1 100644 --- a/libvips/include/vips/convolution.h +++ b/libvips/include/vips/convolution.h @@ -37,16 +37,10 @@ extern "C" { #endif /*__cplusplus*/ -int im_rank( IMAGE *in, IMAGE *out, int width, int height, int rank ); -int im_rank_image( IMAGE **in, IMAGE *out, int n, int index ); -int im_rank_raw( IMAGE *in, IMAGE *out, int xsize, int ysize, int n ); -int im_zerox( IMAGE *, IMAGE *, int ); - int im_sharpen( IMAGE *, IMAGE *, int, double, double, double, double, double ); int im_addgnoise( IMAGE *, IMAGE *, double ); int im_gaussnoise( IMAGE *, int, int, double, double ); -int im_maxvalue( IMAGE **in, IMAGE *out, int n ); int im_compass( IMAGE *, IMAGE *, INTMASK * ); int im_gradient( IMAGE *, IMAGE *, INTMASK * ); int im_lindetect( IMAGE *, IMAGE *, INTMASK * ); @@ -73,13 +67,6 @@ int im_gradcor_raw( IMAGE *, IMAGE *, IMAGE * ); int im_contrast_surface( IMAGE *, IMAGE *, int, int ); int im_contrast_surface_raw( IMAGE *, IMAGE *, int, int ); -int im_resize_linear( IMAGE *, IMAGE *, int, int ); -int im_mpercent( IMAGE *, double, int * ); -int im_embed( IMAGE *, IMAGE *, int, int, int, int, int ); - -int im_stretch3( IMAGE *in, IMAGE *out, double dx, double dy ); -int im_shrink( IMAGE *, IMAGE *, double, double ); - #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvips/include/vips/freq_filt.h b/libvips/include/vips/freq_filt.h new file mode 100644 index 00000000..5ca5257f --- /dev/null +++ b/libvips/include/vips/freq_filt.h @@ -0,0 +1,52 @@ +/* freq_filt.h + * + * 2/11/09 + * - from proto.h + */ + +/* + + This file is part of VIPS. + + VIPS is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +#ifndef IM_FREQ_H +#define IM_FREQ_H + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus*/ + +int im_fractsurf( IMAGE *out, int size, double frd ); +int im_freqflt( IMAGE *, IMAGE *, IMAGE * ); +int im_disp_ps( IMAGE *, IMAGE * ); +int im_rotquad( IMAGE *, IMAGE * ); +int im_fwfft( IMAGE *, IMAGE * ); +int im_invfft( IMAGE *, IMAGE * ); +int im_invfftr( IMAGE *, IMAGE * ); + +#ifdef __cplusplus +} +#endif /*__cplusplus*/ + +#endif /*IM_FREQ_H*/ diff --git a/libvips/include/vips/histograms_lut.h b/libvips/include/vips/histograms_lut.h new file mode 100644 index 00000000..33915b97 --- /dev/null +++ b/libvips/include/vips/histograms_lut.h @@ -0,0 +1,81 @@ +/* histograms_lut.h + * + * 3/11/09 + * - from proto.h + */ + +/* + + This file is part of VIPS. + + VIPS is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +#ifndef IM_HIST_H +#define IM_HIST_H + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus*/ + +int im_maplut( IMAGE *, IMAGE *, IMAGE * ); +int im_gammacorrect( IMAGE *, IMAGE *, double ); +int im_heq( IMAGE *in, IMAGE *out, int bandno ); +int im_hist( IMAGE *in, IMAGE *out, int bandno ); +int im_hist_indexed( IMAGE *index, IMAGE *value, IMAGE *out ); +int im_histeq( IMAGE *in, IMAGE *out ); +int im_histnorm( IMAGE *in, IMAGE *out ); +int im_histcum( IMAGE *in, IMAGE *out ); +int im_histgr( IMAGE *in, IMAGE *out, int bandno ); +int im_histnD( IMAGE *in, IMAGE *out, int bins ); +int im_histplot( IMAGE *hist, IMAGE *histplot ); +int im_histspec( IMAGE *hin, IMAGE *href, IMAGE *lut ); +int im_hsp( IMAGE *in, IMAGE *ref, IMAGE *out ); +int im_identity( IMAGE *lut, int bands ); +int im_identity_ushort( IMAGE *lut, int bands, int sz ); +int im_lhisteq( IMAGE *in, IMAGE *out, int xwin, int ywin ); +int im_lhisteq_raw( IMAGE *in, IMAGE *out, int xwin, int ywin ); +int im_invertlut( DOUBLEMASK *input, IMAGE *output, int lut_size ); +int im_buildlut( DOUBLEMASK *input, IMAGE *output ); +int im_stdif( IMAGE *in, IMAGE *out, + double a, double m0, double b, double s0, int xwin, int ywin ); +int im_stdif_raw( IMAGE *in, IMAGE *out, + double a, double m0, double b, double s0, int xwin, int ywin ); +int im_tone_build_range( IMAGE *out, + int in_max, int out_max, + double Lb, double Lw, double Ps, double Pm, double Ph, + double S, double M, double H ); +int im_tone_build( IMAGE *out, + double Lb, double Lw, double Ps, double Pm, double Ph, + double S, double M, double H ); +int im_tone_analyse( IMAGE *in, IMAGE *lut, + double Ps, double Pm, double Ph, double S, double M, double H ); +int im_ismonotonic( IMAGE *lut, int *out ); +int im_tone_map( IMAGE *in, IMAGE *out, IMAGE *lut ); +int im_project( IMAGE *in, IMAGE *hout, IMAGE *vout ); +int im_mpercent( IMAGE *, double, int * ); + +#ifdef __cplusplus +} +#endif /*__cplusplus*/ + +#endif /*IM_HIST_H*/ diff --git a/libvips/include/vips/mask.h b/libvips/include/vips/mask.h index 1d194954..40f7c844 100644 --- a/libvips/include/vips/mask.h +++ b/libvips/include/vips/mask.h @@ -1,4 +1,4 @@ -/* convolution.h +/* mask.h * * 20/9/09 * - from proto.h @@ -37,6 +37,8 @@ extern "C" { #endif /*__cplusplus*/ +int poop( int poop ); + typedef struct im__INTMASK { int xsize; int ysize; @@ -44,7 +46,7 @@ typedef struct im__INTMASK { int offset; int *coeff; char *filename; -} INTMASK ; +} INTMASK; typedef struct im__DOUBLEMASK { int xsize; @@ -53,7 +55,7 @@ typedef struct im__DOUBLEMASK { double offset; double *coeff; char *filename; -} DOUBLEMASK ; +} DOUBLEMASK; void im_copy_dmask_matrix( DOUBLEMASK *mask, double **matrix ); void im_copy_matrix_dmask( double **matrix, DOUBLEMASK *mask ); @@ -95,6 +97,31 @@ INTMASK *im_rotate_imask45( INTMASK *m, const char *name ); DOUBLEMASK *im_rotate_dmask90( DOUBLEMASK *m, const char *name ); DOUBLEMASK *im_rotate_dmask45( DOUBLEMASK *m, const char *name ); +DOUBLEMASK *im_mattrn( DOUBLEMASK *, const char * ); +DOUBLEMASK *im_matcat( DOUBLEMASK *, DOUBLEMASK *, const char * ); +DOUBLEMASK *im_matmul( DOUBLEMASK *, DOUBLEMASK *, const char * ); + +DOUBLEMASK *im_lu_decomp( const DOUBLEMASK *mat, const char *name ); +int im_lu_solve( const DOUBLEMASK *lu, double *vec ); +DOUBLEMASK *im_matinv( const DOUBLEMASK *mat, const char *name ); +int im_matinv_inplace( DOUBLEMASK *mat ); + +int *im_ivector(); +float *im_fvector(); +double *im_dvector(); +void im_free_ivector(); +void im_free_fvector(); +void im_free_dvector(); + +int **im_imat_alloc(); +float **im_fmat_alloc(); +double **im_dmat_alloc(); +void im_free_imat(); +void im_free_fmat(); +void im_free_dmat(); + +int im_invmat( double **, int ); + #ifdef __cplusplus } #endif /*__cplusplus*/ diff --git a/libvips/include/vips/morphology.h b/libvips/include/vips/morphology.h new file mode 100644 index 00000000..f0069fb2 --- /dev/null +++ b/libvips/include/vips/morphology.h @@ -0,0 +1,59 @@ +/* convolution.h + * + * 20/9/09 + * - from proto.h + */ + +/* + + This file is part of VIPS. + + VIPS is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +#ifndef IM_MORPHOLOGY_H +#define IM_MORPHOLOGY_H + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus*/ + +int im_dilate( IMAGE *in, IMAGE *out, INTMASK *m ); +int im_dilate_raw( IMAGE *in, IMAGE *out, INTMASK *m ); +int im_erode( IMAGE *in, IMAGE *out, INTMASK *m ); +int im_erode_raw( IMAGE *in, IMAGE *out, INTMASK *m ); + +int im_rank( IMAGE *in, IMAGE *out, int width, int height, int rank ); +int im_rank_raw( IMAGE *in, IMAGE *out, int xsize, int ysize, int n ); +int im_rank_image( IMAGE **in, IMAGE *out, int n, int index ); +int im_maxvalue( IMAGE **in, IMAGE *out, int n ); + +int im_cntlines( IMAGE *im, double *nolines, int flag ); +int im_zerox( IMAGE *, IMAGE *, int ); + +int im_profile( IMAGE *in, IMAGE *out, int dir ); + +#ifdef __cplusplus +} +#endif /*__cplusplus*/ + +#endif /*IM_MORPHOLOGY_H*/ diff --git a/libvips/include/vips/proto.h b/libvips/include/vips/proto.h index 34f1b5f1..0dd4ff70 100644 --- a/libvips/include/vips/proto.h +++ b/libvips/include/vips/proto.h @@ -64,25 +64,6 @@ extern "C" { # endif #endif /*SWIG*/ -/* morphology - */ -int im_dilate( IMAGE *in, IMAGE *out, INTMASK *m ); -int im_dilate_raw( IMAGE *in, IMAGE *out, INTMASK *m ); -int im_erode( IMAGE *in, IMAGE *out, INTMASK *m ); -int im_erode_raw( IMAGE *in, IMAGE *out, INTMASK *m ); -int im_cntlines( IMAGE *im, double *nolines, int flag ); -int im_profile( IMAGE *in, IMAGE *out, int dir ); - -/* freq_filt - */ -int im_fractsurf( IMAGE *out, int size, double frd ); -int im_freqflt( IMAGE *, IMAGE *, IMAGE * ); -int im_disp_ps( IMAGE *, IMAGE * ); -int im_rotquad( IMAGE *, IMAGE * ); -int im_fwfft( IMAGE *, IMAGE * ); -int im_invfft( IMAGE *, IMAGE * ); -int im_invfftr( IMAGE *, IMAGE * ); - /* cimg */ int im_greyc_mask( IMAGE *in, IMAGE *out, IMAGE *mask, @@ -90,44 +71,6 @@ int im_greyc_mask( IMAGE *in, IMAGE *out, IMAGE *mask, float alpha, float sigma, float dl, float da, float gauss_prec, int interpolation, int fast_approx ); -/* histogram - */ -int im_maplut( IMAGE *, IMAGE *, IMAGE * ); -int im_gammacorrect( IMAGE *, IMAGE *, double ); -int im_heq( IMAGE *in, IMAGE *out, int bandno ); -int im_hist( IMAGE *in, IMAGE *out, int bandno ); -int im_hist_indexed( IMAGE *index, IMAGE *value, IMAGE *out ); -int im_histeq( IMAGE *in, IMAGE *out ); -int im_histnorm( IMAGE *in, IMAGE *out ); -int im_histcum( IMAGE *in, IMAGE *out ); -int im_histgr( IMAGE *in, IMAGE *out, int bandno ); -int im_histnD( IMAGE *in, IMAGE *out, int bins ); -int im_histplot( IMAGE *hist, IMAGE *histplot ); -int im_histspec( IMAGE *hin, IMAGE *href, IMAGE *lut ); -int im_hsp( IMAGE *in, IMAGE *ref, IMAGE *out ); -int im_identity( IMAGE *lut, int bands ); -int im_identity_ushort( IMAGE *lut, int bands, int sz ); -int im_lhisteq( IMAGE *in, IMAGE *out, int xwin, int ywin ); -int im_lhisteq_raw( IMAGE *in, IMAGE *out, int xwin, int ywin ); -int im_invertlut( DOUBLEMASK *input, IMAGE *output, int lut_size ); -int im_buildlut( DOUBLEMASK *input, IMAGE *output ); -int im_stdif( IMAGE *in, IMAGE *out, - double a, double m0, double b, double s0, int xwin, int ywin ); -int im_stdif_raw( IMAGE *in, IMAGE *out, - double a, double m0, double b, double s0, int xwin, int ywin ); -int im_tone_build_range( IMAGE *out, - int in_max, int out_max, - double Lb, double Lw, double Ps, double Pm, double Ph, - double S, double M, double H ); -int im_tone_build( IMAGE *out, - double Lb, double Lw, double Ps, double Pm, double Ph, - double S, double M, double H ); -int im_tone_analyse( IMAGE *in, IMAGE *lut, - double Ps, double Pm, double Ph, double S, double M, double H ); -int im_ismonotonic( IMAGE *lut, int *out ); -int im_tone_map( IMAGE *in, IMAGE *out, IMAGE *lut ); -int im_project( IMAGE *in, IMAGE *hout, IMAGE *vout ); - /* other */ int im_feye( IMAGE *image, @@ -161,8 +104,6 @@ int im_sines( IMAGE *image, int xsize, int ysize, double horfreq, double verfreq ); int im_spatres( IMAGE *in, IMAGE *out, int step ); -int im_rightshift_size( IMAGE *in, IMAGE *out, int xshift, int yshift, int band_fmt ); - /* mosaicing */ int im_lrmerge( IMAGE *ref, IMAGE *sec, IMAGE *out, @@ -210,20 +151,6 @@ int im_tbmosaic1( IMAGE *ref, IMAGE *sec, IMAGE *out, int im_global_balance( IMAGE *in, IMAGE *out, double gamma ); int im_global_balancef( IMAGE *in, IMAGE *out, double gamma ); -int im_match_linear( IMAGE *ref, IMAGE *sec, IMAGE *out, - int xr1, int yr1, int xs1, int ys1, - int xr2, int yr2, int xs2, int ys2 ); -int im_match_linear_search( IMAGE *ref, IMAGE *sec, IMAGE *out, - int xr1, int yr1, int xs1, int ys1, - int xr2, int yr2, int xs2, int ys2, - int hwindowsize, int hsearchsize ); - -int im_affinei( IMAGE *in, IMAGE *out, - VipsInterpolate *interpolate, - double a, double b, double c, double d, double dx, double dy, - int ox, int oy, int ow, int oh ); -int im_affinei_all( IMAGE *in, IMAGE *out, VipsInterpolate *interpolate, - double a, double b, double c, double d, double dx, double dy ) ; int im_correl( IMAGE *ref, IMAGE *sec, int xref, int yref, int xsec, int ysec, int hwindowsize, int hsearchsize, @@ -255,34 +182,6 @@ int im_segment( IMAGE *test, IMAGE *mask, int *segments ); int im_lineset( IMAGE *in, IMAGE *out, IMAGE *mask, IMAGE *ink, int n, int *x1v, int *y1v, int *x2v, int *y2v ); -/* matrix - */ -DOUBLEMASK *im_mattrn( DOUBLEMASK *, const char * ); -DOUBLEMASK *im_matcat( DOUBLEMASK *, DOUBLEMASK *, const char * ); -DOUBLEMASK *im_matmul( DOUBLEMASK *, DOUBLEMASK *, const char * ); - -DOUBLEMASK *im_lu_decomp( const DOUBLEMASK *mat, const char *name ); -int im_lu_solve( const DOUBLEMASK *lu, double *vec ); -DOUBLEMASK *im_matinv( const DOUBLEMASK *mat, const char *name ); -int im_matinv_inplace( DOUBLEMASK *mat ); - - -int *im_ivector(); -float *im_fvector(); -double *im_dvector(); -void im_free_ivector(); -void im_free_fvector(); -void im_free_dvector(); - -int **im_imat_alloc(); -float **im_fmat_alloc(); -double **im_dmat_alloc(); -void im_free_imat(); -void im_free_fmat(); -void im_free_dmat(); - -int im_invmat( double **, int ); - /* video */ int im_video_v4l1( IMAGE *im, const char *device, diff --git a/libvips/include/vips/resample.h b/libvips/include/vips/resample.h new file mode 100644 index 00000000..ee3e61da --- /dev/null +++ b/libvips/include/vips/resample.h @@ -0,0 +1,65 @@ +/* resample.h + * + * 20/9/09 + * - from proto.h + */ + +/* + + This file is part of VIPS. + + VIPS is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +#ifndef IM_RESAMPLE_H +#define IM_RESAMPLE_H + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus*/ + +int im_match_linear( IMAGE *ref, IMAGE *sec, IMAGE *out, + int xr1, int yr1, int xs1, int ys1, + int xr2, int yr2, int xs2, int ys2 ); +int im_match_linear_search( IMAGE *ref, IMAGE *sec, IMAGE *out, + int xr1, int yr1, int xs1, int ys1, + int xr2, int yr2, int xs2, int ys2, + int hwindowsize, int hsearchsize ); + +int im_affinei( IMAGE *in, IMAGE *out, + VipsInterpolate *interpolate, + double a, double b, double c, double d, double dx, double dy, + int ox, int oy, int ow, int oh ); +int im_affinei_all( IMAGE *in, IMAGE *out, VipsInterpolate *interpolate, + double a, double b, double c, double d, double dx, double dy ) ; + +int im_resize_linear( IMAGE *, IMAGE *, int, int ); +int im_stretch3( IMAGE *in, IMAGE *out, double dx, double dy ); +int im_shrink( IMAGE *, IMAGE *, double, double ); + +int im_rightshift_size( IMAGE *in, IMAGE *out, int xshift, int yshift, int band_fmt ); + +#ifdef __cplusplus +} +#endif /*__cplusplus*/ + +#endif /*IM_RESAMPLE_H*/ diff --git a/libvips/include/vips/vips.h b/libvips/include/vips/vips.h index 59d5ef6b..168ab2de 100644 --- a/libvips/include/vips/vips.h +++ b/libvips/include/vips/vips.h @@ -81,14 +81,6 @@ extern "C" { #endif /*__cplusplus*/ -/* If we're not using GNU C, elide __attribute__ - */ -#ifndef __GNUC__ -# ifndef __attribute__ -# define __attribute__(x) /*NOTHING*/ -# endif -#endif - #include #include #include @@ -126,6 +118,10 @@ extern "C" { #include #include #include +#include +#include +#include +#include #include #include diff --git a/libvips/iofuncs/package.c b/libvips/iofuncs/package.c index 1cb027dc..185dc787 100644 --- a/libvips/iofuncs/package.c +++ b/libvips/iofuncs/package.c @@ -71,7 +71,7 @@ extern im_package im__format; extern im_package im__freq_filt; extern im_package im__histograms_lut; extern im_package im__inplace; -extern im_package im__matrix; +extern im_package im__mask; extern im_package im__morphology; extern im_package im__mosaicing; extern im_package im__other; @@ -457,7 +457,7 @@ static im_package *built_in[] = { &im__histograms_lut, &im__inplace, &im__iofuncs, - &im__matrix, + &im__mask, &im__morphology, &im__mosaicing, &im__other, diff --git a/libvips/matrix/Makefile.am b/libvips/mask/Makefile.am similarity index 52% rename from libvips/matrix/Makefile.am rename to libvips/mask/Makefile.am index 6fb5d15e..d38e4dfa 100644 --- a/libvips/matrix/Makefile.am +++ b/libvips/mask/Makefile.am @@ -1,11 +1,15 @@ -noinst_LTLIBRARIES = libmatrix.la +noinst_LTLIBRARIES = libmask.la -libmatrix_la_SOURCES = \ +libmask_la_SOURCES = \ + rotmask.c \ + im_gaussmasks.c \ + im_logmasks.c \ + rw_mask.c \ im_matcat.c \ im_matinv.c \ im_matmul.c \ im_mattrn.c \ matalloc.c \ - matrix_dispatch.c + mask_dispatch.c INCLUDES = -I${top_srcdir}/libvips/include @VIPS_CFLAGS@ @VIPS_INCLUDES@ diff --git a/libvips/convolution/im_gaussmasks.c b/libvips/mask/im_gaussmasks.c similarity index 100% rename from libvips/convolution/im_gaussmasks.c rename to libvips/mask/im_gaussmasks.c diff --git a/libvips/convolution/im_logmasks.c b/libvips/mask/im_logmasks.c similarity index 100% rename from libvips/convolution/im_logmasks.c rename to libvips/mask/im_logmasks.c diff --git a/libvips/matrix/im_matcat.c b/libvips/mask/im_matcat.c similarity index 100% rename from libvips/matrix/im_matcat.c rename to libvips/mask/im_matcat.c diff --git a/libvips/matrix/im_matinv.c b/libvips/mask/im_matinv.c similarity index 100% rename from libvips/matrix/im_matinv.c rename to libvips/mask/im_matinv.c diff --git a/libvips/matrix/im_matmul.c b/libvips/mask/im_matmul.c similarity index 100% rename from libvips/matrix/im_matmul.c rename to libvips/mask/im_matmul.c diff --git a/libvips/matrix/im_mattrn.c b/libvips/mask/im_mattrn.c similarity index 100% rename from libvips/matrix/im_mattrn.c rename to libvips/mask/im_mattrn.c diff --git a/libvips/mask/mask_dispatch.c b/libvips/mask/mask_dispatch.c new file mode 100644 index 00000000..ea011e7a --- /dev/null +++ b/libvips/mask/mask_dispatch.c @@ -0,0 +1,577 @@ +/* VIPS function dispatch tables for matricies. + * + * J. Cupitt, 14/2/95. + */ + +/* + + This file is part of VIPS. + + VIPS is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + */ + +/* + + These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk + + */ + +#ifdef HAVE_CONFIG_H +#include +#endif /*HAVE_CONFIG_H*/ +#include + +#include + +#include + +#ifdef WITH_DMALLOC +#include +#endif /*WITH_DMALLOC*/ + +/* One matrix in, one out. + */ +static im_arg_desc one_in_one_out[] = { + IM_INPUT_DMASK( "in" ), + IM_OUTPUT_DMASK( "out" ) +}; + +/* Two matricies in, one out. + */ +static im_arg_desc two_in_one_out[] = { + IM_INPUT_DMASK( "in1" ), + IM_INPUT_DMASK( "in2" ), + IM_OUTPUT_DMASK( "out" ) +}; + +/* Call im_matinv via arg vector. + */ +static int +matinv_vec( im_object *argv ) +{ + im_mask_object *in = argv[0]; + im_mask_object *out = argv[1]; + + if( !(out->mask = + im_matinv( in->mask, out->name )) ) + return( -1 ); + + return( 0 ); +} + +/* Description of im_matinv. + */ +static im_function matinv_desc = { + "im_matinv", /* Name */ + "invert matrix", + 0, /* Flags */ + matinv_vec, /* Dispatch function */ + IM_NUMBER( one_in_one_out ), /* Size of arg list */ + one_in_one_out /* Arg list */ +}; + +/* Call im_mattrn via arg vector. + */ +static int +mattrn_vec( im_object *argv ) +{ + im_mask_object *in = argv[0]; + im_mask_object *out = argv[1]; + + if( !(out->mask = + im_mattrn( in->mask, out->name )) ) + return( -1 ); + + return( 0 ); +} + +/* Description of im_mattrn. + */ +static im_function mattrn_desc = { + "im_mattrn", /* Name */ + "transpose matrix", + 0, /* Flags */ + mattrn_vec, /* Dispatch function */ + IM_NUMBER( one_in_one_out ), /* Size of arg list */ + one_in_one_out /* Arg list */ +}; + +/* Call im_matcat via arg vector. + */ +static int +matcat_vec( im_object *argv ) +{ + im_mask_object *in1 = argv[0]; + im_mask_object *in2 = argv[1]; + im_mask_object *out = argv[2]; + + if( !(out->mask = + im_matcat( in1->mask, in2->mask, out->name )) ) + return( -1 ); + + return( 0 ); +} + +/* Description of im_matcat. + */ +static im_function matcat_desc = { + "im_matcat", /* Name */ + "append matrix in2 to the end of matrix in1", + 0, /* Flags */ + matcat_vec, /* Dispatch function */ + IM_NUMBER( two_in_one_out ), /* Size of arg list */ + two_in_one_out /* Arg list */ +}; + +/* Call im_matmul via arg vector. + */ +static int +matmul_vec( im_object *argv ) +{ + im_mask_object *in1 = argv[0]; + im_mask_object *in2 = argv[1]; + im_mask_object *out = argv[2]; + + if( !(out->mask = + im_matmul( in1->mask, in2->mask, out->name )) ) + return( -1 ); + + return( 0 ); +} + +/* Description of im_matmul. + */ +static im_function matmul_desc = { + "im_matmul", /* Name */ + "multiply matrix in1 by matrix in2", + 0, /* Flags */ + matmul_vec, /* Dispatch function */ + IM_NUMBER( two_in_one_out ), /* Size of arg list */ + two_in_one_out /* Arg list */ +}; + +/* Args for im_read_dmask() + */ +static im_arg_desc read_dmask_args[] = { + IM_INPUT_STRING( "filename" ), + IM_OUTPUT_DMASK( "mask" ) +}; + +/* Call im_read_dmask via arg vector. + */ +static int +read_dmask_vec( im_object *argv ) +{ + im_mask_object *mo = argv[1]; + + if( !(mo->mask = im_read_dmask( argv[0] )) ) + return( -1 ); + + return( 0 ); +} + +/* Description of im_read_dmask(). + */ +static im_function read_dmask_desc = { + "im_read_dmask", /* Name */ + "read matrix of double from file", + 0, /* Flags */ + read_dmask_vec, /* Dispatch function */ + IM_NUMBER( read_dmask_args ), /* Size of arg list */ + read_dmask_args /* Arg list */ +}; + +/* Args for im_gauss_dmask. + */ +static im_arg_desc gauss_dmask_args[] = { + IM_OUTPUT_DMASK( "mask" ), + IM_INPUT_DOUBLE( "sigma" ), + IM_INPUT_DOUBLE( "min_amp" ) +}; + +/* Call im_gauss_dmask via arg vector. + */ +static int +gauss_dmask_vec( im_object *argv ) +{ + im_mask_object *mo = argv[0]; + double sigma = *((double *) argv[1]); + double min_amp = *((double *) argv[2]); + + if( !(mo->mask = + im_gauss_dmask( mo->name, sigma, min_amp )) ) + return( -1 ); + + return( 0 ); +} + +/* Description of im_gauss_dmask. + */ +static im_function gauss_dmask_desc = { + "im_gauss_dmask", /* Name */ + "generate gaussian DOUBLEMASK", + 0, /* Flags */ + gauss_dmask_vec, /* Dispatch function */ + IM_NUMBER( gauss_dmask_args ), /* Size of arg list */ + gauss_dmask_args /* Arg list */ +}; + +/* Args for im_gauss_imask. + */ +static im_arg_desc gauss_imask_args[] = { + IM_OUTPUT_IMASK( "mask" ), + IM_INPUT_DOUBLE( "sigma" ), + IM_INPUT_DOUBLE( "min_amp" ) +}; + +/* Call im_gauss_imask via arg vector. + */ +static int +gauss_imask_vec( im_object *argv ) +{ + im_mask_object *mo = argv[0]; + double sigma = *((double *) argv[1]); + double min_amp = *((double *) argv[2]); + + if( !(mo->mask = + im_gauss_imask( mo->name, sigma, min_amp )) ) + return( -1 ); + + return( 0 ); +} + +/* Description of im_gauss_imask. + */ +static im_function gauss_imask_desc = { + "im_gauss_imask", /* Name */ + "generate gaussian INTMASK", + 0, /* Flags */ + gauss_imask_vec, /* Dispatch function */ + IM_NUMBER( gauss_imask_args ), /* Size of arg list */ + gauss_imask_args /* Arg list */ +}; + +/* Call im_gauss_imask_sep via arg vector. + */ +static int +gauss_imask_sep_vec( im_object *argv ) +{ + im_mask_object *mo = argv[0]; + double sigma = *((double *) argv[1]); + double min_amp = *((double *) argv[2]); + + if( !(mo->mask = + im_gauss_imask_sep( mo->name, sigma, min_amp )) ) + return( -1 ); + + return( 0 ); +} + +/* Description of im_gauss_imask_sep. + */ +static im_function gauss_imask_sep_desc = { + "im_gauss_imask_sep", /* Name */ + "generate separable gaussian INTMASK", + 0, /* Flags */ + gauss_imask_sep_vec, /* Dispatch function */ + IM_NUMBER( gauss_imask_args ), /* Size of arg list */ + gauss_imask_args /* Arg list */ +}; + +/* Args for im_log_imask. + */ +static im_arg_desc log_imask_args[] = { + IM_OUTPUT_IMASK( "mask" ), + IM_INPUT_DOUBLE( "sigma" ), + IM_INPUT_DOUBLE( "min_amp" ) +}; + +/* Call im_log_imask via arg vector. + */ +static int +log_imask_vec( im_object *argv ) +{ + im_mask_object *mo = argv[0]; + double sigma = *((double *) argv[1]); + double min_amp = *((double *) argv[2]); + + if( !(mo->mask = + im_log_imask( mo->name, sigma, min_amp )) ) + return( -1 ); + + return( 0 ); +} + +/* Description of im_log_imask. + */ +static im_function log_imask_desc = { + "im_log_imask", /* Name */ + "generate laplacian of gaussian INTMASK", + 0, /* Flags */ + log_imask_vec, /* Dispatch function */ + IM_NUMBER( log_imask_args ), /* Size of arg list */ + log_imask_args /* Arg list */ +}; + +/* Args for im_log_dmask. + */ +static im_arg_desc log_dmask_args[] = { + IM_OUTPUT_DMASK( "maskfile" ), + IM_INPUT_DOUBLE( "sigma" ), + IM_INPUT_DOUBLE( "min_amp" ) +}; + +/* Call im_log_dmask via arg vector. + */ +static int +log_dmask_vec( im_object *argv ) +{ + im_mask_object *mo = argv[0]; + double sigma = *((double *) argv[1]); + double min_amp = *((double *) argv[2]); + + if( !(mo->mask = + im_log_dmask( mo->name, sigma, min_amp )) ) + return( -1 ); + + return( 0 ); +} + +/* Description of im_log_dmask. + */ +static im_function log_dmask_desc = { + "im_log_dmask", /* Name */ + "generate laplacian of gaussian DOUBLEMASK", + 0, /* Flags */ + log_dmask_vec, /* Dispatch function */ + IM_NUMBER( log_dmask_args ), /* Size of arg list */ + log_dmask_args /* Arg list */ +}; + +static im_arg_desc imask_args[] = { + IM_INPUT_IMASK( "in" ), + IM_OUTPUT_IMASK( "out" ) +}; + +static im_arg_desc dmask_args[] = { + IM_INPUT_DMASK( "in" ), + IM_OUTPUT_DMASK( "out" ) +}; + +/* Call im_rotate_imask45 via arg vector. + */ +static int +rotate_imask45_vec( im_object *argv ) +{ + im_mask_object *min = argv[0]; + im_mask_object *mout = argv[1]; + + if( !(mout->mask = im_rotate_imask45( min->mask, mout->name )) ) + return( -1 ); + + return( 0 ); +} + +/* Description of im_rotate_imask45. + */ +static im_function rotate_imask45_desc = { + "im_rotate_imask45", /* Name */ + "rotate INTMASK clockwise by 45 degrees", + 0, /* Flags */ + rotate_imask45_vec, /* Dispatch function */ + IM_NUMBER( imask_args ), /* Size of arg list */ + imask_args /* Arg list */ +}; + +/* Call im_rotate_imask90 via arg vector. + */ +static int +rotate_imask90_vec( im_object *argv ) +{ + im_mask_object *min = argv[0]; + im_mask_object *mout = argv[1]; + + if( !(mout->mask = im_rotate_imask90( min->mask, mout->name )) ) + return( -1 ); + + return( 0 ); +} + +/* Description of im_rotate_imask90. + */ +static im_function rotate_imask90_desc = { + "im_rotate_imask90", /* Name */ + "rotate INTMASK clockwise by 90 degrees", + 0, /* Flags */ + rotate_imask90_vec, /* Dispatch function */ + IM_NUMBER( imask_args ), /* Size of arg list */ + imask_args /* Arg list */ +}; + +/* Call im_rotate_dmask45 via arg vector. + */ +static int +rotate_dmask45_vec( im_object *argv ) +{ + im_mask_object *min = argv[0]; + im_mask_object *mout = argv[1]; + + if( !(mout->mask = im_rotate_dmask45( min->mask, mout->name )) ) + return( -1 ); + + return( 0 ); +} + +/* Description of im_rotate_dmask45. + */ +static im_function rotate_dmask45_desc = { + "im_rotate_dmask45", /* Name */ + "rotate DOUBLEMASK clockwise by 45 degrees", + 0, /* Flags */ + rotate_dmask45_vec, /* Dispatch function */ + IM_NUMBER( dmask_args ), /* Size of arg list */ + dmask_args /* Arg list */ +}; + +/* Call im_rotate_dmask90 via arg vector. + */ +static int +rotate_dmask90_vec( im_object *argv ) +{ + im_mask_object *min = argv[0]; + im_mask_object *mout = argv[1]; + + if( !(mout->mask = im_rotate_dmask90( min->mask, mout->name )) ) + return( -1 ); + + return( 0 ); +} + +/* Description of im_rotate_dmask90. + */ +static im_function rotate_dmask90_desc = { + "im_rotate_dmask90", /* Name */ + "rotate DOUBLEMASK clockwise by 90 degrees", + 0, /* Flags */ + rotate_dmask90_vec, /* Dispatch function */ + IM_NUMBER( dmask_args ), /* Size of arg list */ + dmask_args /* Arg list */ +}; + +static int +imask_xsize_vec( im_object *argv ) +{ + *( (int*) argv[1] )= ( (INTMASK*) ( ( (im_mask_object*) argv[0] )-> mask ) )-> xsize; + return 0; +} + +static int +imask_ysize_vec( im_object *argv ) +{ + *( (int*) argv[1] )= ( (INTMASK*) ( ( (im_mask_object*) argv[0] )-> mask ) )-> ysize; + return 0; +} + +static int +dmask_xsize_vec( im_object *argv ) +{ + *( (int*) argv[1] )= ( (DOUBLEMASK*) ( ( (im_mask_object*) argv[0] )-> mask ) )-> xsize; + return 0; +} + +static int +dmask_ysize_vec( im_object *argv ) +{ + *( (int*) argv[1] )= ( (DOUBLEMASK*) ( ( (im_mask_object*) argv[0] )-> mask ) )-> ysize; + return 0; +} + +static im_arg_desc imask_size_args[] = { + IM_INPUT_IMASK( "mask" ), + IM_OUTPUT_INT( "size" ) +}; + +static im_arg_desc dmask_size_args[] = { + IM_INPUT_DMASK( "mask" ), + IM_OUTPUT_INT( "size" ) +}; + +static im_function imask_xsize_desc = { + "im_imask_xsize", /* Name */ + "horizontal size of an intmask", /* Description */ + 0, /* Flags */ + imask_xsize_vec, /* Dispatch function */ + IM_NUMBER( imask_size_args ), /* Size of arg list */ + imask_size_args /* Arg list */ +}; + +static im_function imask_ysize_desc = { + "im_imask_ysize", /* Name */ + "vertical size of an intmask", /* Description */ + 0, /* Flags */ + imask_ysize_vec, /* Dispatch function */ + IM_NUMBER( imask_size_args ), /* Size of arg list */ + imask_size_args /* Arg list */ +}; + +static im_function dmask_xsize_desc = { + "im_dmask_xsize", /* Name */ + "horizontal size of a doublemask", /* Description */ + 0, /* Flags */ + dmask_xsize_vec, /* Dispatch function */ + IM_NUMBER( dmask_size_args ), /* Size of arg list */ + dmask_size_args /* Arg list */ +}; + +static im_function dmask_ysize_desc = { + "im_dmask_ysize", /* Name */ + "vertical size of a doublemask", /* Description */ + 0, /* Flags */ + dmask_ysize_vec, /* Dispatch function */ + IM_NUMBER( dmask_size_args ), /* Size of arg list */ + dmask_size_args /* Arg list */ +}; + +/* Package up all these functions. + */ +static im_function *mask_list[] = { + &gauss_dmask_desc, + &log_dmask_desc, + &log_imask_desc, + &gauss_imask_desc, + &gauss_imask_sep_desc, + &dmask_xsize_desc, + &dmask_ysize_desc, + &imask_xsize_desc, + &imask_ysize_desc, + &read_dmask_desc, + &rotate_dmask45_desc, + &rotate_dmask90_desc, + &rotate_imask45_desc, + &rotate_imask90_desc, + &matcat_desc, + &matinv_desc, + &matmul_desc, + &mattrn_desc +}; + +/* Package of functions. + */ +im_package im__mask = { + "mask", + IM_NUMBER( mask_list ), + mask_list +}; diff --git a/libvips/matrix/matalloc.c b/libvips/mask/matalloc.c similarity index 100% rename from libvips/matrix/matalloc.c rename to libvips/mask/matalloc.c diff --git a/libvips/convolution/rotmask.c b/libvips/mask/rotmask.c similarity index 100% rename from libvips/convolution/rotmask.c rename to libvips/mask/rotmask.c diff --git a/libvips/convolution/rw_mask.c b/libvips/mask/rw_mask.c similarity index 100% rename from libvips/convolution/rw_mask.c rename to libvips/mask/rw_mask.c diff --git a/libvips/matrix/matrix_dispatch.c b/libvips/matrix/matrix_dispatch.c deleted file mode 100644 index e6608fda..00000000 --- a/libvips/matrix/matrix_dispatch.c +++ /dev/null @@ -1,181 +0,0 @@ -/* VIPS function dispatch tables for matricies. - * - * J. Cupitt, 14/2/95. - */ - -/* - - This file is part of VIPS. - - VIPS is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - */ - -/* - - These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk - - */ - -#ifdef HAVE_CONFIG_H -#include -#endif /*HAVE_CONFIG_H*/ -#include - -#include - -#include - -#ifdef WITH_DMALLOC -#include -#endif /*WITH_DMALLOC*/ - -/* One matrix in, one out. - */ -static im_arg_desc one_in_one_out[] = { - IM_INPUT_DMASK( "in" ), - IM_OUTPUT_DMASK( "out" ) -}; - -/* Two matricies in, one out. - */ -static im_arg_desc two_in_one_out[] = { - IM_INPUT_DMASK( "in1" ), - IM_INPUT_DMASK( "in2" ), - IM_OUTPUT_DMASK( "out" ) -}; - -/* Call im_matinv via arg vector. - */ -static int -matinv_vec( im_object *argv ) -{ - im_mask_object *in = argv[0]; - im_mask_object *out = argv[1]; - - if( !(out->mask = - im_matinv( in->mask, out->name )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_matinv. - */ -static im_function matinv_desc = { - "im_matinv", /* Name */ - "invert matrix", - 0, /* Flags */ - matinv_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_mattrn via arg vector. - */ -static int -mattrn_vec( im_object *argv ) -{ - im_mask_object *in = argv[0]; - im_mask_object *out = argv[1]; - - if( !(out->mask = - im_mattrn( in->mask, out->name )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_mattrn. - */ -static im_function mattrn_desc = { - "im_mattrn", /* Name */ - "transpose matrix", - 0, /* Flags */ - mattrn_vec, /* Dispatch function */ - IM_NUMBER( one_in_one_out ), /* Size of arg list */ - one_in_one_out /* Arg list */ -}; - -/* Call im_matcat via arg vector. - */ -static int -matcat_vec( im_object *argv ) -{ - im_mask_object *in1 = argv[0]; - im_mask_object *in2 = argv[1]; - im_mask_object *out = argv[2]; - - if( !(out->mask = - im_matcat( in1->mask, in2->mask, out->name )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_matcat. - */ -static im_function matcat_desc = { - "im_matcat", /* Name */ - "append matrix in2 to the end of matrix in1", - 0, /* Flags */ - matcat_vec, /* Dispatch function */ - IM_NUMBER( two_in_one_out ), /* Size of arg list */ - two_in_one_out /* Arg list */ -}; - -/* Call im_matmul via arg vector. - */ -static int -matmul_vec( im_object *argv ) -{ - im_mask_object *in1 = argv[0]; - im_mask_object *in2 = argv[1]; - im_mask_object *out = argv[2]; - - if( !(out->mask = - im_matmul( in1->mask, in2->mask, out->name )) ) - return( -1 ); - - return( 0 ); -} - -/* Description of im_matmul. - */ -static im_function matmul_desc = { - "im_matmul", /* Name */ - "multiply matrix in1 by matrix in2", - 0, /* Flags */ - matmul_vec, /* Dispatch function */ - IM_NUMBER( two_in_one_out ), /* Size of arg list */ - two_in_one_out /* Arg list */ -}; - -/* Package up all these functions. - */ -static im_function *matrix_list[] = { - &matcat_desc, - &matinv_desc, - &matmul_desc, - &mattrn_desc -}; - -/* Package of functions. - */ -im_package im__matrix = { - "matrix", - IM_NUMBER( matrix_list ), - matrix_list -}; diff --git a/libvips/morphology/Makefile.am b/libvips/morphology/Makefile.am index f4e1d03a..c57a9dd1 100644 --- a/libvips/morphology/Makefile.am +++ b/libvips/morphology/Makefile.am @@ -4,6 +4,9 @@ libmorphology_la_SOURCES = \ im_cntlines.c \ im_dilate.c\ im_erode.c\ + im_rank.c \ + im_rank_image.c \ + im_zerox.c \ morph_dispatch.c \ im_profile.c diff --git a/libvips/convolution/im_rank.c b/libvips/morphology/im_rank.c similarity index 100% rename from libvips/convolution/im_rank.c rename to libvips/morphology/im_rank.c diff --git a/libvips/convolution/im_rank_image.c b/libvips/morphology/im_rank_image.c similarity index 100% rename from libvips/convolution/im_rank_image.c rename to libvips/morphology/im_rank_image.c diff --git a/libvips/convolution/im_zerox.c b/libvips/morphology/im_zerox.c similarity index 100% rename from libvips/convolution/im_zerox.c rename to libvips/morphology/im_zerox.c diff --git a/libvips/morphology/morph_dispatch.c b/libvips/morphology/morph_dispatch.c index 86d1e5b4..8d3281ea 100644 --- a/libvips/morphology/morph_dispatch.c +++ b/libvips/morphology/morph_dispatch.c @@ -193,11 +193,147 @@ static im_function cntlines_desc = { cntlines_args /* Arg list */ }; +/* Args to im_rank. + */ +static im_arg_desc rank_args[] = { + IM_INPUT_IMAGE( "in" ), + IM_OUTPUT_IMAGE( "out" ), + IM_INPUT_INT( "xsize" ), + IM_INPUT_INT( "ysize" ), + IM_INPUT_INT( "n" ) +}; + +/* Call im_rank via arg vector. + */ +static int +rank_vec( im_object *argv ) +{ + int xsize = *((int *) argv[2]); + int ysize = *((int *) argv[3]); + int n = *((int *) argv[4]); + + return( im_rank( argv[0], argv[1], xsize, ysize, n ) ); +} + +/* Description of im_rank. + */ +static im_function rank_desc = { + "im_rank", /* Name */ + "rank filter nth element of xsize/ysize window", + IM_FN_PIO, /* Flags */ + rank_vec, /* Dispatch function */ + IM_NUMBER( rank_args ), /* Size of arg list */ + rank_args /* Arg list */ +}; + +/* Args for im_zerox. + */ +static im_arg_desc zerox_args[] = { + IM_INPUT_IMAGE( "in" ), + IM_OUTPUT_IMAGE( "out" ), + IM_INPUT_INT( "flag" ) +}; + +/* Call im_zerox via arg vector. + */ +static int +zerox_vec( im_object *argv ) +{ + int flag = *((int *) argv[2]); + + return( im_zerox( argv[0], argv[1], flag ) ); +} + +/* Description of im_zerox. + */ +static im_function zerox_desc = { + "im_zerox", /* Name */ + "find +ve or -ve zero crossings in image", + IM_FN_PIO | IM_FN_TRANSFORM, /* Flags */ + zerox_vec, /* Dispatch function */ + IM_NUMBER( zerox_args ), /* Size of arg list */ + zerox_args /* Arg list */ +}; + +static im_arg_desc maxvalue_args[] = { + IM_INPUT_IMAGEVEC( "in" ), + IM_OUTPUT_IMAGE( "out" ) +}; + +static int +maxvalue_vec( im_object *argv ) +{ + im_imagevec_object *iv = (im_imagevec_object *) argv[0]; + + return( im_maxvalue( iv->vec, argv[1], iv->n ) ); +} + +static im_function maxvalue_desc = { + "im_maxvalue", /* Name */ + "point-wise maximum value", /* Description */ + IM_FN_PIO, /* Flags */ + maxvalue_vec, /* Dispatch function */ + IM_NUMBER( maxvalue_args ), /* Size of arg list */ + maxvalue_args /* Arg list */ +}; + +static im_arg_desc rank_image_args[] = { + IM_INPUT_IMAGEVEC( "in" ), + IM_OUTPUT_IMAGE( "out" ), + IM_INPUT_INT( "index" ) +}; + +static int +rank_image_vec( im_object *argv ) +{ + im_imagevec_object *iv = (im_imagevec_object *) argv[0]; + int index = *((int *) argv[2]); + + return( im_rank_image( iv->vec, argv[1], iv->n, index ) ); +} + +static im_function rank_image_desc = { + "im_rank_image", /* Name */ + "point-wise pixel rank", /* Description */ + IM_FN_PIO, /* Flags */ + rank_image_vec, /* Dispatch function */ + IM_NUMBER( rank_image_args ), /* Size of arg list */ + rank_image_args /* Arg list */ +}; + +/* Call im_rank_raw via arg vector. + */ +static int +rank_raw_vec( im_object *argv ) +{ + int xsize = *((int *) argv[2]); + int ysize = *((int *) argv[3]); + int n = *((int *) argv[4]); + + return( im_rank_raw( argv[0], argv[1], xsize, ysize, n ) ); +} + +/* Description of im_rank_raw. + */ +static im_function rank_raw_desc = { + "im_rank_raw", /* Name */ + "rank filter nth element of xsize/ysize window, no border", + IM_FN_PIO, /* Flags */ + rank_raw_vec, /* Dispatch function */ + IM_NUMBER( rank_args ), /* Size of arg list */ + rank_args /* Arg list */ +}; + /* Package up all these functions. */ static im_function *morph_list[] = { &cntlines_desc, &dilate_desc, + &rank_desc, + &rank_image_desc, + &maxvalue_desc, + &zerox_desc, + &rank_raw_desc, &dilate_raw_desc, &erode_desc, &erode_raw_desc, diff --git a/libvips/resample/Makefile.am b/libvips/resample/Makefile.am index 3190354e..e284ecbd 100644 --- a/libvips/resample/Makefile.am +++ b/libvips/resample/Makefile.am @@ -5,6 +5,9 @@ libresample_la_SOURCES = \ bicubic.cpp \ interpolate.c \ yafrsmooth.cpp \ + im_resize_linear.c \ + im_shrink.c \ + im_stretch3.c \ nohalo1.cpp \ snohalo1.cpp \ nohalo2.cpp \ diff --git a/libvips/convolution/im_resize_linear.c b/libvips/resample/im_resize_linear.c similarity index 100% rename from libvips/convolution/im_resize_linear.c rename to libvips/resample/im_resize_linear.c diff --git a/libvips/convolution/im_shrink.c b/libvips/resample/im_shrink.c similarity index 100% rename from libvips/convolution/im_shrink.c rename to libvips/resample/im_shrink.c diff --git a/libvips/convolution/im_stretch3.c b/libvips/resample/im_stretch3.c similarity index 100% rename from libvips/convolution/im_stretch3.c rename to libvips/resample/im_stretch3.c diff --git a/libvips/resample/resample_dispatch.c b/libvips/resample/resample_dispatch.c index 925d5a77..82132e2b 100644 --- a/libvips/resample/resample_dispatch.c +++ b/libvips/resample/resample_dispatch.c @@ -136,11 +136,107 @@ static im_function affinei_all_desc = { affinei_all_args /* Arg list */ }; +/* Args for im_shrink. + */ +static im_arg_desc shrink_args[] = { + IM_INPUT_IMAGE( "in" ), + IM_OUTPUT_IMAGE( "out" ), + IM_INPUT_DOUBLE( "xfac" ), + IM_INPUT_DOUBLE( "yfac" ) +}; + +/* Call im_shrink via arg vector. + */ +static int +shrink_vec( im_object *argv ) +{ + double xshrink = *((double *) argv[2]); + double yshrink = *((double *) argv[3]); + + return( im_shrink( argv[0], argv[1], xshrink, yshrink ) ); +} + +/* Description of im_shrink. + */ +static im_function shrink_desc = { + "im_shrink", /* Name */ + "shrink image by xfac, yfac times", + IM_FN_TRANSFORM | IM_FN_PIO, /* Flags */ + shrink_vec, /* Dispatch function */ + IM_NUMBER( shrink_args ), /* Size of arg list */ + shrink_args /* Arg list */ +}; + +/* Args for im_resize_linear. + */ +static im_arg_desc resize_linear_args[] = { + IM_INPUT_IMAGE( "in" ), + IM_OUTPUT_IMAGE( "out" ), + IM_INPUT_INT( "X" ), + IM_INPUT_INT( "Y" ) +}; + +/* Call im_resize_linear via arg vector. + */ +static int +resize_linear_vec( im_object *argv ) +{ + int X = *((int *) argv[2]); + int Y = *((int *) argv[3]); + + return( im_resize_linear( argv[0], argv[1], X, Y ) ); +} + +/* Description of im_resize_linear. + */ +static im_function resize_linear_desc = { + "im_resize_linear", /* Name */ + "resize to X by Y pixels with linear interpolation", + 0, /* Flags */ + resize_linear_vec, /* Dispatch function */ + IM_NUMBER( resize_linear_args ), /* Size of arg list */ + resize_linear_args /* Arg list */ +}; + +/* Args to im_stretch3. + */ +static im_arg_desc stretch3_args[] = { + IM_INPUT_IMAGE( "in" ), + IM_OUTPUT_IMAGE( "out" ), + IM_INPUT_DOUBLE( "xdisp" ), + IM_INPUT_DOUBLE( "ydisp" ) +}; + +/* Call im_stretch3 via arg vector. + */ +static int +stretch3_vec( im_object *argv ) +{ + double xdisp = *((int *) argv[2]); + double ydisp = *((int *) argv[3]); + + return( im_stretch3( argv[0], argv[1], xdisp, ydisp ) ); +} + +/* Description of im_stretch3. + */ +static im_function stretch3_desc = { + "im_stretch3", /* Name */ + "stretch 3%, sub-pixel displace by xdisp/ydisp", + IM_FN_PIO, /* Flags */ + stretch3_vec, /* Dispatch function */ + IM_NUMBER( stretch3_args ), /* Size of arg list */ + stretch3_args /* Arg list */ +}; + /* Package up all these functions. */ static im_function *resample_list[] = { + &resize_linear_desc, + &shrink_desc, + &stretch3_desc, &affinei_desc, - &affinei_all_desc, + &affinei_all_desc }; /* Package of functions.