如何根据图像确定阴影?

发布于 2024-08-18 20:36:24 字数 273 浏览 1 评论 0原文

对于数据库应用程序,我试图根据色标确定照片部分的平均色调。

作为一个新手,我发现这很难解释,所以我创建了一个简单的图表来准确地显示我想要实现的目标。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情释 2024-08-25 20:36:24

如果您使用彩色照片,则应首先将选定区域从 RBG(红、绿、蓝)转换为 HSL/HSV (文章)。

HSL 代表“色调、饱和度、亮度”。1您感兴趣的数字是亮度

用最一般的术语来说,亮度是指您如何感知彩色表面的亮度。很难使用红/绿/蓝分量来判断一块红色是否比一块蓝色更亮/更暗。转换为 HSL 可以解决这个问题。

完成转换后,您可以简单地平均所选区域的亮度值。

关于亮度值的快速说明:从技术上讲,您不能简单地平均亮度值,因为亮度的感知不是线性的(文章)。但是,除非您正在编写深入科学的应用程序,否则简单地平均亮度就会给您一个“足够准确”的值。


1 在 Adob​​e 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)

聊慰 2024-08-25 20:36:24

我想我会从平均像素值开始:

for x = start_x to end_x
for y = stary_y to end_y
  total += getPixel(x,y)
shade = total / (xlen*ylen)

如果你用彩色来做的话,它会变得更加复杂。

I think I would start by just averaging the pixel values:

for x = start_x to end_x
for y = stary_y to end_y
  total += getPixel(x,y)
shade = total / (xlen*ylen)

Its going to be more complicated if you're doing it in color.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文