digiKam
Loading...
Searching...
No Matches
refocusmatrix.h
Go to the documentation of this file.
1/* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2005-04-29
7 * Description : refocus deconvolution matrix implementation.
8 *
9 * SPDX-FileCopyrightText: 2005-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 *
13 * ============================================================ */
14
15#pragma once
16
17// C ++ includes
18
19#ifndef Q_CC_MSVC
20# include <cstdio>
21#endif
22
23namespace Digikam
24{
25
34typedef struct
35{
39 int radius;
47 double* data;
51 double* center;
52}
53CMat;
54
55// ---------------------------------------------------------------------------------------------
56
64typedef struct
65{
69 int rows;
73 int cols;
77 double* data;
78}
79Mat;
80
81// ---------------------------------------------------------------------------------------------
82
84{
85
86public:
87
88 static void fill_matrix(CMat* const matrix, const int m, double f(const int, const int, const double), const double fun_arg);
89
90 static void fill_matrix2(CMat* const matrix, const int m,
91 double f(const int, const int, const double, const double),
92 const double fun_arg1, const double fun_arg2);
93
94 static void make_circle_convolution(const double radius, CMat* const convolution, const int m);
95
96 static void make_gaussian_convolution(const double alpha, CMat* const convolution, const int m);
97
98 static void convolve_star_mat(const CMat* const result, const CMat* const mata, const CMat* const matb);
99
100 static CMat* compute_g_matrix(const CMat* const convolution, const int m,
101 const double gamma, const double noise_factor,
102 const double musq, const bool symmetric);
103
104 static void finish_matrix(Mat* const mat);
105 static void finish_and_free_matrix(Mat* const mat);
106 static void init_c_mat(CMat* const mat, const int radius);
107 static void finish_c_mat(CMat* const mat);
108
109 static double mat_elt(const Mat* const mat, const int r, const int c);
110 static inline double c_mat_elt(const CMat* const mat, const int col, const int row);
111
112private:
113
114 static Mat* allocate_matrix(int nrows, int ncols);
115 static CMat* allocate_c_mat(const int radius);
116
117 static double* mat_eltptr(const Mat* const mat, const int r, const int c);
118
119 static inline double* c_mat_eltptr(const CMat* const mat, const int col, const int row);
120
121 static void convolve_mat(const CMat* const result, const CMat* const mata, const CMat* const matb);
122
123 static int as_idx(const int k, const int l, const int m);
124 static int as_cidx(const int k, const int l);
125
126 static Mat* make_s_matrix(const CMat* const mat, int m, double noise_factor);
127 static Mat* make_s_cmatrix(const CMat* const mat, int m, double noise_factor);
128
129 static double correlation(const int x, const int y, const double gamma, const double musq);
130
131 static Mat* copy_vec(const CMat* const mat, const int m);
132 static Mat* copy_cvec(const CMat* const mat, const int m);
133 static CMat* copy_cvec2mat(const Mat* const cvec, const int m);
134 static CMat* copy_vec2mat(const Mat* const cvec, const int m);
135 static CMat* compute_g(const CMat* const convolution, const int m, const double gamma,
136 const double noise_factor, const double musq, const bool symmetric);
137
138 static double circle_integral(const double x, const double radius);
139 static double circle_intensity(const int x, const int y, const double radius);
140};
141
142} // namespace Digikam
Definition refocusmatrix.h:84
static void init_c_mat(CMat *const mat, const int radius)
Definition refocusmatrix.cpp:148
static void convolve_star_mat(const CMat *const result, const CMat *const mata, const CMat *const matb)
Definition refocusmatrix.cpp:214
static void fill_matrix(CMat *const matrix, const int m, double f(const int, const int, const double), const double fun_arg)
Definition refocusmatrix.cpp:504
static double c_mat_elt(const CMat *const mat, const int col, const int row)
Definition refocusmatrix.cpp:179
static void finish_c_mat(CMat *const mat)
Definition refocusmatrix.cpp:166
static CMat * compute_g_matrix(const CMat *const convolution, const int m, const double gamma, const double noise_factor, const double musq, const bool symmetric)
Definition refocusmatrix.cpp:467
static void make_circle_convolution(const double radius, CMat *const convolution, const int m)
Definition refocusmatrix.cpp:671
static void fill_matrix2(CMat *const matrix, const int m, double f(const int, const int, const double, const double), const double fun_arg1, const double fun_arg2)
Definition refocusmatrix.cpp:520
static void finish_and_free_matrix(Mat *const mat)
Definition refocusmatrix.cpp:126
static void make_gaussian_convolution(const double alpha, CMat *const convolution, const int m)
Definition refocusmatrix.cpp:536
static void finish_matrix(Mat *const mat)
Definition refocusmatrix.cpp:121
static double mat_elt(const Mat *const mat, const int r, const int c)
Definition refocusmatrix.cpp:140
Definition datefolderview.cpp:34
Definition refocusmatrix.h:35
int radius
Definition refocusmatrix.h:39
int row_stride
Definition refocusmatrix.h:43
double * data
Definition refocusmatrix.h:47
double * center
Definition refocusmatrix.h:51
Definition refocusmatrix.h:65
int cols
Definition refocusmatrix.h:73
int rows
Definition refocusmatrix.h:69
double * data
Definition refocusmatrix.h:77