18 #ifndef PIC_FILTERING_FILTER_DEMOSAIC_HPP 19 #define PIC_FILTERING_FILTER_DEMOSAIC_HPP 21 #include "../filtering/filter.hpp" 39 int height = imgIn->
height;
40 int width = imgIn->
width;
42 float *dataIn = imgIn->
data;
43 float *dataOut = imgOut->
data;
46 for(
int j = 0; j < height; j++) {
48 for(
int i = ((j + 1) % 2); i < width; i += 2) {
49 int current = tmp + i;
50 dataOut[current * 3 + 1] = dataIn[current];
56 for(
int k = 0; k < 2; k++) {
57 for(
int j = k; j < (height); j += 2) {
58 float tmpG, sum, Grad,
final;
62 for(
int i = k; i < (width); i += 2) {
69 int current = tmp + i;
81 Grad = dataIn[current] - sum * 0.25f;
83 final = tmpG + Grad * 0.5f;
85 dataOut[current * 3 + 1] =
CLAMPi(
final, 0.0
f, 1.0
f);
102 int shifter = sx + sy;
104 int height = imgIn->
height;
105 int width = imgIn->
width;
106 float *dataIn = imgIn->
data;
107 float *data = imgOut->
data;
111 for(j = sy; j < height; j += 2) {
112 for(i = sx; i < width; i += 2) {
113 int current = j * width + i;
114 data[current * 3 + shifter] = dataIn[current];
134 for(j = ssy; j < (height); j += 2) {
137 for(i = ssx; i < (width); i += 2) {
145 int current = j * width + i;
147 tmp = 5.0f * dataIn[current] +
158 data[current * 3 + shifter] =
CLAMPi(tmp, 0.0
f, 1.0
f);
174 for(j = ssy; j < (height); j += 2) {
177 for(i = ssx; i < (width); i += 2) {
185 int current = j * width + i;
187 tmp = 5.0f * dataIn[current] +
199 data[current * 3 + shifter] =
CLAMPi(tmp, 0.0
f, 1.0
f);
215 for(j = ssy; j < (height); j += 2) {
218 for(i = ssx; i < (width); i += 2) {
226 int current = j * width + i;
227 tmp = 6.0f * dataIn[current] +
237 data[current * 3 + shifter] =
CLAMPi(tmp, 0.0
f, 1.0
f);
262 width = imgIn[0]->width;
263 height = imgIn[0]->height;
265 frames = imgIn[0]->frames;
276 if(imgIn[0] == NULL) {
280 if((!imgIn[0]->isValid()) && (imgIn[0]->channels != 1)) {
void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)
OutputSize.
Definition: filter_demosaic.hpp:260
float * data
data is the main buffer where pixel values are stored.
Definition: image.hpp:91
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
Image * Process(ImageVec imgIn, Image *imgOut)
Filter::Process.
Definition: filter_demosaic.hpp:274
The Filter class.
Definition: filter.hpp:50
int getAddress(int x, int y)
getAddress calculates a memory address from (x, y)
Definition: image.hpp:650
The FilterDemosaic class.
Definition: filter_demosaic.hpp:28
The Image class stores an image as buffer of float.
Definition: image.hpp:60
static Image * execute(Image *imgIn, Image *imgOut)
execute
Definition: filter_demosaic.hpp:299
virtual void f(FilterFData *data)
f
Definition: filter_radial_basis_function.hpp:69
void LinearUpSamplingGCRB(Image *imgIn, Image *imgOut, int sx, int sy)
LinearUpSamplingGCRB this linearly upsamples Red and Blue channels.
Definition: filter_demosaic.hpp:98
#define CLAMPi(x, a, b)
Definition: math.hpp:81
PIC_INLINE ImageVec Single(Image *img)
Single creates an std::vector which contains img; this is for filters input.
Definition: image_vec.hpp:36
Definition: bilateral_separation.hpp:25
virtual Image * setupAux(ImageVec imgIn, Image *imgOut)
setupAux
Definition: filter.hpp:288
FilterDemosaic()
FilterDemosaic.
Definition: filter_demosaic.hpp:248
int width
Definition: image.hpp:80
int height
Definition: image.hpp:80
void LinearUpSamplingGCGreen(Image *imgIn, Image *imgOut)
LinearUpSamplingGCGreen this upsamples the green channel with gradient correction.
Definition: filter_demosaic.hpp:37