|
From: Theo H. <th...@ph...> - 2005-08-18 19:28:51
|
Theo Hopman wrote:
> I can conceive of a possible workaround: rather than encoding colours as
> rrrrrrrrggggggggbbbbbbbb, they could be encoded as something like
> grbgrbgrbgrbgrbgrbgrbgrb, so that the MSBs of the green and blue
> channels are not lost in palette sampling. I'll give this a shot sometime.
Meh...this doesn't work as well as I think it should. The various
paletted terminals agree better now, but the colours are still wrong,
though not as disastrously as before. Oddly, the truecolour png terminal
no longer gives results as good as before. Perhaps there's some flaw in
my encoding/decoding logic, but I can't see it, as is usually the case
with logic flaws. Also, some of the dots are drawn as open circles,
rather than filled. What the deal with that?
encode(c,n)=(n==1 ? (int(c)&1) : ((int(c)&1) + 8*encode(int(c)/2,n-1)) )
decode(c,n)=(n==1 ? (int(c)&1) : ((int(c)&1) + 2*decode(int(c)/8,n-1)) )
# The encode() and decode() functions use recursion to iterate over n
# bits. encode() replaces each bit with either 000 or 001; decode() does
# the reverse.
# e.g. encode(7,8) == 73 == 001 001 001
# encode(4,8) == 64 == 001 000 000
# encode(128,8) == 2097152
# encode(255,8) == 2396745 == 2^21 + 2^18 + 2^15 + ... + 2^0
# encode(256,8) == 0
rgb(r,g,b)=4*encode(g,8)+2*encode(r,8)+encode(b,8)
red(gray)=decode(int(gray*2**24)/2,8)/256.
green(gray)=decode(int(gray*2**24)/4,8)/256.
blue(gray)=decode(int(gray*2**24),8)/256.
set palette color model RGB functions red(gray), green(gray), blue(gray)
set cbrange [0:2**24-1]
unset colorbox
set ticslevel 0
splot 'colour-data.txt' using 1:2:3:(log($4)):(rgb($1,$2,$3)) \
with points pointtype 7 pointsize variable palette
THeo
|