18 #ifndef PIC_SIFT_DESCRIPTOR_HPP 19 #define PIC_SIFT_DESCRIPTOR_HPP 21 #include "../image.hpp" 22 #include "../util/array.hpp" 76 for(
int i = 0; i <
nBin; i++) {
81 for(
int i = 0; i < 36; i++) {
106 float orientation[36];
114 int y = y_local + y0;
118 int x = x_local + x0;
120 float *grad = (*imgGrad)(x, y);
123 float angle = atan2f(grad[1], grad[0]);
124 angle = (angle >= 0.0f) ? angle : angle +
C_PI_2;
129 int index = int(floorf(index_f));
130 int index_1 = (index + 1) %
nBin;
133 dist =
CLAMPi(dist, 0.0f, 1.0f);
135 int squared = x_local * x_local + y_local * y_local;
137 float mag = grad[2] * expf(-
float(squared) /
sigma_sq_2);
139 orientation[index] += mag * (1.0f - dist);
140 orientation[index_1] += mag * dist;
158 float *
get(
Image *imgGrad,
int x0,
int y0,
float *desc = NULL)
160 if(imgGrad == NULL) {
165 desc =
new float[
tot];
168 memset(desc, 0,
sizeof(
float) *
tot);
172 float cosAngle = cosf(-kp_angle);
173 float sinAngle = sinf(-kp_angle);
190 float *grad = (*imgGrad)(x, y);
197 float r_gx = grad[0] * cosAngle - grad[1] * sinAngle;
198 float r_gy = grad[0] * sinAngle + grad[1] * cosAngle;
200 float angle = atan2f(r_gy, r_gx);
201 angle = (angle >= 0.0f) ? angle : angle +
C_PI_2;
206 int index = int(floorf(index_f));
207 int index_1 = (index + 1) %
nBin;
210 dist =
CLAMPi(dist, 0.0f, 1.0f);
214 int squared = x_local * x_local + y_local * y_local;
216 float mag = grad[2] * expf(-
float(squared) /
sigma_sq_2);
218 desc[counter + index] += mag * (1.0f - dist);
219 desc[counter + index_1] += mag * dist;
232 for(
int i = 0; i <
tot; i++) {
233 desc[i] = desc[i] > 0.2f ? desc[i] : 0.2f;
243 static float match(
float *fv0,
float *fv1,
int nfv)
245 if(fv0 == NULL || fv1 == NULL || nfv < 1) {
int half_patchSize
Definition: sift_descriptor.hpp:37
static T getMax(T *data, int size, int &ind)
getMax
Definition: array.hpp:516
float computePatchOrientation(Image *imgGrad, int x0, int y0)
computePatchOrientation
Definition: sift_descriptor.hpp:104
void update(float thr_weak=0.05f, int patchSize=16, int subPatchSize=4, int nBin=8)
update
Definition: sift_descriptor.hpp:54
static float normalize(float *data, int n, float norm_sq=-1.0f)
normalize
Definition: array.hpp:257
static float match(float *fv0, float *fv1, int nfv)
Definition: sift_descriptor.hpp:243
float sigma
Definition: sift_descriptor.hpp:29
int getDescriptorSize()
getDescriptorSize returns the descriptor size.
Definition: sift_descriptor.hpp:92
int subPatchSize
Definition: sift_descriptor.hpp:37
T * delete_vec_s(T *data)
delete_vec_s
Definition: std_util.hpp:138
static T distanceSq(T *data0, T *data1, int n)
distanceSq
Definition: array.hpp:195
const float C_PI_2
Definition: math.hpp:52
Definition: sift_descriptor.hpp:26
float sector_angle
Definition: sift_descriptor.hpp:32
float sigma_sq_2
Definition: sift_descriptor.hpp:29
SIFTDescriptor(float thr_weak=0.01f, int patchSize=16, int subPatchSize=4, int nBin=8)
Definition: sift_descriptor.hpp:41
float thr_weak
Definition: sift_descriptor.hpp:29
int patchSize
Definition: sift_descriptor.hpp:37
The Image class stores an image as buffer of float.
Definition: image.hpp:60
int subPatchSize_sq
Definition: sift_descriptor.hpp:37
#define CLAMPi(x, a, b)
Definition: math.hpp:81
Definition: bilateral_separation.hpp:25
static T * assign(T *data, int size, T *ret)
assign
Definition: array.hpp:464
#define MAX(a, b)
Definition: math.hpp:73
float * reference_angles
Definition: sift_descriptor.hpp:31
float reference_angles_orientation[36]
Definition: sift_descriptor.hpp:34
float nBinf
Definition: sift_descriptor.hpp:32
float sector_angle_orientation
Definition: sift_descriptor.hpp:35
int tot
Definition: sift_descriptor.hpp:37
int nBin
Definition: sift_descriptor.hpp:37