Skip to content

Instantly share code, notes, and snippets.

View lesolorzanov's full-sized avatar
:shipit:

Leslie Evelyn Solorzano lesolorzanov

:shipit:
  • Uppsala, Sweden
View GitHub Profile
@lesolorzanov
lesolorzanov / voxelsimagetiff.py
Created January 9, 2017 11:04
Cubes from voxels
from PIL import Image
import numpy
im=Image.open('C:/Users/Administrator/Documents/Leslie/Uppsala/registered161101/crops/b1-2-0001-1757-1887-White Top Hat.tif')
def makeMaterial(name, diffuse, specular, alpha):
mat = bpy.data.materials.new(name)
mat.diffuse_color = diffuse
mat.diffuse_shader = 'LAMBERT'
mat.diffuse_intensity = 1.0
@lesolorzanov
lesolorzanov / Python VTK MPR
Created November 10, 2016 16:17
Nice short way to make an MPR in python
def testBug(self):
# Uncomment the next line if you want to run this via
# `gdb python`.
#raw_input('Hit Ctrl-C')
# Load some data.
v16 = vtk.vtkVolume16Reader()
v16.SetDataDimensions(64, 64)
v16.SetDataByteOrderToLittleEndian()
v16.SetFilePrefix(os.path.join(Testing.VTK_DATA_ROOT,
@lesolorzanov
lesolorzanov / itk.cxx
Last active September 1, 2015 11:36
My ITK tips
/*
* Create a float image the size of a short image
* This is an example of how to create an image of
* a different type but same size as a given image
*/
FloatImageType::Pointer ppRecruitImage = FloatImageType::New();
//define origin and size the same as the input
//get the biggest region (which usually is the whole image)
@lesolorzanov
lesolorzanov / commands.sh
Last active November 11, 2016 09:08
General bash commands I use
#Copy directory structure
cd /path/to/directories &&
find . -type d -exec mkdir -p -- /path/to/backup/{} \;
#copy files of certain extension
#http://superuser.com/questions/299938/how-can-i-recursively-copy-files-by-file-extension-preserving-directory-structu
cd /source/path
find -type f -name \*.txt -exec install -D {} /dest/path/{} \;
@lesolorzanov
lesolorzanov / DrawTowers.py
Last active October 15, 2015 01:24
Draw Towers around a circle
def DrawTower(x,y,z,a):
bpy.ops.mesh.primitive_cube_add(location=(x,y,z+1), rotation = (0,0,a))
bpy.ops.mesh.primitive_cylinder_add(location=(x,y,z+3), rotation = (0,0,a))
bpy.ops.mesh.primitive_cone_add(location=(x,y,z+5), rotation = (0,0,a))
def DrawTowers(n):
for i in range (0,n):
DrawTower(cos((2*pi*i)/n)*4,sin((2*pi*i)/n)*4,0,2*pi/n*i)
def DrawTowersCircle(n,r,cx,cy):