如何判断图像是否较暗? (高对比度、低亮度)
作为我正在从事的项目的一部分,我需要使用 CLI Linux 应用程序简单地分析图片并确定其图像是否较暗(高对比度、低亮度)。
到目前为止,我发现我可以使用 ImageMagick 来获取图像的详细信息,但不确定如何使用该数据......或者是否有更简单的解决方案?
As part of a project I am working on, I need to simply analyze a picture using a CLI Linux application and determining if its dark image (high contrast, low brightness).
So far, I figured out I can use ImageMagick to get verbose information of the image, but not sure how to use that data...or is there a simpler solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将图像缩放到非常小的图像 - 尺寸为 1x1 像素并代表原始图像的“平均颜色”:
然后首先研究该单个像素的颜色,
然后
您也可以在一个图像中获得相同的结果go:
通过这种方式,您可以获取输入图像的原始颜色空间中的“平均像素”值,您可以评估其“亮度”(无论您如何定义)。
您可以将图像转换为灰度,然后调整大小。通过这种方式,您将获得灰度值作为“亮度”的度量:
您还可以将图像转换为 HSB 空间(色调、饱和度、亮度)并执行相同的操作:
您在此处看到的“亮度”值(或者
134
、#86
或52.4941%
)可能是您想知道的。You could scale the image to a very small one -- one that has a dimension of 1x1 pixels and represents the "average color" of your original image:
Then investigate that single pixel's color, first
then
You can also get the same result in one go:
This way you get the values for your "avarage pixel" in the original color space of your input image, which you can evaluate for its 'brightness' (however you define that).
You could convert your image to grayscale and then resize. This way you'll get the gray value as a measure of 'brightness':
You can also convert your image to HSB space (hue, saturation, brightness) and do the same thing:
The 'brightness' values you see here (either of
134
,#86
or52.4941%
) is probably what you want to know.