1 #ifndef vil_exp_grad_filter_1d_h_ 2 #define vil_exp_grad_filter_1d_h_ 15 template <
class srcT,
class destT,
class accumT>
17 destT* dest, std::ptrdiff_t dstep,
21 const srcT* src_end = src + (n-1)*sstep;
24 dest[0]=0; dest+=dstep;
28 accumT rt= -1*(accumT) *s; s+=sstep;
29 accumT k_sum=(accumT) 1;
33 *dest = (destT)(rt/k_sum);
35 rt -= *s; k_sum += 1.0f;
36 s+=sstep; dest+=dstep;
40 dest[0]=0; dest-=dstep;
41 rt= (accumT) *s; s-=sstep;
46 *dest += (destT)(rt/k_sum);
48 rt += *s; k_sum += 1.0f;
49 s-=sstep; dest-=dstep;
57 template <
class srcT,
class destT,
class accumT>
62 unsigned ni = src_im.
ni();
63 unsigned nj = src_im.
nj();
65 std::ptrdiff_t s_istep = src_im.
istep(), s_jstep = src_im.
jstep();
66 std::ptrdiff_t d_istep = dest_im.
istep(),d_jstep = dest_im.
jstep();
68 for (
unsigned p=0;p<src_im.
nplanes();++p)
73 for (
unsigned j=0;j<nj;++j,src_row+=s_jstep,dest_row+=d_jstep)
82 template <
class srcT,
class destT,
class accumT>
87 unsigned ni = src_im.
ni();
88 unsigned nj = src_im.
nj();
90 std::ptrdiff_t s_istep = src_im.
istep(), s_jstep = src_im.
jstep();
91 std::ptrdiff_t d_istep = dest_im.
istep(),d_jstep = dest_im.
jstep();
93 for (
unsigned p=0;p<src_im.
nplanes();++p)
98 for (
unsigned i=0;i<ni;++i,src_col+=s_istep,dest_col+=d_istep)
103 #endif // vil_exp_grad_filter_1d_h_ void vil_exp_grad_filter_1d(const srcT *src, std::ptrdiff_t sstep, destT *dest, std::ptrdiff_t dstep, int n, accumT k)
Apply exponential gradient filter to 1D data. Form: sign(i)*exp(c*|i|).
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.
std::ptrdiff_t jstep() const
Add this to your pixel pointer to get next j pixel.
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.
void vil_exp_grad_filter_j(const vil_image_view< srcT > &src_im, vil_image_view< destT > &dest_im, accumT k)
Apply exponential gradient filter to src_im (along j direction).
A base class reference-counting view of some image data.
void vil_exp_grad_filter_i(const vil_image_view< srcT > &src_im, vil_image_view< destT > &dest_im, accumT k)
Apply exponential gradient filter to src_im (along i direction).
T * top_left_ptr()
Pointer to the first (top left in plane 0) pixel.
unsigned nplanes() const
Number of planes.
std::ptrdiff_t istep() const
Add this to your pixel pointer to get next i pixel.