#include <dog.h>
Definition at line 32 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 dog::operator() | ( | const CVD::Image< CVD::byte > & | i, | |
std::vector< CVD::ImageRef > & | c, | |||
unsigned int | N | |||
) | const [virtual] |
Detect 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 109 of file dog.cc.
00110 { 00111 int s = GV3::get<int>("dog.divisions_per_octave", 3,1); //Divisions per octave 00112 int octaves=GV3::get<int>("dog.octaves", 4, 1); 00113 00114 double k = pow(2, 1.0/s); 00115 00116 double sigma = GV3::get<double>("dog.sigma", 0.8, 1); 00117 00118 Image<float> im = convert_image(i); 00119 00120 convolveGaussian_fir(im, im, sigma); 00121 00122 00123 Image<float> d1, d2, d3; 00124 c.clear(); 00125 vector<pair<float, ImageRef> > corners; 00126 corners.reserve(50000); 00127 00128 int scalemul=1; 00129 int d1m = 1, d2m = 1, d3m = 1; 00130 00131 for(int o=0; o < octaves; o++) 00132 { 00133 00134 for(int j=0; j < s; j++) 00135 { 00136 float delta_sigma = sigma * sqrt(k*k-1); 00137 Image<float> blurred(im.size()); 00138 convolveGaussian_fir(im, blurred, delta_sigma); 00139 00140 for(fi i1=im.begin(), i2 = blurred.begin(); i1!= im.end(); ++i1, ++i2) 00141 *i1 = (*i2 - *i1); 00142 00143 //im is now dog 00144 //blurred 00145 00146 d1 = d2; 00147 d2 = d3; 00148 d3 = im; 00149 im = blurred; 00150 00151 d1m = d2m; 00152 d2m = d3m; 00153 d3m = scalemul; 00154 00155 //Find maxima 00156 if(d1.size().x != 0) 00157 { 00158 if(d1.size() == d2.size()) 00159 if(d2.size() == d3.size()) 00160 local_maxima<Equal, Equal>(d1, d2, d3, corners, d2m); 00161 else 00162 local_maxima<Equal, Smaller>(d1, d2, d3, corners, d2m); 00163 else 00164 if(d2.size() == d3.size()) 00165 local_maxima<Larger, Equal>(d1, d2, d3, corners, d2m); 00166 else 00167 local_maxima<Larger, Smaller>(d1, d2, d3, corners, d2m); 00168 } 00169 00170 00171 sigma *= k; 00172 } 00173 00174 if(o != octaves - 1) 00175 { 00176 scalemul *=2; 00177 sigma /=2; 00178 Image<float> tmp(im.size()/2); 00179 halfSample(im,tmp); 00180 im=tmp; 00181 } 00182 } 00183 00184 00185 if(corners.size() > N) 00186 { 00187 nth_element(corners.begin(), corners.begin() + N, corners.end()); 00188 corners.resize(N); 00189 } 00190 00191 00192 for(unsigned int i=0; i < corners.size(); i++) 00193 c.push_back(corners[i].second); 00194 }