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

Home » Public Forums » archive » Transparent series of images with axis using cgImage
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
Transparent series of images with axis using cgImage [message #88115] Fri, 21 March 2014 06:01 Go to next message
Petros Syntelis is currently offline  Petros Syntelis
Messages: 32
Registered: June 2013
Member
Hi everybody,

I am trying create three images with axis in a row, and overplot above them a transparent image.
I have a code like this that works fine in the 'X' window case


cgimage, im1 , xr=[..],yr=[..],/axis, /keep ,pos=pos
loadct,3
cgimage, im2 , xr=[..],yr=[..],/axis, /axis, transparent=transparent, /over,pos=pos
...
and is followed by two other similar sets of plots with different position vectors.

When i want to print this to ps. according to the instructions here
https://www.idlcoyote.com/ip_tips/transparentpng.php
, I have to provide a background image.

Now, if i do the trick described in the documentation, and write the code as

cgDisplay, /Pixmap
cgimage, im1 , xr=[..],yr=[..],/axis, /keep ,pos=pos
bgimage1 = cgSnapshot()
WDelete
...

for all three cases, and pass the bgimages to AlphaBackgroundImage, like

cgps_open ...
cgimage, im1 , xr=[..],yr=[..],/axis, /keep ,pos=pos
loadct,3
cgimage, im2 , xr=[..],yr=[..],/axis, /axis, transparent=transparent, /over,pos=pos, AlphaBackgroundImage=bgimage1
...
cgps_close


I have the following problems:
a) The background images does not match the size of the transparent images in the ps file.
b) The characters in the axis are different
which both of them arise i think from the fact that the window size does not match the ps window file.

Has anybody tried to create transparent images with axis and done it correctly?

Regards,
Petros
Re: Transparent series of images with axis using cgImage [message #88116 is a reply to message #88115] Fri, 21 March 2014 06:07 Go to previous messageGo to next message
Petros Syntelis is currently offline  Petros Syntelis
Messages: 32
Registered: June 2013
Member
I upload this file to show you what the problem looks like
https://www.dropbox.com/s/kgkrm9mwlxwnrt5/211_0_0026.png

In this file I have plotted the first image as transparent and the others as not to see the difference.

Cheers,
Petros
Re: Transparent series of images with axis using cgImage [message #88118 is a reply to message #88115] Fri, 21 March 2014 07:41 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Petros Syntelis writes:

> Has anybody tried to create transparent images with axis and done it correctly?

Not this way, no. :-)

Too much going on here for the hacking that has to take place in direct
graphics. I would do this a completely different way. I would write the
program like this:

;****************************************************
PRO Example, PS=ps

; Fake images.
im1 = cgDemoData(7)
im2 = cgDemoData(21)
im3 = cgDemoData(22)
im4 = cgDemoData(5)

; Build composite images.
cgDisplay, 400, 500, WID=2, /Pixmap
cgimage, im1
cgimage, im4, ctindex=33, $
AlphaFGPos=[0.0,0.25,1.0,0.75], transparent=50
snap1 = cgSnapShot()

cgimage, im2
cgimage, im4, ctindex=33, $
AlphaFGPos=[0.0, 0.25, 1.0, 0.75], transparent=50
snap2 = cgSnapShot()

cgimage, im3
cgimage, im4, ctindex=33, $
AlphaFGPos=[0.0, 0.25, 1.0, 0.75], transparent=50
snap3 = cgSnapShot()

; Delete the Pixmap.
WDelete, 2

; Set multimargin and character size values.
mm = 12
cs = 2.25

; Need a PostScript file?
IF Keyword_Set(ps) THEN BEGIN
cgPS_Open, 'example.ps'
mm = 8
cs = 1.75
ENDIF

; Display them.
cgDisplay, 1200, 500

!P.Multi=[0,3,1]
cgimage, snap1, multimargin=mm, /axes, $
OPosition=opos, axkey={charsize:cs}
yrange = opos[3] - opos[1]
p1 = opos[1] + yrange*0.25
p3 = opos[3] - yrange*0.25
cgPlot, [1], /NoData, /NoErase, Charsize=cs, $
Position=[opos[0], p1, opos[2], p3], AxisColor='red'

cgimage, snap2, multimargin=mm, /axes, $
OPosition=opos, axkey={charsize:cs}
yrange = opos[3] - opos[1]
p1 = opos[1] + yrange*0.25
p3 = opos[3] - yrange*0.25
cgPlot, [1], /NoData, /NoErase, Charsize=cs, $
Position=[opos[0], p1, opos[2], p3], AxisColor='red'

cgimage, snap3, multimargin=mm, /axes, OPosition=opos, $
axkey={charsize:cs}
yrange = opos[3] - opos[1]
p1 = opos[1] + yrange*0.25
p3 = opos[3] - yrange*0.25
cgPlot, [1], /NoData, /NoErase, Charsize=cs, $
Position=[opos[0], p1, opos[2], p3], AxisColor='red'

!P.Multi=0

IF Keyword_Set(PS) THEN BEGIN
cgPS_Close, /PNG
ENDIF

END
;****************************************************

To see it on the display:

IDL> Example

To see it in a PostScript and PNG file:

IDL> Example, /PS

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: Transparent series of images with axis using cgImage [message #88120 is a reply to message #88118] Fri, 21 March 2014 09:41 Go to previous message
Petros Syntelis is currently offline  Petros Syntelis
Messages: 32
Registered: June 2013
Member
Thx David!
I'll study your example to sort it out!

Cheers,
Petros

On Friday, March 21, 2014 2:41:35 PM UTC, David Fanning wrote:
> Petros Syntelis writes:
>
>
>
>> Has anybody tried to create transparent images with axis and done it correctly?
>
>
>
> Not this way, no. :-)
>
>
>
> Too much going on here for the hacking that has to take place in direct
>
> graphics. I would do this a completely different way. I would write the
>
> program like this:
>
>
>
> ;****************************************************
>
> PRO Example, PS=ps
>
>
>
> ; Fake images.
>
> im1 = cgDemoData(7)
>
> im2 = cgDemoData(21)
>
> im3 = cgDemoData(22)
>
> im4 = cgDemoData(5)
>
>
>
> ; Build composite images.
>
> cgDisplay, 400, 500, WID=2, /Pixmap
>
> cgimage, im1
>
> cgimage, im4, ctindex=33, $
>
> AlphaFGPos=[0.0,0.25,1.0,0.75], transparent=50
>
> snap1 = cgSnapShot()
>
>
>
> cgimage, im2
>
> cgimage, im4, ctindex=33, $
>
> AlphaFGPos=[0.0, 0.25, 1.0, 0.75], transparent=50
>
> snap2 = cgSnapShot()
>
>
>
> cgimage, im3
>
> cgimage, im4, ctindex=33, $
>
> AlphaFGPos=[0.0, 0.25, 1.0, 0.75], transparent=50
>
> snap3 = cgSnapShot()
>
>
>
> ; Delete the Pixmap.
>
> WDelete, 2
>
>
>
> ; Set multimargin and character size values.
>
> mm = 12
>
> cs = 2.25
>
>
>
> ; Need a PostScript file?
>
> IF Keyword_Set(ps) THEN BEGIN
>
> cgPS_Open, 'example.ps'
>
> mm = 8
>
> cs = 1.75
>
> ENDIF
>
>
>
> ; Display them.
>
> cgDisplay, 1200, 500
>
>
>
> !P.Multi=[0,3,1]
>
> cgimage, snap1, multimargin=mm, /axes, $
>
> OPosition=opos, axkey={charsize:cs}
>
> yrange = opos[3] - opos[1]
>
> p1 = opos[1] + yrange*0.25
>
> p3 = opos[3] - yrange*0.25
>
> cgPlot, [1], /NoData, /NoErase, Charsize=cs, $
>
> Position=[opos[0], p1, opos[2], p3], AxisColor='red'
>
>
>
> cgimage, snap2, multimargin=mm, /axes, $
>
> OPosition=opos, axkey={charsize:cs}
>
> yrange = opos[3] - opos[1]
>
> p1 = opos[1] + yrange*0.25
>
> p3 = opos[3] - yrange*0.25
>
> cgPlot, [1], /NoData, /NoErase, Charsize=cs, $
>
> Position=[opos[0], p1, opos[2], p3], AxisColor='red'
>
>
>
> cgimage, snap3, multimargin=mm, /axes, OPosition=opos, $
>
> axkey={charsize:cs}
>
> yrange = opos[3] - opos[1]
>
> p1 = opos[1] + yrange*0.25
>
> p3 = opos[3] - yrange*0.25
>
> cgPlot, [1], /NoData, /NoErase, Charsize=cs, $
>
> Position=[opos[0], p1, opos[2], p3], AxisColor='red'
>
>
>
> !P.Multi=0
>
>
>
> IF Keyword_Set(PS) THEN BEGIN
>
> cgPS_Close, /PNG
>
> ENDIF
>
>
>
> END
>
> ;****************************************************
>
>
>
> To see it on the display:
>
>
>
> IDL> Example
>
>
>
> To see it in a PostScript and PNG file:
>
>
>
> IDL> Example, /PS
>
>
>
> 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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: how to convert a segmented image to _polygons_ and save it in a single ROI or .evf file?
Next Topic: Killing Widget Objects

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

Current Time: Wed Oct 08 15:48:14 PDT 2025

Total time taken to generate the page: 0.00252 seconds