allow much larger reduce factors

sometimes you want to use lanczos etc. for everything
This commit is contained in:
John Cupitt 2017-10-09 11:48:11 +01:00
parent 61fc94946a
commit de82c9e919
6 changed files with 24 additions and 20 deletions

View File

@ -601,7 +601,7 @@ vips_colourspace_class_init( VipsColourspaceClass *class )
G_STRUCT_OFFSET( VipsColourspace, space ), G_STRUCT_OFFSET( VipsColourspace, space ),
VIPS_TYPE_INTERPRETATION, VIPS_INTERPRETATION_sRGB ); VIPS_TYPE_INTERPRETATION, VIPS_INTERPRETATION_sRGB );
VIPS_ARG_ENUM( class, "source-space", 6, VIPS_ARG_ENUM( class, "source_space", 6,
_( "Source space" ), _( "Source space" ),
_( "Source color space" ), _( "Source color space" ),
VIPS_ARGUMENT_OPTIONAL_INPUT, VIPS_ARGUMENT_OPTIONAL_INPUT,

View File

@ -938,7 +938,7 @@ vips_convi_build( VipsObject *object )
!intize_to_fixed_point( M, convi->fixed ) && !intize_to_fixed_point( M, convi->fixed ) &&
!vips_convi_compile( convi, in ) ) { !vips_convi_compile( convi, in ) ) {
generate = vips_convi_gen_vector; generate = vips_convi_gen_vector;
g_info( "using vector path" ); g_info( "convi: using vector path" );
} }
else else
vips_convi_compile_free( convi ); vips_convi_compile_free( convi );
@ -947,7 +947,7 @@ vips_convi_build( VipsObject *object )
/* Make the data for the C path. /* Make the data for the C path.
*/ */
if( generate == vips_convi_gen ) { if( generate == vips_convi_gen ) {
g_info( "using C path" ); g_info( "convi: using C path" );
/* Make an int version of our mask. /* Make an int version of our mask.
*/ */

View File

@ -67,7 +67,7 @@ GType vips_resample_get_type( void );
/* The max size of the vector we use. /* The max size of the vector we use.
*/ */
#define MAX_POINT (50) #define MAX_POINT (2000)
int vips_reduce_get_points( VipsKernel kernel, double shrink ); int vips_reduce_get_points( VipsKernel kernel, double shrink );
void vips_reduce_make_mask( double *c, void vips_reduce_make_mask( double *c,

View File

@ -454,7 +454,7 @@ vips_reduceh_build( VipsObject *object )
*/ */
reduceh->n_point = reduceh->n_point =
vips_reduce_get_points( reduceh->kernel, reduceh->hshrink ); vips_reduce_get_points( reduceh->kernel, reduceh->hshrink );
g_info( "%d point mask", reduceh->n_point ); g_info( "reduceh: %d point mask", reduceh->n_point );
if( reduceh->n_point > MAX_POINT ) { if( reduceh->n_point > MAX_POINT ) {
vips_error( object_class->nickname, vips_error( object_class->nickname,
"%s", _( "reduce factor too large" ) ); "%s", _( "reduce factor too large" ) );

View File

@ -781,7 +781,7 @@ vips_reducev_raw( VipsReducev *reducev, VipsImage *in, VipsImage **out )
if( in->BandFmt == VIPS_FORMAT_UCHAR && if( in->BandFmt == VIPS_FORMAT_UCHAR &&
vips_vector_isenabled() && vips_vector_isenabled() &&
!vips_reducev_compile( reducev ) ) { !vips_reducev_compile( reducev ) ) {
g_info( "using vector path" ); g_info( "reducev: using vector path" );
generate = vips_reducev_vector_gen; generate = vips_reducev_vector_gen;
} }
@ -848,12 +848,12 @@ vips_reducev_build( VipsObject *object )
reducev->n_point = reducev->n_point =
vips_reduce_get_points( reducev->kernel, reducev->vshrink ); vips_reduce_get_points( reducev->kernel, reducev->vshrink );
g_info( "reducev: %d point mask", reducev->n_point );
if( reducev->n_point > MAX_POINT ) { if( reducev->n_point > MAX_POINT ) {
vips_error( object_class->nickname, vips_error( object_class->nickname,
"%s", _( "reduce factor too large" ) ); "%s", _( "reduce factor too large" ) );
return( -1 ); return( -1 );
} }
g_info( "%d point mask", reducev->n_point );
/* Unpack for processing. /* Unpack for processing.
*/ */

View File

@ -115,22 +115,26 @@ G_DEFINE_TYPE( VipsResize, vips_resize, VIPS_TYPE_RESAMPLE );
static int static int
vips_resize_int_shrink( VipsResize *resize, double scale ) vips_resize_int_shrink( VipsResize *resize, double scale )
{ {
if( scale > 1.0 ) int shrink;
return( 1 );
if( scale > 1.0 )
shrink = 1;
else
switch( resize->kernel ) { switch( resize->kernel ) {
case VIPS_KERNEL_NEAREST: case VIPS_KERNEL_NEAREST:
return( 1 ); shrink = 1;
case VIPS_KERNEL_LINEAR: case VIPS_KERNEL_LINEAR:
case VIPS_KERNEL_CUBIC: case VIPS_KERNEL_CUBIC:
default: default:
return( VIPS_FLOOR( 1.0 / scale ) ); shrink = VIPS_FLOOR( 1.0 / scale );
case VIPS_KERNEL_LANCZOS2: case VIPS_KERNEL_LANCZOS2:
case VIPS_KERNEL_LANCZOS3: case VIPS_KERNEL_LANCZOS3:
return( VIPS_MAX( 1, VIPS_FLOOR( 1.0 / (scale * 2) ) ) ); shrink = VIPS_MAX( 1, VIPS_FLOOR( 1.0 / (scale * 2) ) );
} }
return( shrink );
} }
/* Suggest a VipsInterpolate which corresponds to a VipsKernel. We use /* Suggest a VipsInterpolate which corresponds to a VipsKernel. We use
@ -392,7 +396,7 @@ vips_resize_init( VipsResize *resize )
* a #VipsInterpolate selected depending on @kernel. It will use * a #VipsInterpolate selected depending on @kernel. It will use
* #VipsInterpolateBicubic for #VIPS_KERNEL_CUBIC and above. * #VipsInterpolateBicubic for #VIPS_KERNEL_CUBIC and above.
* *
* vips_resize() normally maintains the image apect ratio. If you set * vips_resize() normally maintains the image aspect ratio. If you set
* @vscale, that factor is used for the vertical scale and @scale for the * @vscale, that factor is used for the vertical scale and @scale for the
* horizontal. * horizontal.
* *