1 #ifndef SOPT_GRADIENT_OPERATOR_H
2 #define SOPT_GRADIENT_OPERATOR_H
4 #include "sopt/config.h"
14 output.segment(0, x.size() - 1) = x.segment(1, x.size() - 1) - x.segment(0, x.size() - 1);
21 output.segment(0, x.size() - 1) -= x.segment(0, x.size() - 1);
22 if (output.size() > 2) output.segment(1, x.size() - 1) = x.segment(0, x.size() - 1);
30 for (Eigen::Index i(0); i <
rows; i++)
31 output.block(0, 0,
rows,
cols).row(i) = diff<T>(input_image.row(i));
32 for (Eigen::Index i(0); i <
cols; i++)
33 output.block(0,
cols,
rows,
cols).col(i) = diff<T>(input_image.col(i));
41 for (Eigen::Index i(0); i <
rows; i++)
42 output.row(i) += diff_adjoint<T>(input_image.block(0, 0,
rows,
cols).row(i));
43 for (Eigen::Index i(0); i <
cols; i++)
44 output.col(i) += diff_adjoint<T>(input_image.block(0,
cols,
rows,
cols).col(i));
59 assert(out.size() == 2 *
rows *
cols);
Vector< T > diff2d(const Vector< T > &x, const t_int rows, const t_int cols)
Numerical derivative of 2d image.
Vector< T > diff_adjoint(const Vector< T > &x)
Numerical derivative adjoint of 1d vector.
Vector< T > diff(const Vector< T > &x)
Numerical derivative of 1d vector.
LinearTransform< Vector< T > > gradient_operator(const t_int rows, const t_int cols)
Vector< T > diff2d_adjoint(const Vector< T > &x, const t_int rows, const t_int cols)
Numerical derivative adjoint of 2d image.
int t_int
Root of the type hierarchy for signed integers.
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector of a given type.
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > Matrix
A matrix of a given type.