-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlibdemosaic.h
193 lines (159 loc) · 4.27 KB
/
libdemosaic.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*
* Copyright (c) 2015, Gene Selkov <selkovjr@gmail.com>
*/
/*
* Portions copyright (c) 2009-2011, A. Buades <toni.buades@uib.es>
* All rights reserved.
*/
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef _LIBDEMOSAIC_H_
#define _LIBDEMOSAIC_H_
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "libAuxiliary.h"
/**
* @file libdemosaic.cpp
* @brief Demosaicking functions: HAmilton-Adams algorithm, NLmeans based demosaicking, Chromatic components filtering
*
*
*
* @author Antoni Buades <toni.buades@uib.es>
*/
/**
* \brief Classical Adams-Hamilton demosaicking algorithm
*
* The green channel is interpolated directionally depending on the green first and red and blue second directional derivatives.
* The red and blue differences with the green channel are interpolated bilinearly.
*
* @param[in] ired, igreen, iblue original cfa image
* @param[out] ored, ogreen, oblue demosaicked output
* @param[in] threshold value to consider horizontal and vertical variations equivalent and average both estimates
* @param[in] width, height size of the image
*
*/
void g_directional(
float threshold,
float *ired,
float *igreen,
float *iblue,
float *ored,
float *ogreen,
float *oblue,
int width,
int height,
int origWidth,
int origHeight,
unsigned char* mask
);
/**
* \brief Classical bilinear interpolation of red and blue differences with the green channel
*
*
* @param[in] ored, ogreen, oblue original cfa image with green interpolated
* @param[out] ored, ogreen, oblue demosaicked output
* @param[in] width, height size of the image
*
*/
void bilinear_red_blue(
float *ored,
float *ogreen,
float *oblue,
int width,
int height,
int origWidth,
int origHeight,
unsigned char* mask
);
/**
* \brief NLmeans based demosaicking
*
* For each value to be filled, a weigthed average of original CFA values of the same channel is performed.
* The weight depends on the difference of a 3x3 color patch
*
* @param[in] ired, igreen, iblue initial demosaicked image
* @param[out] ored, ogreen, oblue demosaicked output
* @param[in] bloc research block of size (2+bloc+1) x (2*bloc+1)
* @param[in] h kernel bandwidth
* @param[in] width, height size of the image
*
*/
void demosaic_nlmeans(
int bloc,
float h,
float *ored,
float *ogreen,
float *oblue,
float *ired,
float *igreen,
float *iblue,
int width,
int height,
int origWidth,
int origHeight,
unsigned char* mask
);
/**
* \brief Iterate median filter on chromatic components of the image
*
*
* @param[in] ired, igreen, iblue initial image
* @param[in] iter number of iteracions
* @param[out] ored, ogreen, oblue filtered output
* @param[in] side median in a (2*side+1) x (2*side+1) window
* @param[in] projflag if not zero, values of the original CFA are kept
* @param[in] width, height size of the image
*
*/
void chromatic_median(int iter,int ,int projflag,float side,float *ired,float *igreen, float *iblue,float *ored,float *ogreen,float *oblue,int width,int height);
/**
* \brief Demosaicking chain
*
*
*
* Compute initialization by Adams-Hamilton algorithm (u0)
*
* for h in {16,4,1} do
* {
*
* u <- NL_h(u0); Apply NLmeans demosaicking
*
* u <- CR(u); Apply chromatic regularization
*
* u0 <- u;
*
* }
*
* Output <- u;
*
*
* @param[in] ired, igreen, iblue initial image
* @param[out] ored, ogreen, oblue filtered output
* @param[in] width, height size of the image
*
*/
void ssdd_demosaic_chain(
float *ired,
float *igreen,
float *iblue,
float *ored,
float *ogreen,
float *oblue,
int width,
int height,
int origWidth,
int origHeight,
unsigned char* mask
);
#endif