Skip to content

Commit be4ccde

Browse files
author
Carsten Griwodz
committed
[sift] reduce size of GaussTable dd to 1
The other levels existed only for direct downscaling.
1 parent fd924b2 commit be4ccde

File tree

2 files changed

+23
-33
lines changed

2 files changed

+23
-33
lines changed

src/popsift/gauss_filter.cu

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,19 @@ void print_gauss_filter_symbol( int columns )
102102
}
103103
printf("\n");
104104

105-
printf(" level 0-filters for direct downscaling\n");
105+
printf(" level 0-filter for the creation of the first level of the first octave\n" );
106106

107-
for( int lvl=0; lvl<MAX_OCTAVES; lvl++ ) {
108-
int span = d_gauss.dd.span[lvl] + d_gauss.dd.span[lvl] - 1;
107+
int span = d_gauss.dd.span[0] + d_gauss.dd.span[0] - 1;
109108

110-
printf(" %d %d %2.6f: ", lvl, span, d_gauss.dd.sigma[lvl] );
111-
int m = min( d_gauss.dd.span[lvl], columns );
112-
for( int x=0; x<m; x++ ) {
113-
printf("%0.8f ", d_gauss.dd.filter[lvl*GAUSS_ALIGN+x] );
114-
}
115-
if( m < d_gauss.dd.span[lvl] )
116-
printf("...\n");
117-
else
118-
printf("\n");
109+
printf(" %d %d %2.6f: ", 0, span, d_gauss.dd.sigma[0] );
110+
int m = min( d_gauss.dd.span[0], columns );
111+
for( int x=0; x<m; x++ ) {
112+
printf("%0.8f ", d_gauss.dd.filter[x] );
119113
}
114+
if( m < d_gauss.dd.span[0] )
115+
printf("...\n");
116+
else
117+
printf("\n");
120118
printf("\n");
121119
}
122120

@@ -215,26 +213,17 @@ void init_filter( const Config& conf,
215213
h_gauss.abs_oN.computeBlurTable( &h_gauss );
216214

217215
/* dd :
218-
* The direct-downscaling kernels make use of the assumption that downscaling
219-
* from MAX_LEVEL-3 is identical to applying 2*sigma on the identical image
220-
* before downscaling, which would be identical to applying 1*sigma after
221-
* downscaling.
222-
* In reality, this is not true because images are not continuous, but we
223-
* support the options because it is interesting. Perhaps it works for the later
224-
* octaves, where it is also good for performance.
216+
* A leftover from an attempt to create all top levels of all octaves from the
217+
* input image.
225218
* dd is only for creating level 0 of all octave directly from the input image.
226219
*/
227-
for( int oct=0; oct<MAX_OCTAVES; oct++ ) {
228-
// sigma * 2^i
229-
float oct_sigma = scalbnf( sigma0, oct );
230220

231-
// subtract initial blur
232-
float b = sqrt( fabs( oct_sigma * oct_sigma - initial_blur * initial_blur ) );
221+
// subtract initial blur
222+
const float sigma_o0_l0 = sqrt( fabs( sigma0 * sigma0 - initial_blur * initial_blur ) );
233223

234-
// sigma / 2^i
235-
h_gauss.dd.sigma[oct] = scalbnf( b, -oct );
236-
h_gauss.dd.computeBlurTable( &h_gauss );
237-
}
224+
// sigma / 2^i
225+
h_gauss.dd.sigma[0] = sigma_o0_l0;
226+
h_gauss.dd.computeBlurTable( &h_gauss );
238227

239228
cudaError_t err;
240229
err = cudaMemcpyToSymbol( d_gauss,

src/popsift/gauss_filter.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,13 @@ struct GaussInfo
7474
*/
7575
GaussTable<GAUSS_LEVELS> abs_oN;
7676

77-
/* In theory, level 0 of octave 2 contains the same information
78-
* whether it is constructed by downscaling and blurring the
79-
* input image with sigma or by blurring the input image with 2*sigma
80-
* and downscaling afterwards.
77+
/* The dd table was meant for the creation of every top-level of
78+
* every octave directly from the upscaling input image. This option
79+
* has been removed because it didn't work well.
80+
* As a consequence, the table dd needs only its first entry for
81+
* Gaussian filtering of the first octave.
8182
*/
82-
GaussTable<MAX_OCTAVES> dd;
83+
GaussTable<1> dd;
8384

8485
__host__
8586
void clearTables( );

0 commit comments

Comments
 (0)