Example of image denoising using tv_admm class.
#include <string>
#include <Eigen/Core>
#include <Eigen/SparseCore>
#include "image_denoising_common.h"
auto main(int argc, char** argv) -> int {
int sample_image_index = 1;
if (!initialize(argc, argv, sample_image_index)) {
return 1;
}
Eigen::MatrixXd origin;
if (!generate_sample_image(sample_image_index, origin)) {
return 1;
}
Eigen::MatrixXd data = origin;
const Eigen::VectorXd data_vec = data.reshaped<Eigen::ColMajor>();
using coeff_type = Eigen::SparseMatrix<double>;
coeff_type coeff;
coeff.resize(size, size);
coeff.setIdentity();
using derivative_matrix_type = Eigen::SparseMatrix<double>;
const auto derivative_matrix =
derivative_matrix_type>(cols, rows);
derivative_matrix_type, Eigen::VectorXd>;
solver_type solver;
solver.
compute(coeff, derivative_matrix, data_vec);
const auto& initial_solution = data_vec;
solver, data_vec, initial_solution};
Eigen::VectorXd solution_vec = initial_solution;
const Eigen::MatrixXd solution =
solution_vec.reshaped<Eigen::ColMajor>(rows, cols);
visualize_result(origin, data, solution, "TV Regularization", "tv_admm");
return 0;
}
Definition of add_noise function.
Class to search optimal regularization parameter using GCV.
void solve(data_type &solution) const
Solver with the optimal regularization parameter.
void search()
Search the optimal regularization parameter.
Class to solve linear equations with total variation (TV) regularization using the alternating direct...
void compute(const Coeff &coeff, const DerivativeMatrix &derivative_matrix, const Data &data)
Compute internal parameters.
Definition of implicit_gcv class.
Definition of index_type type.
std::ptrdiff_t index_type
Type of indices in this library.
auto sparse_diff_matrix_2d(num_collect::index_type outer_size, num_collect::index_type inner_size) -> Matrix
Create a sparse differential matrix in 2D.
void add_noise(Eigen::MatrixXd &data, double rate)
Add noise to data.
Definition of sparse_diff_matrix_2d function.
Definition of tv_admm class.