comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Any suggestions for a B&W colour scheme for publication images?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Any suggestions for a B&W colour scheme for publication images? [message #55936] Tue, 25 September 2007 08:30
Steve Eddins is currently offline  Steve Eddins
Messages: 9
Registered: July 2001
Junior Member
hradilv wrote:
> On Sep 25, 9:25 am, Tyler <hayes.ty...@gmail.com> wrote:
>> Hello All:
>>
>> I am in the process of submitting some figures to a journal for
>> publication (it has been accepted). I intend to save my supervisor
>> cash by submitting B&W figures for print, and keep the colour images
>> for the electronic version.
>>
>> Here is my problem. Originally, I've been using one of the EOS colour
>> schemes and the figures turn out great. There is excellent contrast
>> between regions, and the positive/negative values are clearly
>> distinguished. Sadly, switching the colour scheme to B&W tends to blur
>> these crucial distinct regions.
>>
>> [snip]
>
> Here's a reference: J. McNames, "An effective color scale for
> simultaneous color and gray-scale publications," IEEE Signal
> Processing Magazine, Vol. 23, No. 1, January 2006, pp. 82-87. (pdf:
> http://bsp.pdx.edu/Publications/2006/SPM_McNames.pdf)

I had a bit of correspondence with McNames about this article. It turns
out that his formulas assume a relationship between RGB and gray scale
that isn't quite accurate enough to get a fully monotonic scale in gray.

An alternative idea to plot a path through L*a*b* space, as I described
here:

http://blogs.mathworks.com/steve/2006/05/09/a-lab-based-unif orm-color-scale/

Since I don't know IDL, I can't provide a translation :-), but if you
have a way to convert between sRGB and L*a*b*, the rest of the math is
straightforward.

--
Steve Eddins
http://blogs.mathworks.com/steve
Re: Any suggestions for a B&W colour scheme for publication images? [message #55937 is a reply to message #55936] Tue, 25 September 2007 08:07 Go to previous message
Tyler is currently offline  Tyler
Messages: 5
Registered: September 2007
Junior Member
Wow! That was some quick response.

Thanks everyone for your suggestions. I will be trying them out
directly :)

Cheers,

t.
Re: Any suggestions for a B&W colour scheme for publication images? [message #55938 is a reply to message #55937] Tue, 25 September 2007 08:05 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Good suggestions. If this doesn't work, I'd also try converting
> your RGB color vectors to HSV vectors with COLOR_CONVERT, then
> stretching your saturation vector as far as it will go, before
> converting back and loading into your color table. That's been
> known to work before, too, although sometimes the saturation
> is already stretched to the max anyway. (It was in the couple
> of color tables I just tried.)

I suppose you could try doing various log and power transformations
on the saturation vector. Here are a list of programs you can
find on my web page that might come in handy:

GMASCL
LOGSCL
ASINCSCL
CLIPSCL
GAUSSSCL

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Any suggestions for a B&W colour scheme for publication images? [message #55939 is a reply to message #55938] Tue, 25 September 2007 08:03 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Sep 25, 10:01 am, hradilv <hrad...@yahoo.com> wrote:
> On Sep 25, 9:25 am, Tyler <hayes.ty...@gmail.com> wrote:
>
>
>
>> Hello All:
>
>> I am in the process of submitting some figures to a journal for
>> publication (it has been accepted). I intend to save my supervisor
>> cash by submitting B&W figures for print, and keep the colour images
>> for the electronic version.
>
>> Here is my problem. Originally, I've been using one of the EOS colour
>> schemes and the figures turn out great. There is excellent contrast
>> between regions, and the positive/negative values are clearly
>> distinguished. Sadly, switching the colour scheme to B&W tends to blur
>> these crucial distinct regions.
>
>> I have tried several values for STRETCH. Perhaps I was not using the
>> STRETCH command properly. Does anyone have any suggestions for values
>> of STRETCH or GAMMA_CT that have worked for their own publications in
>> the past? This problem is only further compounded by the fact that
>> XLOADCT seems to not want to load from my IDL script file, so I'm
>> limited to what I can do from the within the script.
>
>> For what it's worth, I have several figures to convert to B&W, all of
>> which have different maximums and minimums. Can I use that knowledge
>> to control STRETCH/GAMMA_CT with these values?
>
>> I have two example PNG files I can send to anyone if they would like
>> to see what I am talking about. Just email me with "GAMMA_CT" in the
>> subject heading.
>
>> Any ideas are greatly appreciated.
>
>> Cheers,
>
>> t.
>
> Here's a reference: J. McNames, "An effective color scale for
> simultaneous color and gray-scale publications," IEEE Signal
> Processing Magazine, Vol. 23, No. 1, January 2006, pp. 82-87. (pdf:http://bsp.pdx.edu/Publications/2006/SPM_McNames.pdf)
>
> I translated the matlab code here:
>
> function hyperbola, nc, ymaxa=ymaxa
>
> if n_elements(ymaxa) eq 0 then ymaxa=0.95
>
> a = sqrt( (1.0-ymaxa)^2 / (1.0-(1.0-ymaxa)^2) )
> xvals = findgen(nc)
> xs = 2.0 * xvals/float(nc-1) - 1.0 ; scale from -1 to 1
> nx = n_elements(xvals)
>
> y = 1.0 - sqrt(xs^2+a^2)/sqrt(1.0+a^2)
> y = y>0.0
>
> return, y
> end
>
> function triangle, nc
>
> result = findgen(nc/2)/float(nc/2-1)
> result = [result,reverse(result)]
>
> return, result
> end
>
> function colorspiral, nc, np, palname, smin=smin, twosided=twosided
>
> if n_elements(smin) eq 0 then smin=0
>
> ;nc=128
> ;np=2
>
> wn = sqrt(3.0/8.0) * hyperbola(nc)
> a12 = asin(1.0/sqrt(3.0))
> a23 = !pi/4.0
>
> if keyword_set(twosided) then begin
> t = sqrt(3.0)*findgen(nc/2)/float(nc/2-1)
> t = [-reverse(t),t]
> wn = [reverse(wn),wn]
> endif else begin
> t = sqrt(3.0)*findgen(nc)/float(nc-1)
> endelse
>
> r0 = abs(t)
> g0 = wn * cos((t-sqrt(3.0)/2.0)*np*2.0*!pi/sqrt(3.0))
> b0 = wn * sin((t-sqrt(3.0)/2.0)*np*2.0*!pi/sqrt(3.0))
>
> pm, 3, 3
> plot, r0, g0
> plot, r0, b0
> plot, g0, b0
>
> rgpol = cv_coord(from_rect=transpose([[r0],[g0]]),/to_polar)
> rg1 = cv_coord(from_polar=[rgpol[0,*]+a12,rgpol[1,*]],/to_rect)
> r1 = reform(rg1[0,*])
> g1 = reform(rg1[1,*])
> b1 = b0
>
> plot, r1, g1
> plot, r1, b1
> plot, g1, b1
>
> rbpol = cv_coord(from_rect=transpose([[r1],[b1]]),/to_polar)
> rb2 = cv_coord(from_polar=[rbpol[0,*]+a23,rbpol[1,*]],/to_rect)
> r2 = reform(rb2[0,*])
> g2 = g1
> b2 = reform(rb2[1,*])
>
> plot, r2, g2
> plot, r2, b2
> plot, g2, b2
>
> spiral = bytscl([[r2],[g2],[b2]])
>
> ;smin = 0
> smax = nc-smin-1
>
> spiral = congrid(spiral[smin:smax,*],nc,3)
>
> openw, lun, palname+'.pal', /get_lun
> printf, lun, palname
> for i=nc-1, 0, -1 do printf, lun, string(format='("#",3z2.2)',spiral[i,
> 0],spiral[i,1],spiral[i,2])
> free_lun, lun
>
> return, spiral
> end

Oops, forgot to mention that you can remove the plot commands
(diagnostics) and also that I write out the palette for use with
AFNI. But you get the idea.
Re: Any suggestions for a B&W colour scheme for publication images? [message #55940 is a reply to message #55939] Tue, 25 September 2007 08:01 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Sep 25, 9:25 am, Tyler <hayes.ty...@gmail.com> wrote:
> Hello All:
>
> I am in the process of submitting some figures to a journal for
> publication (it has been accepted). I intend to save my supervisor
> cash by submitting B&W figures for print, and keep the colour images
> for the electronic version.
>
> Here is my problem. Originally, I've been using one of the EOS colour
> schemes and the figures turn out great. There is excellent contrast
> between regions, and the positive/negative values are clearly
> distinguished. Sadly, switching the colour scheme to B&W tends to blur
> these crucial distinct regions.
>
> I have tried several values for STRETCH. Perhaps I was not using the
> STRETCH command properly. Does anyone have any suggestions for values
> of STRETCH or GAMMA_CT that have worked for their own publications in
> the past? This problem is only further compounded by the fact that
> XLOADCT seems to not want to load from my IDL script file, so I'm
> limited to what I can do from the within the script.
>
> For what it's worth, I have several figures to convert to B&W, all of
> which have different maximums and minimums. Can I use that knowledge
> to control STRETCH/GAMMA_CT with these values?
>
> I have two example PNG files I can send to anyone if they would like
> to see what I am talking about. Just email me with "GAMMA_CT" in the
> subject heading.
>
> Any ideas are greatly appreciated.
>
> Cheers,
>
> t.

Here's a reference: J. McNames, "An effective color scale for
simultaneous color and gray-scale publications," IEEE Signal
Processing Magazine, Vol. 23, No. 1, January 2006, pp. 82-87. (pdf:
http://bsp.pdx.edu/Publications/2006/SPM_McNames.pdf)

I translated the matlab code here:

function hyperbola, nc, ymaxa=ymaxa

if n_elements(ymaxa) eq 0 then ymaxa=0.95

a = sqrt( (1.0-ymaxa)^2 / (1.0-(1.0-ymaxa)^2) )
xvals = findgen(nc)
xs = 2.0 * xvals/float(nc-1) - 1.0 ; scale from -1 to 1
nx = n_elements(xvals)

y = 1.0 - sqrt(xs^2+a^2)/sqrt(1.0+a^2)
y = y>0.0

return, y
end

function triangle, nc

result = findgen(nc/2)/float(nc/2-1)
result = [result,reverse(result)]

return, result
end

function colorspiral, nc, np, palname, smin=smin, twosided=twosided

if n_elements(smin) eq 0 then smin=0

;nc=128
;np=2

wn = sqrt(3.0/8.0) * hyperbola(nc)
a12 = asin(1.0/sqrt(3.0))
a23 = !pi/4.0

if keyword_set(twosided) then begin
t = sqrt(3.0)*findgen(nc/2)/float(nc/2-1)
t = [-reverse(t),t]
wn = [reverse(wn),wn]
endif else begin
t = sqrt(3.0)*findgen(nc)/float(nc-1)
endelse

r0 = abs(t)
g0 = wn * cos((t-sqrt(3.0)/2.0)*np*2.0*!pi/sqrt(3.0))
b0 = wn * sin((t-sqrt(3.0)/2.0)*np*2.0*!pi/sqrt(3.0))

pm, 3, 3
plot, r0, g0
plot, r0, b0
plot, g0, b0

rgpol = cv_coord(from_rect=transpose([[r0],[g0]]),/to_polar)
rg1 = cv_coord(from_polar=[rgpol[0,*]+a12,rgpol[1,*]],/to_rect)
r1 = reform(rg1[0,*])
g1 = reform(rg1[1,*])
b1 = b0

plot, r1, g1
plot, r1, b1
plot, g1, b1

rbpol = cv_coord(from_rect=transpose([[r1],[b1]]),/to_polar)
rb2 = cv_coord(from_polar=[rbpol[0,*]+a23,rbpol[1,*]],/to_rect)
r2 = reform(rb2[0,*])
g2 = g1
b2 = reform(rb2[1,*])

plot, r2, g2
plot, r2, b2
plot, g2, b2

spiral = bytscl([[r2],[g2],[b2]])

;smin = 0
smax = nc-smin-1

spiral = congrid(spiral[smin:smax,*],nc,3)

openw, lun, palname+'.pal', /get_lun
printf, lun, palname
for i=nc-1, 0, -1 do printf, lun, string(format='("#",3z2.2)',spiral[i,
0],spiral[i,1],spiral[i,2])
free_lun, lun

return, spiral
end
Re: Any suggestions for a B&W colour scheme for publication images? [message #55941 is a reply to message #55940] Tue, 25 September 2007 07:57 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
R.G. Stockwell writes:

> I do the same thing. Usually I can just use the default B&W scheme
> (loadct,0) and natively create the image that way. Perhaps reducing
> the number of contour or shade levels will help the contrast. Or perhaps
> adding a contour overlay on top of the image may help.
>
> One trick that sometimes works (but usually doesn't) is to
> use your normal color scheme (EOS) but not set the /color keyword to
> the ps device command. That seems to directly translate your color scheme
> into B&W. The problem, is that distinct colors can get mapped to similar
> shades of grey.

Good suggestions. If this doesn't work, I'd also try converting
your RGB color vectors to HSV vectors with COLOR_CONVERT, then
stretching your saturation vector as far as it will go, before
converting back and loading into your color table. That's been
known to work before, too, although sometimes the saturation
is already stretched to the max anyway. (It was in the couple
of color tables I just tried.)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Any suggestions for a B&W colour scheme for publication images? [message #55942 is a reply to message #55941] Tue, 25 September 2007 07:45 Go to previous message
R.G.Stockwell is currently offline  R.G.Stockwell
Messages: 163
Registered: October 2004
Senior Member
"Tyler" <hayes.tyler@gmail.com> wrote in message
news:1190730302.624006.228950@d55g2000hsg.googlegroups.com.. .
> Hello All:
>
> I am in the process of submitting some figures to a journal for
> publication (it has been accepted). I intend to save my supervisor
> cash by submitting B&W figures for print, and keep the colour images
> for the electronic version.


I do the same thing. Usually I can just use the default B&W scheme
(loadct,0) and natively create the image that way. Perhaps reducing
the number of contour or shade levels will help the contrast. Or perhaps
adding a contour overlay on top of the image may help.

One trick that sometimes works (but usually doesn't) is to
use your normal color scheme (EOS) but not set the /color keyword to
the ps device command. That seems to directly translate your color scheme
into B&W. The problem, is that distinct colors can get mapped to similar
shades of grey.

Cheers,
bob
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Mosaic_doit
Next Topic: int of pixel and surrounding pixels

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 20:40:19 PDT 2025

Total time taken to generate the page: 0.66819 seconds