Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

mixing colors

For general discussion related FlowStone

mixing colors

Postby tester » Fri Jul 11, 2014 10:01 pm

Changing the topic a little bit.

How to mix multiple colors in "light" way and "paint" way?

Let say that I have an array of RGB values (0-255 ranges; this comes out of a module):

rrr/ggg/bbb
rrr/ggg/bbb
rrr/ggg/bbb
...

And as the output reslut - I'd like to have one color as if I was mixing lights, and second color as if I was mixing paints.

From what I see - one formula is probably just to sum on all rrr/ggg/bbb channels and divide by amount of elements in the array (subtractive/paint type?). But I don't know how to approach the second one. Especially because many colors in FS are just idealistic with 0 or 255 thresholds.

Trog - I don't seek for ultra-hyper-realistic sRGB, just something brief. ;-)
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: mixing colors

Postby TheOm » Fri Jul 11, 2014 10:28 pm

I would first convert the colours from RGB to HSV and then take the average values.
TheOm
 
Posts: 103
Joined: Tue Jan 28, 2014 7:35 pm
Location: Germany

Re: mixing colors

Postby tester » Fri Jul 11, 2014 10:46 pm

Okay, thanks. Tested, and while results are not quite as expected (thus - I will keep probably only one mixing model), this conversion RGB-HSV will be useful for other thing.

BTW, @TheOm, you sound very familiar. :mrgreen:
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: mixing colors

Postby trogluddite » Sat Jul 12, 2014 10:41 am

For 'light mix', summing R, G, B would be a reasonable approximation - the hue would be about right, but as you say the limited (0-255) would affect the brightness, so the values will need scaling to keep in range.

For paints, the colour depends on the light that the pigments absorb, and your eye sees the remainder that bounces off - mixing two pigments combines their 'negative' spectrum. (mixing pigments always makes the color darker - hence all oil painters always have a huge tube of white paint!).

So this 'inversion' might be worth a go...

Take (255 -R), (255 - G), (255 - B) for each colour.
Take averages.
Take (255 -R), (255 - G), (255 - B) of result.

Not tried that, it might distort the hue because the traditional painter's primary colours are Red, Blue, Yellow - not Cyan, Yellow, Magenta (opposites of R, G, B).

Mixing in the HSV color space would give other results, though. For example yellow and blue are 'complementary' colours - if you mix those ('light' method), you would get white/grey (zero saturation). But an HSV average will still give you a very saturated color of a different hue.
It is a good way to create a 'spectrum' of hues, so the results will often have more 'visual appeal', but unlikely to give results like mixing lights or pigments.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK


Return to General

Who is online

Users browsing this forum: No registered users and 80 guests