1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : filter to add Film Grain to image.
9
* Copyright (C) 2005-2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
10
* Copyright (C) 2005-2010 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
12
* This program is free software; you can redistribute it
13
* and/or modify it under the terms of the GNU General
14
* Public License as published by the Free Software Foundation;
15
* either version 2, or (at your option)
18
* This program is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU General Public License for more details.
23
* ============================================================ */
25
#ifndef FILMGRAINFILTER_H
26
#define FILMGRAINFILTER_H
30
#include "digikam_export.h"
31
#include "dimgthreadedfilter.h"
38
class FilmGrainFilterPriv;
40
class DIGIKAM_EXPORT FilmGrainContainer
48
photoDistribution = false;
50
addLuminanceNoise = true;
54
lumaHighlights = -100;
56
addChrominanceBlueNoise = false;
57
chromaBlueIntensity = 25;
58
chromaBlueShadows = -100;
59
chromaBlueMidtones = 0;
60
chromaBlueHighlights = -100;
62
addChrominanceRedNoise = false;
63
chromaRedIntensity = 25;
64
chromaRedShadows = -100;
65
chromaRedMidtones = 0;
66
chromaRedHighlights = -100;
69
~FilmGrainContainer(){};
73
return (addLuminanceNoise || addChrominanceBlueNoise || addChrominanceRedNoise);
79
bool photoDistribution;
81
bool addLuminanceNoise;
87
bool addChrominanceBlueNoise;
88
int chromaBlueIntensity;
89
int chromaBlueShadows;
90
int chromaBlueMidtones;
91
int chromaBlueHighlights;
93
bool addChrominanceRedNoise;
94
int chromaRedIntensity;
96
int chromaRedMidtones;
97
int chromaRedHighlights;
100
// -----------------------------------------------------------------------------------------------
102
class DIGIKAM_EXPORT FilmGrainFilter : public DImgThreadedFilter
107
explicit FilmGrainFilter(DImg* orgImage, QObject* parent=0, const FilmGrainContainer& settings=FilmGrainContainer());
108
// Constructor for slave mode: execute immediately in current thread with specified master filter
109
explicit FilmGrainFilter(DImgThreadedFilter* parentFilter, const DImg& orgImage, const DImg& destImage,
110
int progressBegin=0, int progressEnd=100,
111
const FilmGrainContainer& settings=FilmGrainContainer());
118
inline void computeNoiseSettings(const DColor& col,
119
double& luRange, double& luNoise,
120
double& cbRange, double& cbNoise,
121
double& crRange, double& crNoise);
122
inline double interpolate(int shadows, int midtones, int highlights, const DColor& col);
123
inline double randomizeUniform(double range);
124
inline double randomizeGauss(double sigma);
125
inline double randomizePoisson(double lambda);
126
inline void adjustYCbCr(DColor& col, double range, double nRand, int channel);
130
FilmGrainFilterPriv* const d;
133
} // namespace Digikam
135
#endif /* FILMGRAINFILTER_H */