本文整理汇总了C#中MagickWand.AutoLevelImage方法的典型用法代码示例。如果您正苦于以下问题:C# MagickWand.AutoLevelImage方法的具体用法?C# MagickWand.AutoLevelImage怎么用?C# MagickWand.AutoLevelImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MagickWand
的用法示例。
在下文中一共展示了MagickWand.AutoLevelImage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessPhotoAsync
public async Task<ProcessingResult> ProcessPhotoAsync(string filename)
{
using(var wand = new MagickWand())
{
var srcFile = _pathHelper.GetSourceFilePath(filename);
if(_rawConverter.IsRawFile(srcFile))
{
var conversionResult = await _rawConverter.ConvertAsync(srcFile);
wand.ReadImage(conversionResult.OutputFile);
File.Delete(conversionResult.OutputFile);
}
else
{
wand.ReadImage(srcFile);
}
wand.AutoOrientImage();
wand.AutoLevelImage();
wand.StripImage();
var path = Path.Combine(Path.GetDirectoryName(srcFile), "review", $"{Path.GetFileNameWithoutExtension(filename)}.jpg");
wand.WriteImage(path, true);
}
return null;
}
示例2: ComposedTest
public void ComposedTest()
{
var contrastRatioThreshold = 0.5;
var tooContrastyThreshold = 1.9;
MagickWandEnvironment.Genesis();
PrintStatsHeader();
foreach(var file in _files)
{
using(var wand = new MagickWand(file))
{
double mean, stddev;
wand.GetImageChannelMean(ChannelType.AllChannels, out mean, out stddev);
PrintStats(file, wand);
wand.AutoLevelImage();
var contrastRatio = stddev / mean;
var contrastyRatio = stddev / 10000;
if(contrastRatio < contrastRatioThreshold)
{
var saturationAmount = Convert.ToInt32((contrastRatioThreshold - contrastRatio) * 100) * 4;
// limit the saturation adjustment to 20%
if(saturationAmount > 20)
{
saturationAmount = 20;
}
saturationAmount += 100;
Console.WriteLine("modulating by: " + saturationAmount);
// 100 = don't adjust brightness
// 300 = don't rotate hue
wand.ModulateImage(100, saturationAmount, 300);
}
else if(contrastyRatio > tooContrastyThreshold)
{
Console.WriteLine("attempting to reduce contrast");
wand.SigmoidalContrastImage(true, 2, 0); // smooth brightness/contrast
}
wand.UnsharpMaskImage(0, 0.7, 0.7, 0.008); // sharpen
WriteImage("composed", file, new string[] { }, wand);
}
}
MagickWandEnvironment.Terminus();
}
示例3: AutoLevelTest
public void AutoLevelTest()
{
MagickWandEnvironment.Genesis();
foreach(var file in _files)
{
using(var wand = new MagickWand(file))
{
wand.AutoLevelImage();
WriteImage("auto_level", file, new string[] { }, wand);
}
}
MagickWandEnvironment.Terminus();
}