1 #ifndef vil_cartesian_differential_invariants_hxx_ 2 #define vil_cartesian_differential_invariants_hxx_ 17 # include <vcl_msvc_warnings.h> 22 template <
class S,
class T>
25 unsigned max_kernel_width )
29 unsigned filt_n=int(3*scale + 0.5)*2+1;
31 if (max_kernel_width!=0 && filt_n > max_kernel_width)
32 filt_n = (max_kernel_width | 1);
34 const std::ptrdiff_t filt_c=filt_n/2;
36 std::vector<double> filt_0(filt_n), filt_2(filt_n), filt_1(filt_n), filt_3(filt_n);
46 vil_convolve_1d(src, LX, &filt_0[filt_c], -filt_c, filt_c,
double(), bo, bo);
47 vil_convolve_1d(src, LXx, &filt_1[filt_c], -filt_c, filt_c,
double(), bo, bo);
48 vil_convolve_1d(src, LXxx, &filt_2[filt_c], -filt_c, filt_c,
double(), bo, bo);
49 vil_convolve_1d(src, LXxxx, &filt_3[filt_c], -filt_c, filt_c,
double(), bo, bo);
56 &filt_0[filt_c], -filt_c, filt_c,
double(), bo, bo);
58 &filt_1[filt_c], -filt_c, filt_c,
double(), bo, bo);
62 &filt_0[filt_c], -filt_c, filt_c,
double(), bo, bo);
64 &filt_1[filt_c], -filt_c, filt_c,
double(), bo, bo);
66 &filt_2[filt_c], -filt_c, filt_c,
double(), bo, bo);
70 &filt_0[filt_c], -filt_c, filt_c,
double(), bo, bo);
72 &filt_1[filt_c], -filt_c, filt_c,
double(), bo, bo);
74 &filt_2[filt_c], -filt_c, filt_c,
double(), bo, bo);
76 &filt_3[filt_c], -filt_c, filt_c,
double(), bo, bo);
79 for (
unsigned j=0;j<dest.
ni();++j)
81 for (
unsigned i=0;i<dest.
nj();++i)
85 dest(j,i,0)= Lx(i,j)*Lx(i,j)
90 dest(j,i,1)= Lxx(i,j)*Lx(i,j)*Lx(i,j)
91 +T(2)*Lx(i,j)*Lxy(i,j)*Ly(i,j)
92 +Lyy(i,j)*Ly(i,j)*Ly(i,j);
96 dest(j,i,2)= Lxx(i,j)*Ly(i,j)*Ly(i,j)
97 -T(2)*Lxy(i,j)*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j)
144 +Lyyy(i,j)*Ly(i,j)*Ly(i,j)*Ly(i,j)
145 +T(3)*Lxxy(i,j)*Lx(i,j)*Lx(i,j)*Ly(i,j)
146 +T(3)*Lxyy(i,j)*Lx(i,j)*Ly(i,j)*Ly(i,j);
153 template <
class S,
class T>
160 for (
unsigned p=0; p < src.
nplanes(); ++p)
167 assert(destplanes == check);
171 #undef VIL_CARTESIAN_DIFFERENTIAL_INVARIANTS_INSTANTIATE 172 #define VIL_CARTESIAN_DIFFERENTIAL_INVARIANTS_INSTANTIATE(S, T) \ 174 vil_cartesian_differential_invariants_3( const vil_image_view< S >& src, \ 175 vil_image_view< T >& dest, double, unsigned ) 177 #endif // vil_cartesian_differential_invariants_hxx_ void vil_gauss_filter_gen_ntap(double sd, unsigned diff, std::vector< double > &filter)
Generate an n-tap FIR filter from a Gaussian function.
Extend the signal to be constant beyond the boundary.
void vil_cartesian_differential_invariants_3(const vil_image_view< S > &src, vil_image_view< T > &dest, double scale, unsigned max_kernel_width=0)
Compute up to 3rd order C.d.i. of an image.
Concrete view of image data of type T held in memory.
void set_size(unsigned ni, unsigned nj) override
resize current planes to ni x nj.
vil_convolve_boundary_option
Available options for boundary behavior.
unsigned ni() const
Width.
unsigned nj() const
Height.
std::ptrdiff_t planestep() const
Add this to your pixel pointer to get pixel on next plane.
A base class reference-counting view of some image data.
Find Cartesian differential Invariants.
void vil_cartesian_differential_invariants_3_1plane(const vil_image_view< S > &src, vil_image_view< T > &dest, double scale, unsigned max_kernel_width)
Compute 1st, 2nd, and 3rd order C.d.i.s of an image.
vil_image_view< T > vil_plane(const vil_image_view< T > &im, unsigned p)
Return a view of im's plane p.
void vil_convolve_1d(const vil_image_view< srcT > &src_im, vil_image_view< destT > &dest_im, const kernelT *kernel, std::ptrdiff_t k_lo, std::ptrdiff_t k_hi, accumT ac, vil_convolve_boundary_option start_option, vil_convolve_boundary_option end_option)
Convolve kernel[i] (i in [k_lo,k_hi]) with srcT in i-direction.
unsigned nplanes() const
Number of planes.
vil_image_view< T > vil_planes(const vil_image_view< T > &im, unsigned first, int skip, unsigned n)
Return a view of a selection of im's planes.
1D Convolution with cunning boundary options
vil_image_view< T > vil_transpose(const vil_image_view< T > &v)
Create a view which appears as the transpose of this view.