澄清有关嘉洛斯转变是如何工作的 [英] Clarification about how ColorMatrix transformations work

查看:129
本文介绍了澄清有关嘉洛斯转变是如何工作的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一些工作的图像处理应用程序(乐趣)和我在努力充分了解嘉洛斯转换是如何工作的。我得到的线性/仿射变换的基本知识,并可以通过就好度日网上复制的例子,但我想完全掌握的为什么的东西的工作,而不是仅仅得到满足,它的工作原理。

I'm doing some work on an image processing app (for fun) and am struggling to fully understand how ColorMatrix transformations work. I get the basics of linear/affine transformations, and can get by just fine by replicating examples online, but I'd like to fully grasp why something works instead of just being satisfied that it works.

例如,做一个简单的变换图像上产生的负面(每种颜色转换成其相应的免费)使用以下矩阵:

For example, doing a simple transformation on an image to produce its negative (each color is converted to its respective complimentary) uses the following matrix:

[-1, 0, 0, 0, 0]
[0, -1, 0, 0, 0]
[0, 0, -1, 0, 0]
[0, 0, 0, 1, 0]
[1, 1, 1, 0, 1]

据我所知,-1 180degrees的余弦值,这是必要的轮换,以炫色到它的互补性,但我不明白的是怎样一种颜色矢量可以成倍对上述矩阵,并产生正确的互补载体。

I understand that -1 is the cosine of 180degrees, which is the rotation needed to "flip" a color to it's complementary, but what I don't understand is how a color vector can be multiplied against the above matrix and produce the correct complementary vector.

有关例如,如果一个像素具有的[247,255,0,255,1](使用RGBAW空间),​​对上述矩阵执行乘法产生[-247,-255,0,255的颜色矢量,1],但是这是不正确的,因为上述的真实补色是[8,0,255,255,1]

For instance, if a pixel has the color vector of [247, 255, 0, 255, 1] (using the RGBAW space), performing the multiplication against the above matrix produces [-247, -255, 0, 255, 1], but that isn't correct since the real complementary color of the above is [8, 0, 255, 255, 1].

我缺少的东西在这里很明显,我很高兴地承认,我不是完全确定我在做什么:)正在转化psented在一些其它的坐标系统重新$ P $颜色矢量? (如不0-255)

I'm missing something obvious here and am happy to admit that I'm not completely sure what I'm doing :) Is the color vector being transformed represented in some other coordinate system? (e.g. not 0-255)

如果有人可以帮助提供我的理解中缺失的环节,我会非常AP preciative。

If anyone could help provide the "missing link" of my understanding, I'd be really appreciative.

修改

我刚刚发现下面的矩阵也适用,实际上mathemtically直观(它产生正确的向量)。

I just discovered that the following matrix also works and is actually mathemtically intuitive (it produces the correct vector).

-1  0  0  0  0
 0 -1  0  0  0
 0  0 -1  0  0
 1  1  1  1  0
 0  0  0  0  1

所以我的新问题是:为什么这两个矩阵的工作吗?后者为我提供了更加令人满意的解决方案,因为我能掌握,为什么它的工作原理,从代数观点。是四大行用于缩放?如果是这样,为什么缩放增加255?它在哪里,从获取的价值?

So my new question is: why do both of these matrices work? The latter one provides me with the more satisfying solution since I can grasp why it works from an algebraic perspective. Is the four row used for scaling? And if so, why does scaling add 255? Where does it get that value from?

很抱歉,如果这真的是愚蠢的问题,我试图让这个拍下来。

Sorry if these are really stupid questions, I'm trying to get this down pat.

推荐答案

您是正确的,底线是翻译。什么汉斯说,在他的评论是,有255的比例因子介入,这可能是发生了什么迷惑你。来看待这个的一种方法是,所有的ARGB值由255第一分割,则矩阵乘法应用于然后所有值都被乘以回255,得到正确的ARGB值。另一种方式来看待它是想的平移值是255大。您将两种方式达到同样的结果。

You are correct that the bottom line is for translation. What Hans is saying in his comment is that there's a scaling factor of 255 involved, which is probably what's confusing you. One way to look at this is that all ARGB values are first divided by 255, then the matrix multiplication is applied and then all values are multiplied back by 255 to give the correct ARGB values. Another way to look at it is to think of the translation values being 255 as big. You will arrive at the same result both ways.

((247/255) * -1 + 1) * 255 = 8
or
247 * -1 + 255 = 8

这篇关于澄清有关嘉洛斯转变是如何工作的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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