From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/74230 Path: news.gmane.org!not-for-mail From: Frank Schmitt Newsgroups: gmane.emacs.gnus.general Subject: Re: Colour manipulation Date: Sun, 21 Nov 2010 20:57:43 +0100 Organization: Hamme net, kren mer och nimmi Message-ID: <87d3pyfo08.fsf@mid.gehheimdienst.de> References: <87pquvldcs.fsf@lifelogs.com> <87oc9yp21w.fsf@lifelogs.com> <87lj4pmgu7.fsf@keller.adm.naquadah.org> <87oc9ihjbk.fsf@keller.adm.naquadah.org> <8739quh5gk.fsf@keller.adm.naquadah.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1290369569 25339 80.91.229.12 (21 Nov 2010 19:59:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 21 Nov 2010 19:59:29 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M22595@lists.math.uh.edu Sun Nov 21 20:59:25 2010 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PKG4J-00076J-IR for ding-account@gmane.org; Sun, 21 Nov 2010 20:59:24 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1PKG47-0006tp-6f; Sun, 21 Nov 2010 13:59:11 -0600 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1PKG45-0006te-Se for ding@lists.math.uh.edu; Sun, 21 Nov 2010 13:59:09 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1PKG44-0003d6-2N for ding@lists.math.uh.edu; Sun, 21 Nov 2010 13:59:09 -0600 Original-Received: from lo.gmane.org ([80.91.229.12]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1PKG43-0005Gq-00 for ; Sun, 21 Nov 2010 20:59:07 +0100 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PKG42-0006uu-OT for ding@gnus.org; Sun, 21 Nov 2010 20:59:06 +0100 Original-Received: from zoidberg.uni-koblenz.de ([141.26.69.172]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 21 Nov 2010 20:59:06 +0100 Original-Received: from ich by zoidberg.uni-koblenz.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 21 Nov 2010 20:59:06 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 99 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: zoidberg.uni-koblenz.de X-Face: :EL9TzGRN){7|oE2~xQ8Q(VjpjsXgX$~gi&rYD5J5p)$w\Thdl~v:7h`/n)J!8nXT%_+Wj6}@EHM8}QbA(9nX-wrQ:ch1%DauV[?kFasXUcnL#+"K8zOx&$@/M'/},q-eztaJra1|?C+p$h\2XnK-HB"8_U Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:74230 Archived-At: Julien Danjou writes: > I did not write any lab->rgb function, but that's totally doable if > needed. :) But it is a bit of a mess, as you have to go via CIE-XYZ first. I did this in C++ some time ago. lab->rgb: double var_Y = (lab.l + 16.0) / 116.0; double var_X = lab.a / 500.0 + var_Y; double var_Z = var_Y - lab.b / 200.0; if ( pow(var_Y,3) > 0.008856 ) var_Y = pow(var_Y,3); else var_Y = (var_Y - 0.137931034482758620689655172413793103448275862068965517241379) / 7.787; if ( pow(var_X,3) > 0.008856 ) var_X = pow(var_X,3); else var_X = (var_X - 0.137931034482758620689655172413793103448275862068965517241379) / 7.787; if ( pow(var_Z,3) > 0.008856 ) var_Z = pow(var_Z,3); else var_Z = (var_Z - 0.137931034482758620689655172413793103448275862068965517241379) / 7.787; double var_R = var_X * 3.0800930820000003 + var_Y * -1.5372 + var_Z * -0.54289063799999993; double var_G = var_X * -0.92091038300000005 + var_Y * 1.8758 + var_Z * 0.045186444999999999; double var_B = var_X * 0.052941179000000005 + var_Y * -0.2040 + var_Z * 1.1508933099999998; double r = pow(var_R, 0.45454545454545453) * 255; if (r<0) rgb.red = 0; else if (r>255) rgb.red = 255; else rgb.red = (UINT8)r; double g = pow(var_G, 0.45454545454545453) * 255; if (g<0) rgb.green = 0; else if (g>255) rgb.green = 255; else rgb.green = (UINT8)g; double b = pow(var_B, 0.45454545454545453) * 255; if (b<0) rgb.blue = 0; else if (b>255) rgb.blue = 255; else rgb.blue = (UINT8)b; rgb->lab double var_R = rgb.red / 255.0; double var_G = rgb.green / 255.0; double var_B = rgb.blue / 255.0; if (var_R > 0.04045) var_R = pow(((var_R + 0.055) / 1.055), 2.4); else var_R = var_R / 12.92; if (var_G > 0.04045) var_G = pow(((var_G + 0.055) / 1.055), 2.4); else var_G = var_G / 12.92; if (var_B > 0.04045) var_B = pow(((var_B + 0.055) / 1.055), 2.4); else var_B = var_B / 12.92; //Includes division by reference white //Observer. = 2°, Illuminant = D65 double var_X = var_R * 0.43389060149189346 + var_G * 0.37623491535766512 + var_B * 0.18990604648226667; double var_Y = var_R * 0.2126 + var_G * 0.7152 + var_B * 0.0722; double var_Z = var_R * 0.017725448417108273 + var_G * 0.10947530835851327 + var_B * 0.87295537411717172; if (var_X > 0.008856) var_X = pow(var_X, 0.333333333333333333333333333333333333333333333333333333333333); else var_X = (7.787 * var_X) + (0.137931034482758620689655172413793103448275862068965517241379); if (var_Y > 0.008856 ) var_Y = pow(var_Y, 0.333333333333333333333333333333333333333333333333333333333333); else var_Y = (7.787 * var_Y) + (0.137931034482758620689655172413793103448275862068965517241379); // 16.0/116 if (var_Z > 0.008856) var_Z = pow(var_Z, 0.333333333333333333333333333333333333333333333333333333333333); else var_Z = (7.787 * var_Z) + (0.137931034482758620689655172413793103448275862068965517241379); lab.l = (float)((116 * var_Y) - 16); lab.a = (float)(500 * (var_X - var_Y)); lab.b = (float)(200 * (var_Y - var_Z)); -- Have you ever considered how much text can fit in eighty columns? Given that a signature typically contains up to four lines of text, this space allows you to attach a tremendous amount of valuable information to your messages. Seize the opportunity and don't waste your signature on bullshit that nobody cares about.