本文整理汇总了C++中magick::Image::gamma方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::gamma方法的具体用法?C++ Image::gamma怎么用?C++ Image::gamma使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类magick::Image
的用法示例。
在下文中一共展示了Image::gamma方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onInput
void AdjustLuminance::onInput(InputImageInfo info, Magick::Image img) {
std::vector<std::pair < Magick::Color, size_t>> histogram;
Magick::colorHistogram(&histogram, img);
Magick::Image original = img;
/* gamma correction rules:
* http://www.imagemagick.org/Usage/transform/#evaluate_pow
*
* updatedColor = color ^ (1 / gamma)
* gamma = 1 / log(color, updatedColor)
* gamma = 1 / (log(updatedColor) / log(color))
*
* We can't compute gamma just from current and target luminance,
* but we can estimate it.
*
* We can compute expected luminance after gamma
* correction from image histogram, it is relatively fast.
* So we iterate gamma estimation ten times. Results are relatively good.
*/
double gamma = 1.0;
double targetLuminance = info.luminanceChange + info.luminance;
double expectedLuminance = info.luminance;
for (int iteration = 0; iteration < 10; iteration++) {
gamma *= 1 / (
std::log(Magick::Color::scaleQuantumToDouble(targetLuminance)) /
std::log(Magick::Color::scaleQuantumToDouble(expectedLuminance)));
expectedLuminance = ComputeLuminance::computeLuminance(histogram, gamma);
*verboseOutput << QString("%1 iteration %2 changing gamma to %3 (expected luminance: %4, target %5, abs(diff) %6)")
.arg(info.file.filePath())
.arg(iteration)
.arg(gamma)
.arg(expectedLuminance)
.arg(targetLuminance)
.arg(std::abs(expectedLuminance - targetLuminance))
<< endl;
}
img.gamma(gamma);
if (debugView) {
original.transform(
Magick::Geometry(original.columns(), original.rows()),
Magick::Geometry(original.columns() / 2, original.rows())
);
img.composite(original, 0, 0, Magick::DissolveCompositeOp);
}
//img.brightnessContrast(brighnessChange, /* contrast */0.0);
emit input(info, img);
}
示例2:
void Magick::gammaImage::operator()( Magick::Image &image_ ) const
{
image_.gamma( _gammaRed, _gammaGreen, _gammaBlue );
}