This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// A simple example of image streaming, using a reader that can stream | |
// from a file and a writer than can stream to a file. | |
// | |
// Currently, the only image writer in VTK that streams from its input | |
// is the vtkMINCImageWriter. | |
// | |
// Please send any comments to david.gobbi@gmail.com | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
// This is a program for converting a binary image (little-endian) | |
// into a set of integers that indicate the position where the bit | |
// value changes. It is much faster than going through bit-by-bit. | |
int main(int argc, char *argv[]) | |
{ | |
static const int debruijn[32] = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!!ARBfp1.0 | |
# This is a short fragment program for bicubic texture interpolation. | |
# It takes one parameter, a vector that gives the texture size as | |
# (xsize, ysize, 1.0/xsize, 1.0/ysize). The cubic interpolation weights | |
# are computed by the shader, so it is not necessary to supply an | |
# interpolation kernel texture. | |
# width, height, xspacing, yspacing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is a simple class that can catch errors from VTK objects. | |
""" | |
import vtk | |
class ErrorObserver: | |
def __init__(self): | |
self.__ErrorOccurred = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Clip a line segment defined by endpoints at p1[3], p2[3] by a | |
// collection of n planes defined by the equation ax+by+cz+d=0. | |
// The parametric coordinates t1,t2 of new endpoints are returned, | |
// as well as the indices i1,i2 of the entry and exit planes for the line. | |
// Result values of -1 for i1 or i2 signify that the line was not clipped | |
// at the p1 end or the p2 end respectively. The function return value | |
// will be 0 if the whole line segment lies outside, or 1 if the line | |
// segment lies fully or partially inside the planes. | |
int clipLineWithPlanes(const double p1[3], const double p2[3], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
""" | |
Usage: python bracefix.py [--test] <file1> [<file2> ...] | |
This script takes old-style "Whitesmiths" indented VTK source files as | |
input, and re-indents the braces according to the new VTK style. | |
Only the brace indentation is modified. | |
If called with the --test option, then it will print an error message | |
for each file that it would modify, but it will not actually modify the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def ellipsoid(radii, dtype='d'): | |
"""Generate an ellipsoid with the specified radii. | |
The ellipsoid will be centered in the output, which will always | |
have odd dimensions. The surface of the sphere will be antialiased, | |
that is, a linear ramp is applied at the surface instead of a hard | |
edge. The size of the ramp is exactly one sample spacing, i.e. points | |
right on the surface will have a value of 0.5 while points that are |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
Kb = 0.114 | |
Kr = 0.299 | |
full = numpy.array([ | |
[1.0, 0.0, 2.0*(1.0-Kr) ], | |
[1.0, -2.0*Kb*(1.0-Kb)/(1.0-Kr-Kb), -2.0*Kr*(1.0-Kr)/(1.0-Kr-Kb) ], | |
[1.0, 2.0*(1.0-Kb), 0.0 ] | |
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Program nifti_readwrite.py | |
Sep 16, 2019 | |
David Gobbi | |
""" | |
import sys | |
import argparse | |
import nibabel as nib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
""" | |
This program reads the output from "dicomdump" and converts it to json. | |
The latest version of this code can be found at gist.github.com/dgobbi | |
Note that this code is incomplete, incorrect, and may destroy your data. | |
It comes with absolutely no warranties. Use at your own risk. | |
""" |
OlderNewer