Open ghost opened 8 years ago
Hello Thank you for interest for color library.
Adding new model I not so trivial. Here is possible steps:
... 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 notifications@github.com 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 https://github.com/dmilos/color/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/APIjvCTJr7q65bqnswOQOL29qt8nax4fks5qiQYggaJpZM4JpdZb .
I use use both.
On Mon, Aug 22, 2016 at 9:38 PM, acterhd notifications@github.com wrote:
You using GCC? No Visual Studio?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dmilos/color/issues/1#issuecomment-241525403, or mute the thread https://github.com/notifications/unsubscribe-auth/APIjvNZqDf_k_WLOlrxKQryKULv2TuK0ks5qifq_gaJpZM4JpdZb .
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 notifications@github.com 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 https://github.com/dmilos/color/issues/1#issuecomment-241529849, or mute the thread https://github.com/notifications/unsubscribe-auth/APIjvI87W9D5OQf0mD0Gg1LKk_W17Coqks5qif6GgaJpZM4JpdZb .
Perfect. Thanks.
On Mon, Aug 22, 2016 at 10:54 PM, acterhd notifications@github.com 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 https://github.com/dmilos/color/issues/1#issuecomment-241547080, or mute the thread https://github.com/notifications/unsubscribe-auth/APIjvP82noKi_lRNz4TawGL1-9slG-yEks5qigyHgaJpZM4JpdZb .
What if someone want more precision than two/three numbers?
On Tue, Aug 23, 2016 at 8:07 PM, acterhd notifications@github.com 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 https://github.com/dmilos/color/issues/1#issuecomment-241822028, or mute the thread https://github.com/notifications/unsubscribe-auth/APIjvNkqmSiQ3l86NRwd6Fdpuku0q0Kyks5qizbcgaJpZM4JpdZb .
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.
Full HSX converter, nearly all from worlds! https://github.com/acterhd/death-color/blob/master/convert/index.js
Thanks. I'll take a look.
On Sat, Sep 10, 2016 at 4:25 PM, acterhd notifications@github.com 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 https://github.com/dmilos/color/issues/1#issuecomment-246114485, or mute the thread https://github.com/notifications/unsubscribe-auth/APIjvEhviMGbyuJJQ0WeaEsdYml5vThrks5qor3fgaJpZM4JpdZb .
Will support more color models?
I looked to code - too hard... I beg to help implement HCG color model for your library. https://github.com/acterhd/hcg-color