small hough cleanups

This commit is contained in:
John Cupitt 2014-03-25 08:45:57 +00:00
parent 4d758af087
commit bb87bb3690
3 changed files with 13 additions and 20 deletions

View File

@ -100,10 +100,13 @@ vips_hough_start( VipsStatistic *statistic )
*/
g_assert( !hough->threads );
if( !(accumulator = class->new_accumulator( hough )) )
return( NULL );
accumulator = vips_image_new_buffer();
if( vips_image_write_prepare( accumulator ) ) {
vips_image_pipelinev( accumulator,
VIPS_DEMAND_STYLE_ANY, statistic->in, NULL );
if( class->init_accumulator( hough, accumulator ) ||
vips_image_write_prepare( accumulator ) ) {
g_object_unref( accumulator );
return( NULL );
}

View File

@ -56,7 +56,8 @@ extern "C" {
typedef struct _VipsHough VipsHough;
typedef struct _VipsHoughClass VipsHoughClass;
typedef VipsImage *(*VipsHoughNewAccumulator)( VipsHough *hough );
typedef int (*VipsHoughInitAccumulator)( VipsHough *hough,
VipsImage *accumulator );
typedef void (*VipsHoughVote)( VipsHough *hough,
VipsImage *accumulator, int x, int y );
@ -87,7 +88,7 @@ struct _VipsHoughClass {
/* Make a new accumulator image.
*/
VipsHoughNewAccumulator new_accumulator;
VipsHoughInitAccumulator init_accumulator;
/* Vote function for this parameter space.
*/

View File

@ -76,27 +76,16 @@ vips_hough_line_build( VipsObject *object )
return( 0 );
}
/* Build a new accumulator.
*/
static VipsImage *
vips_hough_line_new_accumulator( VipsHough *hough )
static int
vips_hough_line_init_accumulator( VipsHough *hough, VipsImage *accumulator )
{
VipsStatistic *statistic = (VipsStatistic *) hough;
VipsImage *accumulator;
accumulator = vips_image_new_buffer();
vips_image_pipelinev( accumulator,
VIPS_DEMAND_STYLE_ANY, statistic->in, NULL );
vips_image_init_fields( accumulator,
hough->width, hough->height, 1,
VIPS_FORMAT_UINT, VIPS_CODING_NONE,
VIPS_INTERPRETATION_MATRIX,
1.0, 1.0 );
return( (void *) accumulator );
return( 0 );
}
/* Cast votes for all lines passing through x, y.
@ -132,7 +121,7 @@ vips_hough_line_class_init( VipsHoughClass *class )
object_class->description = _( "find hough line transform" );
object_class->build = vips_hough_line_build;
hclass->new_accumulator = vips_hough_line_new_accumulator;
hclass->init_accumulator = vips_hough_line_init_accumulator;
hclass->vote = vips_hough_line_vote;
}