fix vips_hist_match()

it wasn't upcasting input to uint due to a mix-up with VipsHistogram
This commit is contained in:
John Cupitt 2013-12-19 10:05:49 +00:00
parent d7037618fc
commit 3f95520580
4 changed files with 29 additions and 15 deletions

View File

@ -1,12 +1,13 @@
20/11/13 started 7.36.5
20/11/13 started 7.36.5
- better cache sizing in unbuffered sequential mode
- allow larger tile_size in dzsave
- remove use of PATH_MAX to help gnu hurd
- fix vips_hist_match()
15/11/13 started 7.36.4
15/11/13 started 7.36.4
- improve compat with im_init_world()
18/10/13 started 7.36.3
18/10/13 started 7.36.3
- fix compiler warnings in ubuntu 13.10
- reverse similarity rotation direction to match the convention used
elsewhere in vips

View File

@ -14,6 +14,8 @@
* - small cleanups
* 12/8/13
* - redone im_histspec() as a class, vips_hist_match()
* 19/12/13
* - oop, upcast input
*/
/*
@ -138,13 +140,6 @@ vips_hist_match_build( VipsObject *object )
return( 0 );
}
#define UI VIPS_FORMAT_UINT
static const VipsBandFormat vips_hist_match_format_table[10] = {
/* UC C US S UI I F X D DX */
UI, UI, UI, UI, UI, UI, UI, UI, UI, UI
};
static void
vips_hist_match_class_init( VipsHistMatchClass *class )
{
@ -159,7 +154,7 @@ vips_hist_match_class_init( VipsHistMatchClass *class )
vobject_class->description = _( "match two histograms" );
vobject_class->build = vips_hist_match_build;
hclass->format_table = vips_hist_match_format_table;
hclass->input_format = VIPS_FORMAT_UINT;
hclass->process = vips_hist_match_process;
VIPS_ARG_IMAGE( class, "in", 1,

View File

@ -145,11 +145,23 @@ vips_histogram_build( VipsObject *object )
vips_check_hist( class->nickname, histogram->in[i] ) )
return( -1 );
/* Cast our input images up to a common format, bands and size.
/* Cast our input images up to a common format, bands and size. If
* input_format is set, cast to a fixed input type.
*/
if( vips__formatalike_vec( histogram->in, format, histogram->n ) ||
vips__bandalike_vec( class->nickname,
format, band, histogram->n, 1 ) ||
if( hclass->input_format != VIPS_FORMAT_NOTSET ) {
for( i = 0; i < histogram->n; i++ )
if( vips_cast( histogram->in[i], &format[i],
hclass->input_format, NULL ) )
return( -1 );
}
else {
if( vips__formatalike_vec( histogram->in,
format, histogram->n ) )
return( -1 );
}
if( vips__bandalike_vec( class->nickname,
format, band, histogram->n, 1 ) ||
vips__hist_sizealike_vec( band, size, histogram->n ) )
return( -1 );
@ -203,6 +215,8 @@ vips_histogram_class_init( VipsHistogramClass *class )
vobject_class->description = _( "histogram operations" );
vobject_class->build = vips_histogram_build;
class->input_format = VIPS_FORMAT_NOTSET;
/* Inputs set by subclassess.
*/

View File

@ -81,6 +81,10 @@ typedef struct _VipsHistogramClass {
*/
const VipsBandFormat *format_table;
/* If not VIPS_FORMAT_NOTSET, upcast all ins to this.
*/
VipsBandFormat input_format;
VipsHistogramProcessFn process;
} VipsHistogramClass;