From c248b7203d8ab3c4b853a5290e09e80499b99149 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 10 Jun 2011 17:21:32 +0100 Subject: [PATCH] more im_aconv() cluster polishing larger edge buffer, strike out all involved nodes on merge --- libvips/convolution/im_aconv.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/libvips/convolution/im_aconv.c b/libvips/convolution/im_aconv.c index 8dd0b95f..f285439f 100644 --- a/libvips/convolution/im_aconv.c +++ b/libvips/convolution/im_aconv.c @@ -67,8 +67,6 @@ $ vips im_abs diff.v abs.v $ vips im_max abs.v 2.70833 - - clustering could be much faster - - add more bandfmt - are we handling mask offset correctly? @@ -106,7 +104,7 @@ $ vips im_max abs.v /* The number of edges we consider at once in clustering. Higher values are * faster, but risk pushing up average error in the result. */ -#define MAX_EDGES (10) +#define MAX_EDGES (1000) /* Get an (x,y) value from a mask. */ @@ -361,13 +359,27 @@ boxes_cluster2( Boxes *boxes, int cluster ) if( edge->d > cluster ) break; - if( boxes->hline[edge->a].weight == 0 ) - continue; - if( boxes->hline[edge->b].weight == 0 ) + + /* Has been removed, see loop below. + */ + if( edge->a == -1 ) continue; boxes_merge( boxes, edge->a, edge->b ); merged = 1; + + /* Nodes a and b have vanished or been moved. Remove any edges + * which refer to them from the edge list, + */ + for( i = k; i < MAX_EDGES; i++ ) { + Edge *edgei = &boxes->edge[i]; + + if( edgei->a == edge->a || + edgei->b == edge->a || + edgei->a == edge->b || + edgei->b == edge->b ) + edgei->a = -1; + } } return( merged );