Firstly, define the tree
command as such:
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
The cd
to the directory in question and run tree
. You should get an output
such as this:
#!/usr/bin/env python | |
## | |
# This example shows how to apply an vtkImageData texture to an sphere | |
# vtkPolyData object. | |
# Note: Input jpg file can be located in the VTKData repository. | |
# | |
# @author JBallesteros | |
## |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from vtk import * | |
# Let's create a surface with 3 points unconnected. | |
points = vtkPoints() | |
points.InsertNextPoint(1, 0, 0) | |
points.InsertNextPoint(0, 0, 0) | |
points.InsertNextPoint(0, 1, 0) |
#!/usr/bin/python | |
import SimpleITK as sitk | |
import vtk | |
import numpy as np | |
from vtk.util.vtkConstants import * | |
def numpy2VTK(img,spacing=[1.0,1.0,1.0]): | |
# evolved from code from Stou S., |
sources: | |
http://smh84.wordpress.com/2014/04/23/install-opencv-in-anaconda-1-9-2-on-mac-os-x-mavericks/ | |
https://gist.github.com/welch/6468594 | |
It is a rite of passage to post one's successful build instructions for OpenCV on a Mac | |
after you've tried all the other conflicting instructions out there and still failed. | |
brew failed for me (was this because I could never get a happy brew doctor situation? | |
I'll never know). macports? nope. build-from-source recipes? I didn't find one that | |
worked for me. | |
Firstly, define the tree
command as such:
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
The cd
to the directory in question and run tree
. You should get an output
such as this:
# Assuming that we have an object of type 'vtkImageData' under the name of | |
# 'image' | |
# Create a new vtkImageSliceMapper | |
mapper = vtk.vtkImageSliceMapper() | |
# Set 'image' as the input dataset | |
mapper.SetInput(image) | |
# Set the orthogonal slice orientation to be perpendicular to the 'X' axis. Use | |
# 'SetOrientationToY' and 'SetOrientationToZ' for the Y and Z axes. | |
# Alternatively you can use the 'SetOrientation' method with a 'int' parameter |
Assuming we have a vtkImageData
object under the name of image
this is how we'd go about resampling that image data with a factor of 2
. Here we assume that image
has a spacing of 1.0
mm across all axes
resliceFilter = vtk.vtkImageReslice()
resliceFilter.SetInput(image)
resliceFilter.SetOutputSpacing(0.5, 0.5, 0.5)
resliceFilter.SetInterpolationModeToCubic()
resliceFilter.Update()
imageResampled = resliceFilter.GetOutput()
Assuming we have an .stl
file under filenameSTL
we can load the contents of that file using the vtkSTLReader
class as such:
readerSTL = vtk.vtkSTLReader()
readerSTL.SetFileName(filenameSTL)
# 'update' the reader i.e. read the .stl file
readerSTL.Update()
polydata = readerSTL.GetOutput()
# source: | |
# http://stackoverflow.com/questions/5783517/downloading-progress-bar-urllib2-python | |
import urllib2, sys | |
def chunk_report(bytes_so_far, chunk_size, total_size): | |
percent = float(bytes_so_far) / total_size | |
percent = round(percent*100, 2) | |
sys.stdout.write("Downloaded %d of %d bytes (%0.2f%%)\r" % | |
(bytes_so_far, total_size, percent)) |
#source: http://stackoverflow.com/questions/20023209/python-function-for-rotating-2d-objects | |
import math | |
def rotatePolygon(polygon,theta): | |
"""Rotates the given polygon which consists of corners represented as (x,y), | |
around the ORIGIN, clock-wise, theta degrees""" | |
theta = math.radians(theta) | |
rotatedPolygon = [] | |
for corner in polygon : |