[Digikam-devel] extragear/graphics
Gilles Caulier
caulier.gilles at kdemail.net
Tue Jan 16 14:40:59 GMT 2007
SVN commit 624140 by cgilles:
digiKam from trunk : Color Auto-Correction tool : add new filter to perform auto-exposure correction
CCMAIL: digikam-devel at kde.org
M +2 -2 digikam/data/pics/Makefile.am
D digikam/data/pics/autolevels.png
D digikam/data/pics/equalize.png
D digikam/data/pics/normalize.png
D digikam/data/pics/stretchcontrast.png
M +1 -0 digikam/imageplugins/Makefile.am
M +46 -32 digikam/imageplugins/imageeffect_autocorrection.cpp
M +2 -2 digikam/imageplugins/imageeffect_autocorrection.h
M +4 -3 digikam/libs/whitebalance/whitebalance.cpp
M +3 -2 digikam/libs/whitebalance/whitebalance.h
M +6 -4 digikamimageplugins/whitebalance/imageeffect_whitebalance.cpp
--- trunk/extragear/graphics/digikam/data/pics/Makefile.am #624139:624140
@@ -3,8 +3,8 @@
histogram-lin.png histogram-log.png \
logo-digikam.png logo-gphoto.png logo-lcms.png logo-exiv2.png \
browntone.png coldtone.png neutralbw.png platinum.png selenium.png sepia.png \
- bwgreen.png bwred.png bwyellow.png bworange.png autolevels.png normalize.png \
- equalize.png stretchcontrast.png centerwidth.png centerheight.png target.png \
+ bwgreen.png bwred.png bwyellow.png bworange.png \
+ centerwidth.png centerheight.png target.png \
bothvert.png bothhorz.png curvefree.png curvemooth.png original.png \
duplicatebothvert.png duplicatebothhorz.png togglemouseover.png \
zoom10.png zoom15.png zoom20.png zoom25.png zoom30.png \
--- trunk/extragear/graphics/digikam/imageplugins/Makefile.am #624139:624140
@@ -5,6 +5,7 @@
-I$(top_srcdir)/digikam/libs/histogram \
-I$(top_srcdir)/digikam/libs/levels \
-I$(top_srcdir)/digikam/libs/curves \
+ -I$(top_srcdir)/digikam/libs/whitebalance \
-I$(top_srcdir)/digikam/libs/widgets/common \
-I$(top_srcdir)/digikam/libs/widgets/iccprofiles \
-I$(top_srcdir)/digikam/libs/widgets/imageplugins \
--- trunk/extragear/graphics/digikam/imageplugins/imageeffect_autocorrection.cpp #624139:624140
@@ -43,9 +43,9 @@
// KDE includes.
#include <kcursor.h>
+#include <kstandarddirs.h>
#include <kconfig.h>
#include <klocale.h>
-#include <kstandarddirs.h>
#include <kapplication.h>
// Digikam includes.
@@ -55,6 +55,7 @@
#include "histogramwidget.h"
#include "colorgradientwidget.h"
#include "dimgimagefilters.h"
+#include "whitebalance.h"
#include "dimg.h"
#include "listboxpreviewitem.h"
@@ -157,29 +158,27 @@
Digikam::ListBoxWhatsThis* whatsThis = new Digikam::ListBoxWhatsThis(m_correctionTools);
QPixmap pix = getThumbnailForEffect(AutoLevelsCorrection);
-
Digikam::ListBoxPreviewItem *item = new Digikam::ListBoxPreviewItem(pix, i18n("Auto Levels"));
-
- whatsThis->add( item, i18n("<img source=\"%1\"> <b>Auto Levels</b>:"
+ whatsThis->add( item, i18n("<b>Auto Levels</b>:"
"<p>This option maximizes the tonal range in the Red, "
"Green, and Blue channels. It searches the image shadow and highlight "
"limit values and adjusts the Red, Green, and Blue channels "
- "to a full histogram range.</p>").arg(previewEffectPic("autolevels")));
+ "to a full histogram range.</p>"));
m_correctionTools->insertItem(item, AutoLevelsCorrection);
pix = getThumbnailForEffect(NormalizeCorrection);
item = new Digikam::ListBoxPreviewItem(pix, i18n("Normalize"));
- whatsThis->add( item, i18n("<img source=\"%1\"> <b>Normalize</b>:"
+ whatsThis->add( item, i18n("<b>Normalize</b>:"
"<p>This option scales brightness values across the active "
"image so that the darkest point becomes black, and the "
"brightest point becomes as bright as possible without "
"altering its hue. This is often a \"magic fix\" for "
- "images that are dim or washed out.</p>").arg(previewEffectPic("normalize")));
+ "images that are dim or washed out.</p>"));
m_correctionTools->insertItem(item, NormalizeCorrection);
pix = getThumbnailForEffect(EqualizeCorrection);
item = new Digikam::ListBoxPreviewItem(pix, i18n("Equalize"));
- whatsThis->add( item, i18n("<img source=\"%1\"> <b>Equalize</b>:"
+ whatsThis->add( item, i18n("<b>Equalize</b>:"
"<p>This option adjusts the brightness of colors across the "
"active image so that the histogram for the value channel "
"is as nearly as possible flat, that is, so that each possible "
@@ -187,18 +186,27 @@
"as each other value. Sometimes Equalize works wonderfully at "
"enhancing the contrasts in an image. Other times it gives "
"garbage. It is a very powerful operation, which can either work "
- "miracles on an image or destroy it.</p>").arg(previewEffectPic("equalize")));
+ "miracles on an image or destroy it.</p>"));
m_correctionTools->insertItem(item, EqualizeCorrection);
pix = getThumbnailForEffect(StretchContrastCorrection);
item = new Digikam::ListBoxPreviewItem(pix, i18n("Stretch Contrast"));
- whatsThis->add( item, i18n("<img source=\"%1\"> <b>Stretch Contrast</b>:"
+ whatsThis->add( item, i18n("<b>Stretch Contrast</b>:"
"<p>This option enhances the contrast and brightness "
"of the RGB values of an image by stretching the lowest "
"and highest values to their fullest range, adjusting "
- "everything in between.</p>").arg(previewEffectPic("stretchcontrast")));
+ "everything in between.</p>"));
m_correctionTools->insertItem(item, StretchContrastCorrection);
+ pix = getThumbnailForEffect(StretchContrastCorrection);
+ item = new Digikam::ListBoxPreviewItem(pix, i18n("Auto Exposure"));
+ whatsThis->add( item, i18n("<b>Auto Exposure</b>:"
+ "<p>This option enhances the contrast and brightness "
+ "of the RGB values of an image to calculate optimal "
+ "exposition and black level using image histogram "
+ "properties.</p>"));
+ m_correctionTools->insertItem(item, AutoExposureCorrection);
+
// -------------------------------------------------------------
m_correctionTools->setFocus();
@@ -274,12 +282,6 @@
m_histogramWidget->setHistogramGuideByColor(color);
}
-QString ImageEffect_AutoCorrection::previewEffectPic(QString name)
-{
- KGlobal::dirs()->addResourceType(name.ascii(), KGlobal::dirs()->kde_default("data") + "digikam/data");
- return ( KGlobal::dirs()->findResourceDir(name.ascii(), name + ".png") + name + ".png" );
-}
-
void ImageEffect_AutoCorrection::readUserSettings()
{
KConfig* config = kapp->config();
@@ -373,6 +375,10 @@
case StretchContrastCorrection:
name = i18n("Stretch Contrast");
break;
+
+ case AutoExposureCorrection:
+ name = i18n("Auto Exposure");
+ break;
}
iface->putOriginalImage(name, data);
@@ -389,21 +395,29 @@
switch (type)
{
- case AutoLevelsCorrection:
- filter.autoLevelsCorrectionImage(data, w, h, sb);
- break;
-
- case NormalizeCorrection:
- filter.normalizeImage(data, w, h, sb);
- break;
-
- case EqualizeCorrection:
- filter.equalizeImage(data, w, h, sb);
- break;
-
- case StretchContrastCorrection:
- filter.stretchContrastImage(data, w, h, sb);
- break;
+ case AutoLevelsCorrection:
+ filter.autoLevelsCorrectionImage(data, w, h, sb);
+ break;
+
+ case NormalizeCorrection:
+ filter.normalizeImage(data, w, h, sb);
+ break;
+
+ case EqualizeCorrection:
+ filter.equalizeImage(data, w, h, sb);
+ break;
+
+ case StretchContrastCorrection:
+ filter.stretchContrastImage(data, w, h, sb);
+ break;
+
+ case AutoExposureCorrection:
+ Digikam::WhiteBalance wbFilter(sb);
+ double blackLevel;
+ double exposureLevel;
+ wbFilter.autoExposureAdjustement(data, w, h, sb, blackLevel, exposureLevel);
+ wbFilter.whiteBalance(data, w, h, sb, blackLevel, exposureLevel);
+ break;
}
}
--- trunk/extragear/graphics/digikam/imageplugins/imageeffect_autocorrection.h #624139:624140
@@ -73,7 +73,8 @@
AutoLevelsCorrection=0,
NormalizeCorrection,
EqualizeCorrection,
- StretchContrastCorrection
+ StretchContrastCorrection,
+ AutoExposureCorrection
};
enum HistogramScale
@@ -113,7 +114,6 @@
void resetValues();
void autoCorrection(uchar *data, int w, int h, bool sb, int type);
- QString previewEffectPic(QString name);
QPixmap getThumbnailForEffect(AutoCorrectionType type);
};
--- trunk/extragear/graphics/digikam/libs/whitebalance/whitebalance.cpp #624139:624140
@@ -106,16 +106,17 @@
}
void WhiteBalance::whiteBalance(uchar *data, int width, int height, bool sixteenBit,
- double temperature, double dark, double black, double exposition,
- double gamma, double saturation, double green)
+ double black, double exposition,
+ double temperature, double green, double dark,
+ double gamma, double saturation)
{
d->temperature = temperature;
+ d->green = green;
d->dark = dark;
d->black = black;
d->exposition = exposition;
d->gamma = gamma;
d->saturation = saturation;
- d->green = green;
// Set final lut.
setRGBmult();
--- trunk/extragear/graphics/digikam/libs/whitebalance/whitebalance.h #624139:624140
@@ -41,8 +41,9 @@
~WhiteBalance();
void whiteBalance(uchar *data, int width, int height, bool sixteenBit,
- double temperature, double dark, double black, double exposition,
- double gamma, double saturation, double green);
+ double black=0.0, double exposition=0.0,
+ double temperature=4.750, double green=1.2, double dark=0.5,
+ double gamma=1.0, double saturation=1.0);
static void autoExposureAdjustement(uchar* data, int width, int height, bool sb,
double &black, double &expo);
--- trunk/extragear/graphics/digikamimageplugins/whitebalance/imageeffect_whitebalance.cpp #624139:624140
@@ -555,8 +555,9 @@
Digikam::WhiteBalance wbFilter(sb);
wbFilter.whiteBalance(data, w, h, sb,
- temperature, dark, black, exposition,
- gamma, saturation, green);
+ black, exposition,
+ temperature, green, dark,
+ gamma, saturation);
iface->putPreviewImage(data);
m_previewWidget->updatePreview();
@@ -586,8 +587,9 @@
Digikam::WhiteBalance wbFilter(sb);
wbFilter.whiteBalance(data, w, h, sb,
- temperature, dark, black, exposition,
- gamma, saturation, green);
+ black, exposition,
+ temperature, green, dark,
+ gamma, saturation);
iface->putOriginalImage(i18n("White Balance"), data);
delete [] data;
More information about the Digikam-devel
mailing list