如何根据图像确定阴影?
对于数据库应用程序,我试图根据色标确定照片部分的平均色调。
作为一个新手,我发现这很难解释,所以我创建了一个简单的图表来准确地显示我想要实现的目标。
http://www.knockyoursocksoff.com/shade/
如果有人有时间给我一些我将非常感激。
最美好的祝愿,
沃伦。
For a database app I'm trying to determine the average shade of a section of photo, against a colour scale.
Being a novice I'm finding this very difficult to explain so I've created a simple diagram showing exactly what I'm trying to achieve.
http://www.knockyoursocksoff.com/shade/
If anybody has the time to give me some ideas I'd be very grateful.
Best wishes,
Warren.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用彩色照片,则应首先将选定区域从 RBG(红、绿、蓝)转换为 HSL/HSV (文章)。
HSL 代表“色调、饱和度、亮度”。1您感兴趣的数字是亮度。
用最一般的术语来说,亮度是指您如何感知彩色表面的亮度。很难使用红/绿/蓝分量来判断一块红色是否比一块蓝色更亮/更暗。转换为 HSL 可以解决这个问题。
完成转换后,您可以简单地平均所选区域的亮度值。
关于亮度值的快速说明:从技术上讲,您不能简单地平均亮度值,因为亮度的感知不是线性的(文章)。但是,除非您正在编写深入科学的应用程序,否则简单地平均亮度就会给您一个“足够准确”的值。
1 在 Adobe Photoshop 中,他们称之为 “足够准确”的值。 HSB(色相、饱和度、亮度)
If you are using color photos, you should first convert the selected area from RBG (red, green, blue) to HSL/HSV (article).
HSL stands for "hue, saturation, lightness".1 The number you are interested in is the lightness.
In the most general terms, the lightness refers to how you perceive the brightness of a colored surface. It's hard to use the red/green/blue components to say whether a patch of red is brighter/darker than, say, a patch of blue. Converting to HSL takes care of that problem.
Once you have done the conversion, you can simply average the lightness values of your selected area.
Quick note on lightness values: Technically, you can't simply average the lightness values because the perception of lightness is not linear (article). But, unless you are writing a deeply scientific application, simply averaging the lightness will give you an "accurate enough" value.
1 In Adobe Photoshop, they call it HSB (hue, saturation, brightness)
我想我会从平均像素值开始:
如果你用彩色来做的话,它会变得更加复杂。
I think I would start by just averaging the pixel values:
Its going to be more complicated if you're doing it in color.