Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Complementary Colour for Image

$
0
0
Yes, think there could be a problem - see this image: http://imgur.com/a/VNIa6

Added this to my code:

using (PixelCollection pixels = image5.GetPixels())
                {
                    ColorRGB average = pixels.GetPixel(0, 0).ToColor();
                    var cr1 = ((int)(average.R / 256)).ToString();
                    var cb1 = ((int)(average.B / 256)).ToString();
                    var cg1 = ((int)(average.G / 256)).ToString();
                    var tx1 = "AV: R:" + cr1 + " G:" + cg1 + " B:" + cb1;
                    quote += tx1;
                    fillColor = average.ComplementaryColor();
                    var cr = ((int)(fillColor.R / 256)).ToString();
                    var cb = ((int)(fillColor.B / 256)).ToString();
                    var cg = ((int)(fillColor.G / 256)).ToString();
                    var tx = "   COMP: R:" + cr + " G:" + cg + " B:" + cb;
                    quote += tx;
                }
The average is 153 160 30 - yellowish green - so that's right.

The complement 160 153 156 (text color) is too grey.

If I go to https://www.sessions.edu/color-calculator/ and set RGB mode
my average color is #9aa01e and the complement is a dark blue - #251ea0

I did find this: https://sharpsnippets.wordpress.com/2014/03/11/c-extension-complementary-color/
If you ignore the first paragraph - which is RYB and so doesn't match his RGB code - maybe the c# code will help.
Some more (php) here: http://serennu.com/colour/rgbtohsl.php

Found this on RGB<->RYB - looks complicated http://stackoverflow.com/questions/4945457/conversion-between-rgb-and-ryb-color-spaces

"Take the equations for a trilinear interpolation. Substitute the first equations into the last, the expand and collect the coefficients for: Xd, Yd, Zd, XdYd, XdZd, YdZd, ZdYdZd and the constant. Then find the partial differentiation of the equation in each of the 3 dimensions each in respect to Xd, Yd and Zd. Use these new equations to populate the (3x3) Jacobian matrix and then use Newton's method to solve in software."

The guy at https://www.sessions.edu/color-calculator/ seems to have the code - maybe he would share for a non-profit project??

Viewing all articles
Browse latest Browse all 3693

Trending Articles