We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
GIMP 显然使用了一种非常简单的自动白平衡算法。
http://docs.gimp.org/en/gimp-layer-white -balance.html
有比这里描述的更多的调整,因为我第一次尝试实现这项工作似乎适用于大多数照片,但其他照片似乎有伪影或包含太多的红绿或蓝色:/
GIMP apparently uses a very simple algorithm for automatic white balancing.
http://docs.gimp.org/en/gimp-layer-white-balance.html
There is a bit more tweaking than is described here since my first attempt at implementing this works seems to work for most photos but other photos seem to have artifacts or contain too much of either red green or blue :/
一个相对简单的算法是对屏幕上最亮和最暗像素的色调(HSV 或 HSL)进行平均。 在紧要关头,仅使用最亮的像素。 如果最亮和最暗之间的色调差异太大,请选择明亮的像素。 如果黑暗接近黑色,则选择明亮的像素。
为什么还要关注暗像素? 有时,黑暗并不接近黑色,而是暗示环境光或雾或霾。
如果您是 Photoshop 的重度用户,这对您来说很有意义。 照片中的高光与物体的底层颜色无关(或微弱相关)。 它们是光线色偏的最佳表现,除非图像曝光过度以至于一切都淹没了 CCD。
然后调整所有像素的色调。
您将需要快速的 RGB 到 HSV 和 HSV 到 RGB 函数。 (但也许您可以使用 LUT 或线性插值在 RGB 中进行像素校正。)
您不想使用平均像素颜色或最流行的颜色。 那就是疯狂。
要快速找到最亮的颜色(和最暗的颜色),您可以使用 RGB,但您应该有绿色、红色和蓝色的乘数。 在 RGB 显示器上,255 绿色比 255 红色更亮,而 255 红色又比 255 蓝色更亮。 我的脑海里曾经有过很好的乘数,但可惜的是,它们已经从我的记忆中消失了。 你也许可以用谷歌搜索他们。
对于没有高光的图像,此操作将失败。 例如,哑光漆墙。 但我不知道你能对此做些什么。
这个简单的算法还有很多改进之处。 您可以平均多个明亮像素、对图像进行网格化并从每个单元格中抓取亮像素和暗像素等。实现算法后,您会发现一些明显的调整。
A relatively simple algorithm is to average the hues (in HSV or HSL) of the brightest and darkest pixels on the screen. In a pinch, go with the brightest pixel only. If the hues between brightest and darkest are too different, go with the bright pixel. If the dark is near black go with the bright pixel.
Why even look at the dark pixel? Sometimes the dark is not near black, and hints at the ambient light or fog or haze.
This will make sense to you if you're a heavy Photoshop user. Highlights in a photo are unrelated (or weakly related) to the underlying color of the object. They are your best representation of the color cast of the light, unless the image is so overexposed that everything has overwhelmed the CCDs.
Then adjust the hues of all pixels.
You'll need fast RGB to HSV and HSV to RGB functions. (But maybe you can work in RGB for the pixel corrections with a LUT or linear interpolation.)
You don't want to go by average pixel color or most popular color. That way lies madness.
To quickly find the brightest color (and the darkest one), you can work in RGB, but you should have multipliers for green, red, and blue. On an RGB monitor, 255 green is brighter than 255 red which is brighter than 255 blue. I used to have good multipliers in my head, but alas, they have fled my memory. You can probably google for them.
This will fail in an image which has no highlights. A matte painted wall, for example. But I don't know what you can do about that.
There are many improvements to make to this simple algorithm. You can average multiple bright pixels, grid the image and grab bright and dark pixels from each cell, etc. You'll find some obvious tweaks after implementing the algorithm.
@Charles Ma 建议使用
Gimp
白平衡算法。 在 python 和 numpy 中,这可能看起来像这样:它快速、简单并且提供相当不错的结果
@Charles Ma has suggested to use the
Gimp
white balance algorithm. Inpython
andnumpy
this could look like this:it's fast, simple and provides pretty decent results
白平衡算法很难。 即使数码相机也偶尔会出错,尽管它们知道有关图片的许多额外信息 - 例如是否使用闪光灯以及光线水平。
对于初学者来说,我只会平均红色、绿色和蓝色,并将其用作白平衡点。 对其设置限制 - 保持在钨丝灯、荧光灯和日光的范围内。 它不会是完美的,但当它出错时,解释原因会相对容易。
White balancing algorithms are hard. Even digital cameras get the wrong once in a while, even though they know a lot of extra info about the picture - such as whether the flash was used, and the light level.
For starters, I would just average red, green, and blue, and use that as the white balance point. Set limits on it - stay within the ranges for tungsten, flourescent, and daylight. It won't be perfect, but when its wrong, it will be relatively easy to explain why.
最近发布的一种算法是颜色分布算法:
论文中还引用了 Matlab 源代码(互联网档案馆)。 这是一个简单的算法,可以轻松编程,结果表明它非常快。
如果您需要额外的快速且同时准确的白平衡(颜色恒常性)算法,您应该检查 此网站。
有几种算法及其各自的源代码,可能正是您所寻找的。
One recently published algorithm is the Color Distribution algorithm:
In the paper there is also the reference to the Matlab source code (Internet Archive). It's a simple algorithm that can be easily programmed and the results show it to be very fast.
If you need additional fast and at the same time accurate white balancing (color constancy) algorithms, you should check this site.
There are several algorithms with their respective source coded that might be just the ones you look for.