#include <dog.h>
Definition at line 43 of file dog.h.
Public Member Functions | |
virtual void | operator() (const CVD::Image< CVD::byte > &i, std::vector< CVD::ImageRef > &c, unsigned int N) const |
void harrisdog::operator() | ( | const CVD::Image< CVD::byte > & | i, | |
std::vector< CVD::ImageRef > & | c, | |||
unsigned int | N | |||
) | const [virtual] |
Detecto corners.
i | Image in which to detect corners | |
c | Detected corners are inserted in to this container | |
N | Number of corners to detect |
Implements DetectN.
Definition at line 226 of file dog.cc.
References HarrisDetector().
00227 { 00228 int s = GV3::get<int>("harrislaplace.dog.divisions_per_octave", 11); //Divisions per octave 00229 int octaves=GV3::get<int>("harrislaplace.dog.octaves", 4, 1); 00230 double sigma = GV3::get<double>("harrislaplace.dog.sigma", 0.8); 00231 00232 float hblur = GV3::get<float>("harrislaplace.harris.blur", 2.5); 00233 float hsigmas = GV3::get<float>("harrislaplace.harris.sigmas", 2.0, 1); 00234 00235 double k = pow(2, 1.0/s); 00236 00237 Image<float> im = convert_image(i); 00238 00239 //convolveGaussian(im, sigma); 00240 00241 Image<float> d1, d2, d3; 00242 Image<float> im1, im2, im3; 00243 c.clear(); 00244 vector<pair<float, ImageRef> > corners; 00245 corners.reserve(50000); 00246 00247 int scalemul=1; 00248 int d1m = 1, d2m = 1, d3m = 1; 00249 00250 for(int o=0; o < octaves; o++) 00251 { 00252 00253 for(int j=0; j < s; j++) 00254 { 00255 float delta_sigma = sigma * sqrt(k*k-1); 00256 //hblur *= sqrt(k*k-1); 00257 00258 //Blur im, and put the result in blurred. 00259 //im is already blurred from the previous layers 00260 Image<float> blurred(im.size(), 0); 00261 convolveGaussian_fir(im, blurred, delta_sigma); 00262 00263 //For DoG, at this point, we don't need im anymore, since blurred 00264 //will be used as "im" for the next layer. However, we do need it for 00265 //HarrisDoG, since we need to do a HarrisDetect on it. 00266 Image<float> diff(im.size(), 0); 00267 for(fi i1=im.begin(), i2 = blurred.begin(), d = diff.begin(); i1!= im.end(); ++i1, ++i2, ++d) 00268 *d = (*i2 - *i1); 00269 00270 //Insert the current image, and the current difference 00271 //in to the ring buffer 00272 d1 = d2; 00273 d2 = d3; 00274 d3 = diff; 00275 00276 im1 = im2; 00277 im2 = im3; 00278 im3 = im; 00279 00280 00281 im = blurred; 00282 00283 d1m = d2m; 00284 d2m = d3m; 00285 d3m = scalemul; 00286 00287 //Find maxima 00288 if(d1.size().x != 0) 00289 { 00290 //First, find Harris maxima 00291 vector<pair<float, ImageRef> > layer_corners; 00292 HarrisDetector(im2, layer_corners, N, hblur, hsigmas); 00293 00294 //Keep if they are LoG (or really DoG) maxima across scales. 00295 //The Harris score olny is used. 00296 for(unsigned int c=0; c < layer_corners.size(); c++) 00297 if(is_scale_maximum(d1, d2, d3, layer_corners[c].second)) 00298 corners.push_back(layer_corners[c]); 00299 } 00300 00301 sigma *= k; 00302 } 00303 00304 if(o != octaves - 1) 00305 { 00306 scalemul *=2; 00307 sigma /=2; 00308 Image<float> tmp(im.size()/2); 00309 halfSample(im,tmp); 00310 im=tmp; 00311 } 00312 } 00313 00314 00315 if(corners.size() > N) 00316 { 00317 nth_element(corners.begin(), corners.begin() + N, corners.end()); 00318 corners.resize(N); 00319 } 00320 00321 c.clear(); 00322 00323 for(unsigned int i=0; i < corners.size(); i++) 00324 c.push_back(corners[i].second); 00325 00326 }