[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/graphics/digikam/libs
From: Gilles Caulier <caulier.gilles () gmail ! com>
Date: 2009-12-01 9:43:58
Message-ID: 1259660638.803814.25780.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1056933 by cgilles:
Apply patch from Jens Mueller about to adapt histogram scale when image is over/under \
exposed. Sound like a good way to display a suitable histogram in this situation
BUGS: 144155
M +8 -7 histogram/imagehistogram.cpp
M +1 -1 histogram/imagehistogram.h
M +52 -22 widgets/common/histogrampainter.cpp
--- trunk/extragear/graphics/digikam/libs/histogram/imagehistogram.cpp \
#1056932:1056933 @@ -510,42 +510,43 @@
return value;
}
-double ImageHistogram::getMaximum(int channel)
+double ImageHistogram::getMaximum(int channel, int start, int end)
{
double max = 0.0;
int x;
- if ( !d->histogram )
+ if ( !d->histogram || start < 0 ||
+ end > d->histoSegments-1 || start > end )
return 0.0;
switch(channel)
{
case LuminosityChannel:
- for (x = 0 ; x < d->histoSegments ; ++x)
+ for (x = start ; x < end ; ++x)
if (d->histogram[x].value > max)
max = d->histogram[x].value;
break;
case RedChannel:
- for (x = 0 ; x < d->histoSegments ; ++x)
+ for (x = start ; x < end ; ++x)
if (d->histogram[x].red > max)
max = d->histogram[x].red;
break;
case GreenChannel:
- for (x = 0 ; x < d->histoSegments ; ++x)
+ for (x = start ; x < end ; ++x)
if (d->histogram[x].green > max)
max = d->histogram[x].green;
break;
case BlueChannel:
- for (x = 0 ; x < d->histoSegments ; ++x)
+ for (x = start ; x < end ; ++x)
if (d->histogram[x].blue > max)
max = d->histogram[x].blue;
break;
case AlphaChannel:
- for (x = 0 ; x < d->histoSegments ; ++x)
+ for (x = start ; x < end ; ++x)
if (d->histogram[x].alpha > max)
max = d->histogram[x].alpha;
break;
--- trunk/extragear/graphics/digikam/libs/histogram/imagehistogram.h #1056932:1056933
@@ -68,7 +68,7 @@
double getPixels();
double getStdDev(int channel, int start, int end);
double getValue(int channel, int bin);
- double getMaximum(int channel);
+ double getMaximum(int channel, int start, int end);
int getHistogramSegments(void);
int getMaxSegmentIndex(void);
--- trunk/extragear/graphics/digikam/libs/widgets/common/histogrampainter.cpp \
#1056932:1056933 @@ -35,6 +35,10 @@
#include "kdebug.h"
#include "klocale.h"
+#define HISTOGRAM_CALC_CUTOFF_MIN 0.1
+#define HISTOGRAM_CALC_CUTOFF_MAX 0.9
+#define HISTOGRAM_CALC_CUTOFF_HEIGHT 0.8
+
namespace Digikam
{
@@ -64,32 +68,59 @@
double calculateMax()
{
+ int segments = histogram->getHistogramSegments();
+ int startSeg = HISTOGRAM_CALC_CUTOFF_MIN * (segments-1);
+ int endSeg = HISTOGRAM_CALC_CUTOFF_MAX * (segments-1);
double max = 0.0;
- switch (channelType)
- {
- case GreenChannel:
- case BlueChannel:
- case RedChannel:
- case AlphaChannel:
- case LuminosityChannel:
- max = histogram->getMaximum(channelType);
- break;
- case ColorChannels:
- max = qMax(qMax(histogram->getMaximum(RedChannel),
- histogram->getMaximum(GreenChannel)),
- histogram->getMaximum(BlueChannel));
- break;
- default:
- kError() << "Untreated channel type " << channelType << ". Using \
luminosity as default.";
- max = histogram->getMaximum(LuminosityChannel);
- break;
- }
switch (scale)
{
case LinScaleHistogram:
+ switch (channelType)
+ {
+ case GreenChannel:
+ case BlueChannel:
+ case RedChannel:
+ case AlphaChannel:
+ case LuminosityChannel:
+ max = qMin(histogram->getMaximum(channelType, startSeg, \
endSeg) / HISTOGRAM_CALC_CUTOFF_HEIGHT, + \
histogram->getMaximum(channelType, 0, segments - 1)); + break;
+ case ColorChannels:
+ max = qMin(qMax(qMax(histogram->getMaximum(RedChannel, \
startSeg, endSeg), + \
histogram->getMaximum(GreenChannel, startSeg, endSeg)), + \
histogram->getMaximum(BlueChannel, startSeg, endSeg)) / HISTOGRAM_CALC_CUTOFF_HEIGHT, \
+ qMax(qMax(histogram->getMaximum(RedChannel, 0, \
segments - 1), + \
histogram->getMaximum(GreenChannel, 0, segments - 1)), + \
histogram->getMaximum(BlueChannel, 0, segments - 1))); + \
break; + default:
+ kError() << "Untreated channel type " << channelType << ". \
Using luminosity as default."; + max = \
qMin(histogram->getMaximum(LuminosityChannel, startSeg, endSeg) / \
HISTOGRAM_CALC_CUTOFF_HEIGHT, + \
histogram->getMaximum(LuminosityChannel, 0, segments - 1)); + \
break; + }
break;
case LogScaleHistogram:
+ switch (channelType)
+ {
+ case GreenChannel:
+ case BlueChannel:
+ case RedChannel:
+ case AlphaChannel:
+ case LuminosityChannel:
+ max = histogram->getMaximum(channelType, 0, segments - 1);
+ break;
+ case ColorChannels:
+ max = qMax(qMax(histogram->getMaximum(RedChannel, 0, \
segments - 1), + \
histogram->getMaximum(GreenChannel, 0, segments - 1)), + \
histogram->getMaximum(BlueChannel, 0, segments - 1)); + break;
+ default:
+ kError() << "Untreated channel type " << channelType << ". \
Using luminosity as default."; + max = \
histogram->getMaximum(LuminosityChannel, 0, segments - 1); + \
break; + }
if (max > 0.0)
{
max = log(max);
@@ -105,7 +136,6 @@
}
return max;
-
}
void calculateSegmentMaxSingleColor(double& maxValue, const int& startSegment, \
const int& endSegment) @@ -208,7 +238,7 @@
p1.save();
int wWidth = bufferPixmap.width();
int wHeight = bufferPixmap.height();
- double max = calculateMax();
+ double max = 1.05 * calculateMax();
QPainterPath curvePath;
curvePath.moveTo(0, wHeight);
@@ -259,7 +289,7 @@
p2.begin(&bb);
p2.initFrom(widgetToInitFrom);
- double max = calculateMax();
+ double max = 1.05 * calculateMax();
QPainterPath curveRed, curveGreen, curveBlue;
curveRed.moveTo(0, wHeight);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic