better hough_line
2x faster, better parameter space, but breaks compat :( sorry
This commit is contained in:
parent
f56fbf564f
commit
78db92e60e
@ -2,6 +2,8 @@
|
|||||||
- add magicksave, save image with libMagick [dlemstra]
|
- add magicksave, save image with libMagick [dlemstra]
|
||||||
- remove jpeg thumbnail from EXIF if "jpeg-thumbnail-data" has been removed by
|
- remove jpeg thumbnail from EXIF if "jpeg-thumbnail-data" has been removed by
|
||||||
user
|
user
|
||||||
|
- hough_line scales width to 0 - 180, not 0 - 360
|
||||||
|
- hough_line is 2x faster
|
||||||
|
|
||||||
5/1/18 started 8.6.2
|
5/1/18 started 8.6.2
|
||||||
- vips_sink_screen() keeps a ref to the input image ... stops a rare race
|
- vips_sink_screen() keeps a ref to the input image ... stops a rare race
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
*
|
*
|
||||||
* 7/3/14
|
* 7/3/14
|
||||||
* - from hist_find.c
|
* - from hist_find.c
|
||||||
|
* 1/2/18
|
||||||
|
* - change width to 0 - 180
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -73,8 +75,10 @@ vips_hough_line_build( VipsObject *object )
|
|||||||
if( !(hough_line->sin = VIPS_ARRAY( object, width, double )) )
|
if( !(hough_line->sin = VIPS_ARRAY( object, width, double )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
|
/* Map width to 180 degrees.
|
||||||
|
*/
|
||||||
for( i = 0; i < width; i++ )
|
for( i = 0; i < width; i++ )
|
||||||
hough_line->sin[i] = sin( 2 * VIPS_PI * i / width );
|
hough_line->sin[i] = sin( VIPS_PI * i / width );
|
||||||
|
|
||||||
if( VIPS_OBJECT_CLASS( vips_hough_line_parent_class )->build( object ) )
|
if( VIPS_OBJECT_CLASS( vips_hough_line_parent_class )->build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
@ -107,17 +111,19 @@ vips_hough_line_vote( VipsHough *hough, VipsImage *accumulator, int x, int y )
|
|||||||
double yd = (double) y / statistic->ready->Ysize;
|
double yd = (double) y / statistic->ready->Ysize;
|
||||||
int width = hough_line->width;
|
int width = hough_line->width;
|
||||||
int height = hough_line->height;
|
int height = hough_line->height;
|
||||||
|
unsigned int *data =
|
||||||
|
(unsigned int *) VIPS_IMAGE_ADDR( accumulator, 0, 0 );
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for( i = 0; i < width; i++ ) {
|
for( i = 0; i < width; i++ ) {
|
||||||
int i90 = (i + width / 4) % width;
|
int i90 = (i + width / 2) % width;
|
||||||
double r = xd * hough_line->sin[i90] + yd * hough_line->sin[i];
|
double r = xd * hough_line->sin[i90] + yd * hough_line->sin[i];
|
||||||
int ri = height * r;
|
int ri = height * r;
|
||||||
|
|
||||||
if( ri >= 0 &&
|
if( ri >= 0 &&
|
||||||
ri < height )
|
ri < height )
|
||||||
*VIPS_IMAGE_ADDR( accumulator, i, ri ) += 1;
|
data[i + ri * width] += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,8 +180,8 @@ vips_hough_line_init( VipsHoughLine *hough_line )
|
|||||||
*
|
*
|
||||||
* Find the line Hough transform for @in. @in must have one band. @out has one
|
* Find the line Hough transform for @in. @in must have one band. @out has one
|
||||||
* band, with pixels being the number of votes for that line. The X dimension
|
* band, with pixels being the number of votes for that line. The X dimension
|
||||||
* of @out is the line angle, the Y dimension is the distance of the line from
|
* of @out is the line angle in 0 - 180 degrees, the Y dimension is the
|
||||||
* the origin.
|
* distance of the closest part of that line to the origin in the top-left.
|
||||||
*
|
*
|
||||||
* Use @width @height to set the size of the parameter space image (@out),
|
* Use @width @height to set the size of the parameter space image (@out),
|
||||||
* that is, how accurate the line determination should be.
|
* that is, how accurate the line determination should be.
|
||||||
|
Loading…
Reference in New Issue
Block a user