another 2x faster on hough_line
This commit is contained in:
parent
59afb52f7c
commit
ce1f236c4d
@ -3,7 +3,8 @@
|
||||
- remove jpeg thumbnail from EXIF if "jpeg-thumbnail-data" has been removed by
|
||||
user
|
||||
- hough_line scales width to 0 - 180, not 0 - 360
|
||||
- hough_line is 2x faster
|
||||
- hough_line is 4x faster
|
||||
- hough_circle is 2x faster
|
||||
|
||||
5/1/18 started 8.6.2
|
||||
- vips_sink_screen() keeps a ref to the input image ... stops a rare race
|
||||
|
@ -72,13 +72,13 @@ vips_hough_line_build( VipsObject *object )
|
||||
|
||||
int i;
|
||||
|
||||
if( !(hough_line->sin = VIPS_ARRAY( object, width, double )) )
|
||||
if( !(hough_line->sin = VIPS_ARRAY( object, 2 * width, double )) )
|
||||
return( -1 );
|
||||
|
||||
/* Map width to 180 degrees.
|
||||
/* Map width to 180 degrees, width * 2 to 360.
|
||||
*/
|
||||
for( i = 0; i < width; i++ )
|
||||
hough_line->sin[i] = sin( VIPS_PI * i / width );
|
||||
for( i = 0; i < 2 * width; i++ )
|
||||
hough_line->sin[i] = sin( 2 * VIPS_PI * i / (2 * width) );
|
||||
|
||||
if( VIPS_OBJECT_CLASS( vips_hough_line_parent_class )->build( object ) )
|
||||
return( -1 );
|
||||
@ -111,13 +111,12 @@ vips_hough_line_vote( VipsHough *hough, VipsImage *accumulator, int x, int y )
|
||||
double yd = (double) y / statistic->ready->Ysize;
|
||||
int width = hough_line->width;
|
||||
int height = hough_line->height;
|
||||
unsigned int *data =
|
||||
(unsigned int *) VIPS_IMAGE_ADDR( accumulator, 0, 0 );
|
||||
guint *data = (guint *) accumulator->data;
|
||||
|
||||
int i;
|
||||
|
||||
for( i = 0; i < width; i++ ) {
|
||||
int i90 = (i + width / 2) % width;
|
||||
int i90 = i + width / 2;
|
||||
double r = xd * hough_line->sin[i90] + yd * hough_line->sin[i];
|
||||
int ri = height * r;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user