26 #include "HessianGauss.hh"
27 #include "Convolution.hh"
36 template <
class StorageType,
class OutputStorageType>
46 template <
class StorageType,
class OutputStorageType>
49 : _HessGaussSigma(other._HessGaussSigma),
50 _HessGaussRatio(other._HessGaussRatio),
51 _LastSigma(other._LastSigma),
52 _LastRatio(other._LastRatio),
53 _ConvXX(other._ConvXX),
54 _ConvYY(other._ConvYY),
55 _ConvXY(other._ConvXY)
59 template <
class InputStorageType,
class OutputStorageType>
64 template <
class InputStorageType,
class OutputStorageType>
72 BIASCDOUT(D_FILTERBASE_CALLSTACK,
"HessianGauss::Filter(src, hxx, gyy, hxy)\n");
74 if ((fabs(_HessGaussSigma-_LastSigma)>=DBL_EPSILON) ||
75 (fabs(_HessGaussRatio-_LastRatio)>=DBL_EPSILON)){
76 _CalculateKernels(_HessGaussSigma, _HessGaussRatio);
93 if ((res =_ConvXX.Filter(src, hxx))!=0) {
94 BIASERR(
"Error in hessian xx computation...");
97 if ((res = _ConvYY.Filter(src, hyy))!=0) {
98 BIASERR(
"Error in hessian yy computation...");
102 if ((res = _ConvXY.Filter(src, hxy))!=0) {
103 BIASERR(
"Error in hessian xy computation...");
107 return (res==0)?0:-1;
110 template <
class InputStorageType,
class OutputStorageType>
114 const int hws=(int)(floor(sqrt(-2.0*Sigma*Sigma*log(Ratio))));
115 const int size=(hws<<1)+1;
120 BIASCDOUT(D_HESSGAUSS_KERNEL,
"HWS = "<<hws<<
"\tSize = "<<size<<endl);
121 BIASCDOUT(D_HESSGAUSS_KERNEL,
"Sigma = "<<Sigma<<
"\tRatio = "<<Ratio<<endl);
122 BIASCDOUT(D_HESSGAUSS_KERNEL,
"size = "<<size<<
"\thws = "<<hws<<endl);
126 double fac=-1.0/(2.0*Sigma*Sigma);
128 register double N = 1.0/(Sigma*sqrt(2*M_PI));
129 register double gxx=0,gxy=0,gyy=0;
130 register double g1=0,gxx2=0,gyy2=0;
131 register double eTerm=0;
134 for (
int x=-hws; x<=hws; x++){
135 for (
int y=-hws; y<=hws; y++ ){
140 eTerm = expf((
float)((
double)((x*x)+(y*y))*fac));
141 g1=-N/(Sigma*Sigma)*eTerm;
142 gxx2=(N*x*x)/(Sigma*Sigma*Sigma*Sigma)*eTerm;
143 gyy2=(N*y*y)/(Sigma*Sigma*Sigma*Sigma)*eTerm;
146 gxy=(N*x*y)/(Sigma*Sigma*Sigma*Sigma)*eTerm;
147 Mxx[x+hws][y+hws]= (FM_FLOAT)gxx;
148 Myy[x+hws][y+hws]= (FM_FLOAT)gyy;
149 Mxy[x+hws][y+hws]= (FM_FLOAT)gxy;
156 BIASCDOUT(D_HESSGAUSS_KERNEL,
"Filter xx:"<<Mxx);
158 sizeof(CONV_INT)*8-1);
161 _ConvXX.SetKernel(F);
163 BIASCDOUT(D_HESSGAUSS_KERNEL,
"Filter yy:"<<Myy);
166 sizeof(CONV_INT)*8-1);
169 _ConvYY.SetKernel(F2);
172 BIASCDOUT(D_HESSGAUSS_KERNEL,
"Filter xy:"<<Mxy);
174 sizeof(CONV_INT)*8-1);
177 _ConvXY.SetKernel(F3);
183 template <
class InputStorageType,
class OutputStorageType>
187 _ConvXX.GetBorders(border_x, border_y);
195 #define FILTER_INSTANTIATION_CLASS HessianGauss
196 #define FILTER_INSTANTIATION_NO_UNSIGNED_OUTPUT
197 #include "Filterinst.hh"
void Release()
reimplemented from ImageBase
void CreateIntFilter(int rshift, int rshifth, int rshiftv)
create the int filter from the float filter
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
unsigned int GetWidth() const
double _LastSigma
the parameters at the time of the last call
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
unsigned int GetHeight() const
double _HessGaussSigma
the parameters
int ComputeIntPrecisionBits(int NumberOfBitsInInputData, int NumberOfBitsInTempData)
compute the number of shiftable bits for int-from-float mask
bool SamePixelAndChannelCount(const ImageBase &Image) const
checks if data area has same "size" as Image of other type
virtual int Filter(const Image< InputStorageType > &src, Image< OutputStorageType > &hx, Image< OutputStorageType > &hy, Image< OutputStorageType > &hxy)
returns images containig hxx hyy and hxy
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
void _CalculateKernels(double Sigma, double Ratio)
Fills _HVec with gaussian function and _VVec with derivative of gaussian function with standard devia...
A filter mask (or a kernel) used for convolution.
gradient calculation with separated gauss masks
virtual void GetBordersValid_(int &border_x, int &border_y) const