~ubuntu-branches/ubuntu/intrepid/digikam/intrepid

« back to all changes in this revision

Viewing changes to digikam/imageplugins/coreplugin/sharpnesseditor/matrix.h

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-07-17 20:25:39 UTC
  • mfrom: (1.3.2 upstream) (37 hardy)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: james.westby@ubuntu.com-20080717202539-1bw3w3nrsso7yj4z
* New upstream release
  - digiKam 0.9.4 Release Plan (KDE3) ~ 13 July 08 (Closes: #490144)
* DEB_CONFIGURE_EXTRA_FLAGS := --without-included-sqlite3
* Debhelper compatibility level V7
* Install pixmaps in debian/*.install
* Add debian/digikam.lintian-overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 *
 
3
 * This file is a part of digiKam project
 
4
 * http://www.digikam.org
 
5
 *
 
6
 * Date        : 2005-04-29
 
7
 * Description : refocus deconvolution matrix implementation.
 
8
 *
 
9
 * Copyright (C) 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
10
 *
 
11
 * This program is free software; you can redistribute it
 
12
 * and/or modify it under the terms of the GNU General
 
13
 * Public License as published by the Free Software Foundation;
 
14
 * either version 2, or (at your option)
 
15
 * any later version.
 
16
 * 
 
17
 * This program is distributed in the hope that it will be useful,
 
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
 * GNU General Public License for more details.
 
21
 * 
 
22
 * ============================================================ */
 
23
 
 
24
#ifndef MATRIX_H_INCLUDED
 
25
#define MATRIX_H_INCLUDED
 
26
 
 
27
// C ++ includes.
 
28
 
 
29
#include <cstdio>
 
30
 
 
31
namespace DigikamImagesPluginCore
 
32
{
 
33
    
 
34
/**
 
35
* CMat:
 
36
* @radius: Radius of the matrix.
 
37
*
 
38
* Centered matrix. This is a square matrix where
 
39
* the indices range from [-radius, radius].
 
40
* The matrix contains (2 * radius + 1) ** 2 elements.
 
41
*
 
42
**/
 
43
typedef struct
 
44
{
 
45
    int     radius;                // Radius of the matrix 
 
46
    int     row_stride;            // Size of one row = 2 * radius + 1 
 
47
    double *data;                  // Contents of matrix 
 
48
    double *center;                // Points to element with index (0, 0) 
 
49
}
 
50
CMat;
 
51
 
 
52
/**
 
53
* Mat:
 
54
* @rows: Number of rows in the matrix.
 
55
*
 
56
* Normal matrix type. Indices range from
 
57
* [0, rows -1 ] and [0, cols - 1].
 
58
*
 
59
**/
 
60
typedef struct
 
61
{
 
62
    int     rows;                  // Number of rows in the matrix 
 
63
    int     cols;                  // Number of columns in the matrix 
 
64
    double *data;                  // Content of the matrix 
 
65
}
 
66
Mat;
 
67
 
 
68
class RefocusMatrix
 
69
{
 
70
 
 
71
public: 
 
72
 
 
73
    static void fill_matrix (CMat * matrix, const int m, double f (int, int, double), const double fun_arg);
 
74
    
 
75
    static void fill_matrix2 (CMat * matrix, const int m, 
 
76
                              double f (const int, const int, const double, const double), 
 
77
                              const double fun_arg1, const double fun_arg2);
 
78
    
 
79
    static void make_circle_convolution (const double radius, CMat *convolution, const int m);
 
80
    
 
81
    static void make_gaussian_convolution (const double alpha, CMat *convolution, const int m);
 
82
    
 
83
    static void convolve_star_mat (CMat *result, const CMat *const mata, const CMat* const matb);
 
84
    
 
85
    static CMat *compute_g_matrix (const CMat * const convolution, const int m,
 
86
                                   const double gamma, const double noise_factor,
 
87
                                   const double musq, const bool symmetric);
 
88
    
 
89
    static void finish_matrix (Mat * mat);
 
90
    static void finish_and_free_matrix (Mat * mat);
 
91
    static void init_c_mat (CMat * mat, const int radius);
 
92
    static void finish_c_mat (CMat * mat);
 
93
 
 
94
private:
 
95
 
 
96
    // Debug methods.
 
97
    static void print_c_mat (const CMat * const mat);
 
98
    static void print_matrix (Mat * matrix);
 
99
 
 
100
    static Mat *allocate_matrix (int nrows, int ncols);
 
101
    static double *mat_eltptr (Mat * mat, const int r, const int c);
 
102
    static double mat_elt (const Mat * mat, const int r, const int c);
 
103
    static CMat *allocate_c_mat (const int radius);
 
104
    static inline double *c_mat_eltptr (CMat * mat, const int col, const int row);
 
105
    static inline double c_mat_elt (const CMat * const mat, const int col, const int row);
 
106
    static void convolve_mat (CMat * result, const CMat * const mata, const CMat * const matb);
 
107
    static void convolve_mat_fun (CMat * result, const CMat * const mata, double (f) (int, int));
 
108
    static int as_idx (const int k, const int l, const int m);
 
109
    static int as_cidx (const int k, const int l);
 
110
    static Mat *make_s_matrix (CMat * mat, int m, double noise_factor);
 
111
    static Mat *make_s_cmatrix (CMat * mat, int m, double noise_factor);
 
112
    static double correlation (const int x, const int y, const double gamma, const double musq);
 
113
    static Mat *copy_vec (const CMat * const mat, const int m);
 
114
    static Mat *copy_cvec (const CMat * const mat, const int m);
 
115
    static CMat *copy_cvec2mat (const Mat * const cvec, const int m);
 
116
    static CMat *copy_vec2mat (const Mat * const cvec, const int m);
 
117
    static CMat *compute_g (const CMat * const convolution, const int m, const double gamma,
 
118
                                           const double noise_factor, const double musq, const bool symmetric);
 
119
    static double circle_integral (const double x, const double radius);
 
120
    static double circle_intensity (const int x, const int y, const double radius);               
 
121
    
 
122
    // CLapack interface.
 
123
    static int dgesv (const int N, const int NRHS, double *A, const int lda, double *B, const int ldb);
 
124
 
 
125
};
 
126
            
 
127
}  // NameSpace DigikamImagesPluginCore
 
128
 
 
129
#endif /* MATRIX_H_INCLUDED */