POV-Ray : Newsgroups : povray.binaries.images : color_matrix post_process(4 test images) - attached files (1/1) : Re: color_matrix post_process(4 test images) - attached files (1/1) Server Time
2 Oct 2024 14:15:42 EDT (-0400)
  Re: color_matrix post_process(4 test images) - attached files (1/1)  
From: Chris Huff
Date: 25 Apr 2000 11:21:14
Message: <chrishuff_99-50D220.10241225042000@news.povray.org>
In article <3905b0be@news.povray.org>, "TonyB" 
<ben### [at] panamac-comnet> wrote:

> Interesting. How does one go about coming up with this color_matrix?

Not quite sure what you mean...but here is a short explanation:
The matrix values are multipliers, each column from left to right is 
input red, green and blue. The results for each component are calculated 
by multiplying the column component by the multiplier, and adding the 
three components together:
              inputRed* inputGreen* inputBlue*
resultRed   =    AA    +    AB     +    AC;
resultGreen =    BA    +    BB     +    BC;
resultBlue  =    CA    +    CB     +    CC;

In other words:

resultRed   = AA*inputRed + AB*inputGreen + AC*inputBlue;
resultGreen = BA*inputRed + BB*inputGreen + BC*inputBlue;
resultBlue  = CA*inputRed + CB*inputGreen + CC*inputBlue;


This matrix will not change the image at all:
< 1, 0, 0,
  0, 1, 0,
  0, 0, 1 >
To swap two colors, just interchange the "1" positions:
this swaps red and green:
< 0, 1, 0,
  1, 0, 0,
  0, 0, 1 >

To get a grayscale monochrome output image, just make sure the values in 
each column are equal. To get a more realistic effect, simulating the 
varying sensitivity to different colors, make the numbers in each column 
different. This is black-white:
< 0.5, 0.75, 0.25,
  0.5, 0.75, 0.25,
  0.5, 0.75, 0.25 >

To tint this image a certain color, multiply each row by it's respective 
component from the tint color. This is a sepia tone version:
< 0.5*0.9, 0.75*0.9, 0.25*0.9,
  0.5*0.7, 0.75*0.7, 0.25*0.7,
  0.5*0.3, 0.75*0.3, 0.25*0.3 >


> Oh, and don't you think that color_matrix {...} is better than 
> putting it between {<...>}?

Actually, I will probably modify it to use color_matrix <...>. More 
consistent with the "matrix" transform that way. The curly braces were 
left in because I copied parsing code from another post_process, and I 
hadn't decided whether to make it consistent with other post_process 
effects or with the matrix transform.

-- 
Christopher James Huff - Personal e-mail: chr### [at] yahoocom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Personal Web page: http://chrishuff.dhs.org/
TAG Web page: http://tag.povray.org/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.