-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfasthessian.h
139 lines (95 loc) · 4.33 KB
/
fasthessian.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/***********************************************************
* --- OpenSURF --- *
* This library is distributed under the GNU GPL. Please *
* use the contact form at http://www.chrisevansdev.com *
* for more information. *
* *
* C. Evans, Research Into Robust Visual Features, *
* MSc University of Bristol, 2008. *
* *
************************************************************/
#ifndef FASTHESSIAN_H
#define FASTHESSIAN_H
#include <vector>
#include <vtkImageData.h>
#include <opencv2/opencv.hpp>
#include "ipoint.h"
#include <vtkMutexLock.h>
#define NONE_SCALE 0 //0b00
#define FIRST_SCALE 1 //0b01
#define LAST_SCALE 2 //0b10
class ResponseLayer;
//Maximum value
static const int OCTAVES = 5;
static const int INTERVALS = 4;
static const float THRES = 0.0004f;
static const int INIT_SAMPLE = 2;
class FastHessian {
public:
//! Constructor without image
FastHessian(std::vector<Ipoint> &ipts,
const int octaves = OCTAVES,
const int intervals = INTERVALS,
const int init_sample = INIT_SAMPLE,
const float thres = THRES);
//! Constructor with image
FastHessian(vtkImageData *img,
std::vector<Ipoint> &ipts,
const int octaves = OCTAVES,
const int intervals = INTERVALS,
const int init_sample = INIT_SAMPLE,
const float thres = THRES);
//! Destructor
~FastHessian();
//! Save the parameters
void saveParameters(const int octaves,
const int intervals,
const int init_sample,
const float thres);
//! Set or re-set the integral image source
void setIntImage(vtkImageData *img);
void setMask(vtkImageData *Mask);
void WriteResponseMap();
//! Find the image features and write into vector of features
void getIpoints();
private:
//---------------- Private Functions -----------------//
//! Build map of DoH responses
void buildResponseMap();
//! Calculate DoH responses for supplied layer
void buildResponseLayer(int i, int decile);
void EigenValue(float Cxx, float Cyy, float Czz, float Cxy, float Cyz, float Cxz, float c[3]);
//! 3x3x3x3 Extrema test
int isExtremum(int r, int c, int d, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b, int param);
int isCornerExtremum(int r, int c, int d, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b, int param);
//! Interpolation functions - adapted from Lowe's SIFT implementation
void interpolateExtremum(int d, int r, int c, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b, bool corner);
void interpolateStep(int d, int r, int c, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b,
double* xX, double* xY, double* xZ, double* xS, bool corner);
cv::Matx41d* deriv4D(int d, int r, int c, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b, bool corner);
cv::Matx44d* hessian4D(int d, int r, int c, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b, bool corner);
static VTK_THREAD_RETURN_TYPE ThreadedRL (void *arg);
int Current_thread_ID;
int Current_decile;
void FittingQuadric(int d, int r, int c, ResponseLayer *t, ResponseLayer *m, ResponseLayer *b,
double* xX, double* xY, double* xZ, double* xS , bool corner);
//---------------- Private Variables -----------------//
//! Pointer to the integral Image, and its attributes
vtkImageData *img;
int i_width, i_height, i_depth;
//! Reference to vector of features passed from outside
std::vector<Ipoint> &ipts;
vtkImageData *Mask;
//! Response stack of determinant of hessian values
std::vector<ResponseLayer *> responseMap;
//! Number of Octaves
int octaves;
//! Number of Intervals per octave
int intervals;
//! Initial sampling step for Ipoint detection
int init_sample;
//! Threshold value for blob resonses
float thresh;
inline void print(cv::Mat *input);
};
#endif