以编程方式比较图像的亮度 [英] Comparing images for brightness programmatically

查看:115
本文介绍了以编程方式比较图像的亮度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个场景相同的bmp文件,我想确定一个是否比另一个亮.同样,我有一组对比度不同的bmp和另一组饱和度不同的bmp.如何比较这些图像的亮度,对比度和饱和度?这些测试图像由传感器制造商提供的工具保存.我正在使用gcc 4.5.

I have a two bmp files of the same scene and I would like determine if one is more bright than the other. Similarly I have a set of bmps with different contrasts and another set of bmps with different saturation. How do I compare these images for brightness,contrast and saturation ? These test images are saved by a tool provided by the sensor manufacturer. I am using gcc 4.5.

推荐答案

术语亮度"是一个非常不幸的术语,因为它经常被错误地使用,尤其是在与计算机相关的色彩空间问题中,主要是由于引入术语的人对物理学的理解不佳.请参阅:
http://en.wikipedia.org/wiki/Brightness [ http://en.wikipedia.org/wiki/HSV_color_space [
有关色彩空间的更一般的了解,请参见:
http://en.wikipedia.org/wiki/Color_space [
The term "brightness" is a very unlucky term as it is often used incorrectly, especially in computer-related color space issues, mostly due to poor understanding of physics by the people who introduced the terms. Please see:
http://en.wikipedia.org/wiki/Brightness[^].

I would prefer to call it "value", as in the name of the color space "HSV". Please see:
http://en.wikipedia.org/wiki/HSV_color_space[^].
This article explains some controversies in "brightness" or "lightness".

For more general understanding of color spaces, please see:
http://en.wikipedia.org/wiki/Color_space[^].



Please also see my notes to Solution 1.

—SA


您的问题很有趣,但总之很难回答.首先,我建议您在板上安装一个图像库,该库使您可以访问图像的每个像素,而无需编写大量代码来读取bmp文件.

然后,您想仔细查看您的图像.它们是否精确对准,即是从具有相同相机查看方向和相同焦距的相同点采集的?在这种情况下,您可以直接比较一个图像的像素和另一图像的像素.如果不是,则首先必须对齐图像.

您可能需要考虑更明亮"的含义.图像的某些部分更亮,平均更亮,图像的特定区域更亮?

在最简单的情况下,您只需计算图像1的平均像素亮度并将其与图像2的平均像素亮度进行比较.如果亮度差异是由于不同的光照或不同的曝光设置导致的,那么这可能是一种有效的方法. >
类似的情况适用于对比度和饱和度.为了对比,您可能需要计算像素亮度值的标准偏差.对于饱和度,您可以按所有图像像素的平均饱和度进行计算.

希望能给您完成任务的大致路线图.
Your question is interesting, but hard to answer in short. First of all I would recommend you get some image library on board that allows you to access each pixel of your images without writing tons of code to read the bmp files.

Then you want to take a close look at your images. Are they precisely registered, i.e. taken from the exact same point with the exact same camera viewing direction and the same focal length? In that case you can compare pixels from one image directly with pixels from the other image. If not you will first have to align the images.

You might want to think about what exactly "brighter" means. Brighter in parts of the image, brighter in average, brighter in a particular area of the image?

In the simplest case, you just calculate the average pixel brightness of image 1 and compare that with the average pixel brightness in image 2. If the brightness difference resulted from different lighting or different exposure settings, that is probably a valid method.

Similar things apply to contrast and saturation. For contrast you might want to calculate the standard deviation of pixel brightness values. For saturation you might go by the average saturation of all image pixels.

Hope that gives you a rough road map for your task.


这篇关于以编程方式比较图像的亮度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆