Keep getting a transparent background on a composite image [message #90736] |
Wed, 08 April 2015 14:26  |
simulana
Messages: 15 Registered: August 2012
|
Junior Member |
|
|
http://user.physics.unc.edu/~chaig/research/images/040815/2d amr1-3_paper.png
Yet another puzzler. I would like a white background instead of transparent, but I can't quite figure out to get it. Further mystery - cgImage plots have a white background, but the cgcolorbar part does not. Is it something in my device command? Is it because I set my own color table? All I know from other forums is that I apparently have something that other people want, but I don't want.
For brevity, I won't post the whole code with all 9 images:
set_plot,'ps'
r = Interpol([ 255, 0, 0, 0,255,234,107,0], [0, 36, 73,110,147,184,220,255], Findgen(256))
g = Interpol([ 255, 0,255,126,255, 82, 0,0], [0, 36, 73,110,147,184,220,255], Findgen(256))
b = Interpol([ 255,91,255, 0, 0, 0, 0,0], [0, 36, 73,110,147,184,220,255], Findgen(256))
TVLCT, r, g, b
device,filename='2damr1-3_paper.eps',/color,bits=8,/encaps,x size=xsizecm,ysize=ysizecm,decomposed=0
cgimage, image(0,*,*), /DEVICE, /SCALE,/AXES ,$
position=position1,$
xrange=[-6.25,6.25],yrange=[-8.545,8.545],ytitle='[pc]',$
color='black',charsize=4,/KEEP_ASPECT_RATIO,$
AXKEYWORDS={CHARTHICK:10,xthick:5,ythick:5,xtickformat:'(A1) '},/noerase
cgimage, image(1,*,*), /DEVICE, /SCALE,/AXES ,$
position=position2,xrange=[-6.25,6.25],yrange=[-8.545,8.545] ,$
color='black',charsize=4,/KEEP_ASPECT_RATIO,$
AXKEYWORDS={CHARTHICK:10,xthick:5,ythick:5,ytickformat:'(A1) ',xtickformat:'(A1)'},/noerase
cgimage, image(2,*,*), /DEVICE, /SCALE,/AXES ,$
position=position3,xrange=[-6.25,6.25],yrange=[-8.545,8.545] ,$
color='black',charsize=4,/KEEP_ASPECT_RATIO,$
AXKEYWORDS={CHARTHICK:10,xthick:5,ythick:5,ytickformat:'(A1) ',xtickformat:'(A1)'},/noerase
ticks=loglevels([30,4000],/Fine)
nticks = n_elements(ticks)
cgColorbar,Range=[30,4000],Title='Density (cm!e-3!n)',Position=[0.87, 0.2, 0.90, 0.8],$
/ylog,/vertical,yticks=nticks-1,ytickv=ticks,charsize=5,char thick=13,/right
|
|
|
Re: Keep getting a transparent background on a composite image [message #90741 is a reply to message #90736] |
Wed, 08 April 2015 16:35   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
simulana@gmail.com writes:
> Yet another puzzler. I would like a white background instead of transparent, but I can't quite figure out to get it. Further mystery - cgImage plots have a white background, but the cgcolorbar part does not. Is it something in my device command? Is it because I set my own color table? All I know from other forums is that I apparently have something that other people want, but I don't want.
>
> For brevity, I won't post the whole code with all 9 images:
> set_plot,'ps'
> r = Interpol([ 255, 0, 0, 0,255,234,107,0], [0, 36, 73,110,147,184,220,255], Findgen(256))
> g = Interpol([ 255, 0,255,126,255, 82, 0,0], [0, 36, 73,110,147,184,220,255], Findgen(256))
> b = Interpol([ 255,91,255, 0, 0, 0, 0,0], [0, 36, 73,110,147,184,220,255], Findgen(256))
> TVLCT, r, g, b
> device,filename='2damr1-3_paper.eps',/color,bits=8,/encaps,x size=xsizecm,ysize=ysizecm,decomposed=0
> cgimage, image(0,*,*), /DEVICE, /SCALE,/AXES ,$
> position=position1,$
> xrange=[-6.25,6.25],yrange=[-8.545,8.545],ytitle='[pc]',$
> color='black',charsize=4,/KEEP_ASPECT_RATIO,$
> AXKEYWORDS={CHARTHICK:10,xthick:5,ythick:5,xtickformat:'(A1) '},/noerase
> cgimage, image(1,*,*), /DEVICE, /SCALE,/AXES ,$
> position=position2,xrange=[-6.25,6.25],yrange=[-8.545,8.545] ,$
> color='black',charsize=4,/KEEP_ASPECT_RATIO,$
> AXKEYWORDS={CHARTHICK:10,xthick:5,ythick:5,ytickformat:'(A1) ',xtickformat:'(A1)'},/noerase
> cgimage, image(2,*,*), /DEVICE, /SCALE,/AXES ,$
> position=position3,xrange=[-6.25,6.25],yrange=[-8.545,8.545] ,$
> color='black',charsize=4,/KEEP_ASPECT_RATIO,$
> AXKEYWORDS={CHARTHICK:10,xthick:5,ythick:5,ytickformat:'(A1) ',xtickformat:'(A1)'},/noerase
>
> ticks=loglevels([30,4000],/Fine)
> nticks = n_elements(ticks)
> cgColorbar,Range=[30,4000],Title='Density (cm!e-3!n)',Position=[0.87, 0.2, 0.90, 0.8],$
> /ylog,/vertical,yticks=nticks-1,ytickv=ticks,charsize=5,char thick=13,/right
I can't really figure out what question you are asking. But, it is
probably a mistake to use both the POSITION keyword and the
KEEP_ASPECT_RATIO keyword on the same cgImage command.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
|
Re: Keep getting a transparent background on a composite image [message #90746 is a reply to message #90745] |
Wed, 08 April 2015 19:12   |
simulana
Messages: 15 Registered: August 2012
|
Junior Member |
|
|
Technically I found a solution, though I wouldn't call it ideal.
If I set decomposed=1, and then use a polyfill command, I can fake a white background:
PolyFill, [0,0,1,1,0], $
[0,1,1,0,0], $
COLOR='ffffff'x, /NORMAL
I feel like there must be a better way, however.
|
|
|
Re: Keep getting a transparent background on a composite image [message #90747 is a reply to message #90745] |
Wed, 08 April 2015 19:12   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
simulana@gmail.com writes:
> It's hard to see the problem if you open up the png on a browser, because the browser natively has a white background. However if you open up the png with a photoviewer like Picasa or against a black background you will see that the background of the border of the image is transparent (anywhere there is not a cgimage plot).
>
> So I guess my problem has something to do with the device command, or some other thing missing. I have tried setting !P.Background, but with no apparent effect.
Well, I've tried a number of photo viewers, but I have to admit I don't
see any problems with the output. I put it in Lightroom, which has a
black background, and I don't see any black at all around the border of
any image. In fact, the PNG image appears to me to have a white
background, as I would expect from a PNG created from a PostScript file.
If you are saying that your images don't always fill up your image
positions, I can believe that. That would be a result of using the two
keywords I mentioned before simultaneously and would be a mistake.
Anyway, still not sure what your real question is. The output looks
great to me.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
Re: Keep getting a transparent background on a composite image [message #90752 is a reply to message #90747] |
Thu, 09 April 2015 06:12   |
simulana
Messages: 15 Registered: August 2012
|
Junior Member |
|
|
On Wednesday, April 8, 2015 at 10:12:54 PM UTC-4, David Fanning wrote:
> simulana@gmail.com writes:
>
>> It's hard to see the problem if you open up the png on a browser, because the browser natively has a white background. However if you open up the png with a photoviewer like Picasa or against a black background you will see that the background of the border of the image is transparent (anywhere there is not a cgimage plot).
>>
>> So I guess my problem has something to do with the device command, or some other thing missing. I have tried setting !P.Background, but with no apparent effect.
>
> Well, I've tried a number of photo viewers, but I have to admit I don't
> see any problems with the output. I put it in Lightroom, which has a
> black background, and I don't see any black at all around the border of
> any image. In fact, the PNG image appears to me to have a white
> background, as I would expect from a PNG created from a PostScript file.
>
> If you are saying that your images don't always fill up your image
> positions, I can believe that. That would be a result of using the two
> keywords I mentioned before simultaneously and would be a mistake.
>
> Anyway, still not sure what your real question is. The output looks
> great to me.
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
I see now that my problem is a photoviewer software problem instead of an IDL problem. I retract the question.
|
|
|
|
|