@@ -99,6 +99,18 @@ void AKAZEFeatures::Allocate_Memory_Evolution(void) {
99
99
}
100
100
101
101
/* ************************************************************************* */
102
+ /* *
103
+ * @brief Computes kernel size for Gaussian smoothing if the image
104
+ * @param sigma Kernel standard deviation
105
+ * @returns kernel size
106
+ */
107
+ static inline int getGaussianKernelSize (float sigma) {
108
+ // Compute an appropriate kernel size according to the specified sigma
109
+ int ksize = (int )ceil (2 .0f *(1 .0f + (sigma - 0 .8f ) / (0 .3f )));
110
+ ksize |= 1 ; // kernel should be odd
111
+ return ksize;
112
+ }
113
+
102
114
/* *
103
115
* @brief This method creates the nonlinear scale space for a given image
104
116
* @param img Input image for which the nonlinear scale space needs to be created
@@ -109,10 +121,15 @@ int AKAZEFeatures::Create_Nonlinear_Scale_Space(const Mat& img)
109
121
CV_INSTRUMENT_REGION ()
110
122
CV_Assert (evolution_.size () > 0 );
111
123
112
- // Copy the original image to the first level of the evolution
113
- img.copyTo (evolution_[0 ].Lt );
114
- gaussian_2D_convolution (evolution_[0 ].Lt , evolution_[0 ].Lt , 0 , 0 , options_.soffset );
115
- evolution_[0 ].Lt .copyTo (evolution_[0 ].Lsmooth );
124
+ // create first level of the evolution
125
+ int ksize = getGaussianKernelSize (options_.soffset );
126
+ GaussianBlur (img, evolution_[0 ].Lt , Size (ksize, ksize), options_.soffset , options_.soffset , BORDER_REPLICATE);
127
+ evolution_[0 ].Lsmooth = evolution_[0 ].Lt ;
128
+
129
+ if (evolution_.size () == 1 ) {
130
+ // we don't need to compute kcontrast factor
131
+ return 0 ;
132
+ }
116
133
117
134
// First compute the kcontrast factor
118
135
options_.kcontrast = compute_k_percentile (img, options_.kcontrast_percentile , 1 .0f , options_.kcontrast_nbins , 0 , 0 );
@@ -121,18 +138,21 @@ int AKAZEFeatures::Create_Nonlinear_Scale_Space(const Mat& img)
121
138
for (size_t i = 1 ; i < evolution_.size (); i++) {
122
139
123
140
if (evolution_[i].octave > evolution_[i - 1 ].octave ) {
124
- halfsample_image (evolution_[i - 1 ].Lt , evolution_[i].Lt );
141
+ Size half_size = evolution_[i - 1 ].Lt .size ();
142
+ half_size.width /= 2 ;
143
+ half_size.height /= 2 ;
144
+ resize (evolution_[i - 1 ].Lt , evolution_[i].Lt , half_size, 0 , 0 , INTER_AREA);
125
145
options_.kcontrast = options_.kcontrast *0 .75f ;
126
146
}
127
147
else {
128
148
evolution_[i - 1 ].Lt .copyTo (evolution_[i].Lt );
129
149
}
130
150
131
- gaussian_2D_convolution (evolution_[i].Lt , evolution_[i].Lsmooth , 0 , 0 , 1 .0f );
151
+ GaussianBlur (evolution_[i].Lt , evolution_[i].Lsmooth , Size ( 5 , 5 ) , 1 .0f , 1 . 0f , BORDER_REPLICATE );
132
152
133
153
// Compute the Gaussian derivatives Lx and Ly
134
- image_derivatives_scharr (evolution_[i].Lsmooth , evolution_[i].Lx , 1 , 0 );
135
- image_derivatives_scharr (evolution_[i].Lsmooth , evolution_[i].Ly , 0 , 1 );
154
+ Scharr (evolution_[i].Lsmooth , evolution_[i].Lx , CV_32F, 1 , 0 , 1.0 , 0 , BORDER_DEFAULT );
155
+ Scharr (evolution_[i].Lsmooth , evolution_[i].Ly , CV_32F, 0 , 1 , 1.0 , 0 , BORDER_DEFAULT );
136
156
137
157
// Compute the conductivity equation
138
158
switch (options_.diffusivity ) {
0 commit comments