Difference between revisions of "Stereo ray"

From PyMOLWiki
Jump to navigation Jump to search
(some rearrangements)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{Infobox script-repo
 +
|type      = script
 +
|filename  = stereo_ray.py
 +
|author    = [[User:Inchoate|Jason Vertrees]]
 +
|license  = -
 +
}}
 +
 +
This scripts provides the [[stereo_ray]] command, which saves two ray traced images in PNG format.
 +
The left image is rotated +3 degrees and the right image is rotated -3 degrees.
 +
 +
''Note that the end result is almost identical to using "walleye" [[stereo]] mode, which might be more convenient and is readily available in PyMOL.''
 +
 +
== Usage ==
 +
 +
stereo_ray filename [, width [, height ]]
 +
 +
== Example ==
 +
 +
<syntaxhighlight lang="python">
 +
import stereo_ray
 +
stereo_ray output, 1000, 600
 +
</syntaxhighlight>
 +
 +
This will create two images, "output_l.png" and "output_r.png". Just paste the two images next to each other (in some image editing program) and you're done.
 +
 
[[Image:Stereo_ex_l.png|Left Image|200px|thumb|left]]
 
[[Image:Stereo_ex_l.png|Left Image|200px|thumb|left]]
 
[[Image:Stereo_ex_r.png|Right Image|200px|thumb|right]]
 
[[Image:Stereo_ex_r.png|Right Image|200px|thumb|right]]
 
[[Image:Stereo_complete.png|Combined Images|center|thumb|250px]]
 
[[Image:Stereo_complete.png|Combined Images|center|thumb|250px]]
 
<br clear="all" />
 
<br clear="all" />
 +
 
== Manually ==
 
== Manually ==
  
To get a stereo diagram you need two images. The left image is rotated +3 degrees and the right image is rotated -3 degrees.
+
To obtain the same result without the script, use the [[ray]] and the [[png]] command like this:
  
To obtain the left image, type:
 
 
  ray angle=+3
 
  ray angle=+3
 
  png left-image.png
 
  png left-image.png
Likewise, to obtain the right image, type:
 
 
  ray angle=-3
 
  ray angle=-3
 
  png right-image.png
 
  png right-image.png
  
You still use any other [[ray]] based modifications, such as:
+
Obtain almost the same result using the [[stereo]] command:
ray 1600,1200,angle=+3
 
png big-left-image.png
 
 
 
== Script ==
 
 
 
A user on the PyMol list wrote a very nice little stereo ray tracing script.  Just copy this to a text file.  Then, in PyMol run
 
run dirName/scriptName.pym
 
where '''dirName''' is where you put it, and '''scriptName''' is what you named the file then run one something like the example lines given:
 
<source lang="python">
 
EXAMPLE
 
  stereo_ray output, 1000, 600
 
  stereo_ray secondImage.png
 
</source>
 
This will create to images, one with an L and one with an R suffix.  Just paste the two images next to each other (in some image editing program) and you're done.
 
 
 
<source lang="python">
 
from pymol import cmd
 
 
 
def stereo_ray(output='', width='', height=''):
 
  '''
 
DESCRIPTION
 
  "stereo_ray" ray-traces the current scene twice (separated by
 
  a six-degree rotation around the y axis)
 
  and saves a pair of images that can be combined in any image
 
  manipulation software to form a stereoimage.
 
  The first argument, the output file name, is mandatory.
 
  The second and third arguments, the size of the image, are not.
 
  If the width is given, the height will be calculated.
 
 
 
USAGE
 
  stereo_ray filename [, width [, height]]
 
 
 
EXAMPLE
 
  stereo_ray output, 1000, 600
 
  stereo_ray secondImage.png
 
  '''
 
 
 
  if output == '':
 
      print 'no output filename defined\n'
 
      print 'try: \'stereo_ray filename\''
 
      return -1
 
      # abort if no output file name given
 
 
 
  if width == '':
 
      width,height = cmd.get_session()['main'][0:2]
 
      # get dimensions from viewer if not given
 
  
  elif height == '':
+
stereo walleye
      oldWidth,oldHeight = cmd.get_session()['main'][0:2]
+
png combined.png, ray=1
      height = int(width)*oldHeight/oldWidth
 
      # calculate height from proportions of viewer if
 
      # only width is given
 
  
  cmd.ray(width, height, angle=-3)
+
== See Also ==
  cmd.png(output+"_r")
 
  cmd.ray(width, height, angle=3)
 
  cmd.png(output+"_l")
 
  
cmd.extend('stereo_ray',stereo_ray)
+
* [[stereo]]
</source>
+
* [[Stereo_Mode|stereo_mode]]
  
 
[[Category:Script_Library|Stereo Ray]]
 
[[Category:Script_Library|Stereo Ray]]
 +
[[Category:UI_Scripts]]
 +
[[Category:Pymol-script-repo]]
 +
[[Category:Stereo]]

Latest revision as of 11:49, 31 May 2012

Type Python Script
Download stereo_ray.py
Author(s) Jason Vertrees
License -
This code has been put under version control in the project Pymol-script-repo

This scripts provides the stereo_ray command, which saves two ray traced images in PNG format. The left image is rotated +3 degrees and the right image is rotated -3 degrees.

Note that the end result is almost identical to using "walleye" stereo mode, which might be more convenient and is readily available in PyMOL.

Usage

stereo_ray filename [, width [, height ]]

Example

import stereo_ray 
stereo_ray output, 1000, 600

This will create two images, "output_l.png" and "output_r.png". Just paste the two images next to each other (in some image editing program) and you're done.

Left Image
Right Image
Combined Images


Manually

To obtain the same result without the script, use the ray and the png command like this:

ray angle=+3
png left-image.png
ray angle=-3
png right-image.png

Obtain almost the same result using the stereo command:

stereo walleye
png combined.png, ray=1

See Also