small hough cleanups
This commit is contained in:
parent
4d758af087
commit
bb87bb3690
@ -100,10 +100,13 @@ vips_hough_start( VipsStatistic *statistic )
|
|||||||
*/
|
*/
|
||||||
g_assert( !hough->threads );
|
g_assert( !hough->threads );
|
||||||
|
|
||||||
if( !(accumulator = class->new_accumulator( hough )) )
|
accumulator = vips_image_new_buffer();
|
||||||
return( NULL );
|
|
||||||
|
|
||||||
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 );
|
g_object_unref( accumulator );
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,8 @@ extern "C" {
|
|||||||
typedef struct _VipsHough VipsHough;
|
typedef struct _VipsHough VipsHough;
|
||||||
typedef struct _VipsHoughClass VipsHoughClass;
|
typedef struct _VipsHoughClass VipsHoughClass;
|
||||||
|
|
||||||
typedef VipsImage *(*VipsHoughNewAccumulator)( VipsHough *hough );
|
typedef int (*VipsHoughInitAccumulator)( VipsHough *hough,
|
||||||
|
VipsImage *accumulator );
|
||||||
typedef void (*VipsHoughVote)( VipsHough *hough,
|
typedef void (*VipsHoughVote)( VipsHough *hough,
|
||||||
VipsImage *accumulator, int x, int y );
|
VipsImage *accumulator, int x, int y );
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ struct _VipsHoughClass {
|
|||||||
|
|
||||||
/* Make a new accumulator image.
|
/* Make a new accumulator image.
|
||||||
*/
|
*/
|
||||||
VipsHoughNewAccumulator new_accumulator;
|
VipsHoughInitAccumulator init_accumulator;
|
||||||
|
|
||||||
/* Vote function for this parameter space.
|
/* Vote function for this parameter space.
|
||||||
*/
|
*/
|
||||||
|
@ -76,27 +76,16 @@ vips_hough_line_build( VipsObject *object )
|
|||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build a new accumulator.
|
static int
|
||||||
*/
|
vips_hough_line_init_accumulator( VipsHough *hough, VipsImage *accumulator )
|
||||||
static VipsImage *
|
|
||||||
vips_hough_line_new_accumulator( VipsHough *hough )
|
|
||||||
{
|
{
|
||||||
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,
|
vips_image_init_fields( accumulator,
|
||||||
hough->width, hough->height, 1,
|
hough->width, hough->height, 1,
|
||||||
VIPS_FORMAT_UINT, VIPS_CODING_NONE,
|
VIPS_FORMAT_UINT, VIPS_CODING_NONE,
|
||||||
VIPS_INTERPRETATION_MATRIX,
|
VIPS_INTERPRETATION_MATRIX,
|
||||||
1.0, 1.0 );
|
1.0, 1.0 );
|
||||||
|
|
||||||
return( (void *) accumulator );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cast votes for all lines passing through x, y.
|
/* 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->description = _( "find hough line transform" );
|
||||||
object_class->build = vips_hough_line_build;
|
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;
|
hclass->vote = vips_hough_line_vote;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user