简体   繁体   English

算法:随机化亮度和对比度值,有约束

[英]Algorithm: Randomize Brightness and Contrast Values, With Constraints

I want to do a random brightness and contrast adjustment to an image, such that...我想对图像进行随机亮度和对比度调整,这样......

brightness = random in range (brightness_min, brightness_max)
contrast = random in range (contrast_min, contrast_max)   
outputImage = inputImage * contrast + brightness;

But when I do this, because the range of brightness and contrast values in my application are so large, I often output an image which is all white or all black.但是当我这样做时,因为我的应用程序中亮度和对比度值的范围太大,我经常输出一个全白或全黑的图像。

I want an algorithm to choose a random brightness and contrast pair such that: no output is a solid color (unless already so), and: the output retains some specifiable amount of detail (this part is less important).我想要一个算法来选择一个随机的亮度和对比度对,这样:没有输出是纯色(除非已经是这样),并且:输出保留了一些可指定的细节量(这部分不太重要)。

I don't know how to describe what I want in technical terms, nor begin constructing the solution.我不知道如何用技术术语描述我想要的东西,也不知道如何构建解决方案。 Any help is greatly appreciated.任何帮助是极大的赞赏。 Thank you.谢谢你。

Assuming that brightness , inputImage , and outputImage are all on the same scale, I'd change the formula for outputImage to假设brightnessinputImageoutputImage都在同一比例上,我outputImage的公式outputImage

outputImage = (inputImage - averageInputImage) * contrast + brightness;

where averageInputImage is the average (mean, median, whatever makes sense) of the inputImage values.其中averageInputImage是平均(均值,中位数,无论是有道理的)的的inputImage值。 Assuming positive contrast and an input image with detail, the output should have some detail, even if for high contrast it is alternately white and black.假设正对比度和带有细节的输入图像,输出应该有一些细节,即使对于高对比度它是交替的白色和黑色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM