Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCG color model support #1

Open
ghost opened this issue Aug 22, 2016 · 9 comments
Open

HCG color model support #1

ghost opened this issue Aug 22, 2016 · 9 comments

Comments

@ghost
Copy link

ghost commented Aug 22, 2016

I looked to code - too hard...
I beg to help implement HCG color model for your library.
https://github.com/acterhd/hcg-color

@dmilos
Copy link
Owner

dmilos commented Aug 22, 2016

Hello
Thank you for interest for color library.

Adding new model I not so trivial.
Here is possible steps:

  • create HCG folder
  • copy all files from CMY ( or CMYK, do not use RGB )
  • search/replace CMY with HCG.
  • Search every place that CMY appear and add HCG. This is tricky.
    -- You have to do the same with files too. Very tricky.
  • implement conversion RGB<->HCG
  • in example/test folder add testing of HCG, gray, conversion, etc.
    -- generate ::color::make functions and test and test and test and test and
    test ...

... and I guess that is all.

On github Implementation looks simple but there some heavy JS language
usage.
If you can point me to some c implementation I can easily do this for you.
I'll also make branch for HCG

I found this is https://phabricator.kde.org/D1374#10659608

Regards
Dejan

On Mon, Aug 22, 2016 at 4:14 AM, acterhd [email protected] wrote:

I looked to code - too hard...
I beg to help implement HCG color model for your library.
https://github.com/acterhd/hcg-color


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#1, or mute the thread
https://github.com/notifications/unsubscribe-auth/APIjvCTJr7q65bqnswOQOL29qt8nax4fks5qiQYggaJpZM4JpdZb
.

@dmilos
Copy link
Owner

dmilos commented Aug 22, 2016

I use use both.

On Mon, Aug 22, 2016 at 9:38 PM, acterhd [email protected] wrote:

You using GCC? No Visual Studio?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#1 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/APIjvNZqDf_k_WLOlrxKQryKULv2TuK0ks5qifq_gaJpZM4JpdZb
.

@dmilos
Copy link
Owner

dmilos commented Aug 22, 2016

Most important part is conversion RGB<-> HCG.
Everything else is support of that.
I already set that support. See branch HCG.
All I need is RGB<-> HCG.
JS I pretty hazy to me.|
Can you convert to simple c?

On Mon, Aug 22, 2016 at 9:54 PM, acterhd [email protected] wrote:

Bad news... I lost formulas for convert HCG/HSV and HCG/HSL. I used
special converter in death-color (destroy to min/max/chroma and recompiling
color model).


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#1 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/APIjvI87W9D5OQf0mD0Gg1LKk_W17Coqks5qif6GgaJpZM4JpdZb
.

@dmilos
Copy link
Owner

dmilos commented Aug 22, 2016

Perfect.
Thanks.

On Mon, Aug 22, 2016 at 10:54 PM, acterhd [email protected] wrote:

typedef struct {
double r;
double g;
double b;
} rgb;
typedef struct {
double h;
double c;
double g;
} hcg;
static hcg rgb2hcg(rgb in);static rgb hcg2rgb(hcg in);

hcg rgb2hcg(rgb in)
{
hcg out;
double min, max, delta;

min = in.r < in.g ? in.r : in.g;
min = min  < in.b ? min : in.b;

max = in.r > in.g ? in.r : in.g;
max = max  > in.b ? max : in.b;

delta = max - min;
out.c = delta;
if (delta < 0.00001)
{
    out.h = 0;
    out.c = 0.0;
    out.g = min;
    return out;
}
if (delta < 1.0) {
    out.g = min / (1.0 - delta);
}

if (in.r >= max)
    out.h = (in.g - in.b) / delta;
else
if (in.g >= max)
    out.h = 2.0 + (in.b - in.r) / delta;
else
    out.h = 4.0 + (in.r - in.g) / delta;

out.h *= 60.0;

if (out.h < 0.0)
    out.h += 360.0;

return out;

}

rgb hcg2rgb(hcg in)
{
double hh, p, q, t, ff, v;
long i;
rgb out;

if (in.c <= 0.0) {       // < is bogus, just shuts up warnings
    out.r = in.g;
    out.g = in.g;
    out.b = in.g;
    return out;
}
hh = in.h;
if (hh >= 360.0) hh = 0.0;
hh /= 60.0;
i = (long)hh;
ff = hh - i;
p = in.g * (1.0 - in.c);
q = p + in.c * (1.0 - ff);
t = p + in.c * ff;
v = p + in.c;

switch (i) {
case 0:
    out.r = v;
    out.g = t;
    out.b = p;
    break;
case 1:
    out.r = q;
    out.g = v;
    out.b = p;
    break;
case 2:
    out.r = p;
    out.g = v;
    out.b = t;
    break;
case 3:
    out.r = p;
    out.g = q;
    out.b = v;
    break;
case 4:
    out.r = t;
    out.g = p;
    out.b = v;
    break;
case 5:
default:
    out.r = v;
    out.g = p;
    out.b = q;
    break;
}
return out;

}


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#1 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/APIjvP82noKi_lRNz4TawGL1-9slG-yEks5qigyHgaJpZM4JpdZb
.

@dmilos
Copy link
Owner

dmilos commented Aug 23, 2016

What if someone want more precision than two/three numbers?

On Tue, Aug 23, 2016 at 8:07 PM, acterhd [email protected] wrote:

Something wrong.
color::hcg hcgi({ 0.0, 50.0, 100.0 });
I can't use doubles :(


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#1 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/APIjvNkqmSiQ3l86NRwd6Fdpuku0q0Kyks5qizbcgaJpZM4JpdZb
.

@dmilos
Copy link
Owner

dmilos commented Aug 23, 2016

For example some image processing, no alpha channel.
If you try to find average image pre-converted sequence in HCG you will have huge numerical error.

@ghost
Copy link
Author

ghost commented Sep 10, 2016

Full HSX converter, nearly all from worlds!
https://github.com/acterhd/death-color/blob/master/convert/index.js

@dmilos
Copy link
Owner

dmilos commented Sep 15, 2016

Thanks.
I'll take a look.

On Sat, Sep 10, 2016 at 4:25 PM, acterhd [email protected] wrote:

Full HSX converter, nearly all from worlds!
https://github.com/acterhd/death-color/blob/master/convert/index.js


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#1 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/APIjvEhviMGbyuJJQ0WeaEsdYml5vThrks5qor3fgaJpZM4JpdZb
.

@ghost
Copy link
Author

ghost commented Jan 24, 2017

Will support more color models?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant