ExamplesΒΆ
This page contains some examples on how to use pi2 for simple (and some not so simple) tasks. All the examples are given in Python 3.6. They can be found in a single Python file here.
The examples require a few small images that can be downloaded from here, or from GitHub.
In order to run the examples, please run this initialization first (make sure that the file paths point to correct locations):
import numpy as np
from pi2py2 import *
pi = Pi2()
# Define convenience functions that return input and output file names.
# This is just to avoid copying the paths to all the examples in case they change.
def input_file(filename='t1-head_256x256x129.raw'):
return '../../test_input_data/' + filename
def input_file_bin():
return '../../test_input_data/t1-head_bin_256x256x129.raw'
def output_file(name):
return '../../test_output_data/pi2py2/' + name
List of examples:
- Binning
- Bivariate histogram
- Byte order, big-endian, little-endian
- Create and access images
- File format conversions
- Filtering, normal and distributed mode
- Finding surface using Edwards-Wilkinson model
- Greedy coloring
- Help
- Histogram
- Filling a cavity with a level set method
- Line-enhancing filtering
- Local thickness / opening transform
- Montage
- Estimation of orientation using the structure tensor method
- Particle analysis
- Filter particle analysis results, visualize particles
- Read and write images
- Image rotations
- Seeded distance map
- Simple image math and saturation arithmetic
- Skeleton, saving to VTK format
- Skeleton types
- Vessel graph
- Watershed segmentation
- Watershed segmentation of particles