[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Averaging colours for AA - any known algorithm ?
From:       Paul Campbell <paul () taniwha ! com>
Date:       2000-04-12 23:10:35
[Download RAW message or body]

On Wed, 12 Apr 2000, Rik Hemsley wrote:
> #if Martin Jones
> > KImageEffect::blend() does this:
> > 
> >  int red = r0 + (r1 - r0) * mid;
> > 
> > Might be what you want.
> 
> Thanks, but no beer ;)
> 
> Using that method on red and green gives this:
> 
> r = 255 + (   0 - 255 ) * 0.5 = 127
> g =   0 + ( 255 -   0 ) * 0.5 = 127
> 
> ... which gives you yellow :(
> 
> For 50% between red and green, you should see something like (182,182,112).
> 
> The algorithm looks right, but it doesn't give the 'correct' output.
> 
> Seeing a bright yellow pixel between red and green ones looks wrong.
> The human brain doesn't see it as the average of red and green, it
> sees it as yellow :)
 
look really really closely at the screen ...... see that yellow pixel .......
it's really a green phosphor dot next to a red one.

An anti-aliased pixel that's 1/2 red and 1/2 green should have 1/2 a red
phosphor dot and 1/2 a green one (ie 127, 127, 0) - and yes it does look yellow
because that's the way the color receptors in your eyes work. 

What you can't do is scale up anti-aliased pixels above the minimum screen
resolution and expect them to look sensible - they are supposed to look like
blurrd pixels at the edge of resolution your eyes to the final bit of image
processing to make them 'look right'.

Now strictly speaking this sort of math on pixels is wrong (even though
EVERYONE does it - including your favorite 3D card) you should 
un-gamma the data into a linear space first, then re-gamma the result when
you're done (and remember KDE runs on Macs and Suns as well as PCs all of which
have different ideas about which is the appropriate gamma to use so whatever
you choose to do you're screwed up elsewhere)

I spent a lot of time working with color matching a few years back (I design
video accelerators) - IMHO it's a can of worms - lots of people want 'perfect
color matching' etc and it turns out they all want different things - the
screen has to look like the image on the page - but color on a page looks
different  depending on which light you see it in (big magazines have white
rooms with fixed lights in them to look at stuff) morning light is different
from afternoon light, is different from artificial light. etc. And screens have
quite different gamuts than paper - those saturated bright phosphor colors
can't be made on paper any more than a lot of colors that involves reflective
stuff - silver, gold - can be made on a screen (I bet color anti-aliasing for
subtractive colors on a page is different for additive colors from phosphors
too) .

And people's eyes are different everyone perceives color slightly
differently - you can't win :-) [for a gross example consider that 10% of the
male population is red-green color blind].

Anyway I've gone on too long - my main point - don't sweat the small stuff it
probably isn't worth it :-)

	Paul Campbell
	paul@taniwha.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic