POV-Ray : Newsgroups : povray.binaries.images : An experiment in monochrome : Re: An experiment in monochrome Server Time
18 Apr 2024 12:45:50 EDT (-0400)
  Re: An experiment in monochrome  
From: m@b
Date: 11 Jun 2021 06:16:35
Message: <60c33803$1@news.povray.org>
On 11/06/2021 2:27 am, Bald Eagle wrote:
> I am curious about
> #declare GreyTest = 0.001 + abs(TestK(X,Y,0) -
> abs((TestR(X,Y,0) + TestG(X,Y,0) - TestB(X,Y,0))));
> 
> What is the underlying logic/reasoning behind this "greyness test"?

I wish to represent 4 colours - R, G, B and Grey.

The 0.001 is now redundant, I put it in to prevent a divide by zero 
error in a previous version.

TestK(X,Y,0) returns the mean value of R, G, B. (1)

R+G-B will also return the mean if R, G and B are all the same, i.e. 
colour is Grey. (Black and White are just shades of Grey :-))  (2)

So the GreyTest (1)-(2) returns zero if R, G and B are equal and a small 
value if they are close.

BUT --------------------------------------------------------

You got me thinking, are there any cases where the test returns zero but 
R, G, B are not equal?

Answer - yes, the test sometimes falls down when the 3 numbers are 
equally spaced. e.g  0.1, 0.2, 0.3    or 0.3, 0.6, 0.9

I was over thinking, maybe this will work:

#declare GreyTest = abs(TestR(X,Y,0)-TestG(X,Y,0)) + 
abs(TestR(X,Y,0)-TestB(X,Y,0)) + abs(TestB(X,Y,0)-TestG(X,Y,0));

m@


Post a reply to this message

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