c# - Clarification about how ColorMatrix transformations work -


i'm doing work on image processing app (for fun) , struggling understand how colormatrix transformations work. basics of linear/affine transformations, , can fine replicating examples online, i'd grasp why works instead of being satisfied works.

for example, doing simple transformation on image produce negative (each color converted respective complimentary) uses 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] 

i understand -1 cosine of 180degrees, rotation needed "flip" color it's complementary, don't understand how color vector can multiplied against above matrix , produce correct complementary vector.

for instance, if pixel has color vector of [247, 255, 0, 255, 1] (using rgbaw space), performing multiplication against above matrix produces [-247, -255, 0, 255, 1], isn't correct since real complementary color of above [8, 0, 255, 255, 1].

i'm missing obvious here , happy admit i'm not sure i'm doing :) color vector being transformed represented in other coordinate system? (e.g. not 0-255)

if provide "missing link" of understanding, i'd appreciative.

edit

i discovered following matrix works , mathemtically intuitive (it produces 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 

so new question is: why both of these matrices work? latter 1 provides me more satisfying solution since can grasp why works algebraic perspective. 4 row used scaling? , if so, why scaling add 255? value from?

sorry if these stupid questions, i'm trying down pat.

you correct bottom line translation. hans saying in comment there's scaling factor of 255 involved, what's confusing you. 1 way @ argb values first divided 255, matrix multiplication applied , values multiplied 255 give correct argb values. way @ think of translation values being 255 big. arrive @ same result both ways.

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

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -