Skip to content

Instantly share code, notes, and snippets.

@pieper
Created September 17, 2014 23:06
Show Gist options
  • Save pieper/f87c683f48747b3aaef7 to your computer and use it in GitHub Desktop.
Save pieper/f87c683f48747b3aaef7 to your computer and use it in GitHub Desktop.
render a smoothed image by supersampling - hack for slicer4
lm = slicer.app.layoutManager()
tw = lm.threeDWidget(0)
tv = tw.threeDView()
rw = tv.renderWindow()
ren = rw.GetRenderers().GetItemAsObject(0)
wti = vtk.vtkWindowToImageFilter()
wti.SetMagnification(4)
rw2 = vtk.vtkRenderWindow()
rw2.SetSize(500,500)
rens2 = rw2.GetRenderers()
rens2.AddItem(ren)
rw2.Render()
slicer.app.processEvents()
wti.SetInput(rw2)
pw = vtk.vtkPNGWriter()
pw.SetFileName('/tmp/big.png')
pw.SetInputConnection(wti.GetOutputPort())
pw.Update()
pw.Write()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment