Skip to content

PythonicAPI Examples

Warning

These examples only work with VTK Version: 9.3.20240428 or greater.

These examples:

  • Use the improved VTK Python interface. Some information about the improved Python interface can be found here
  • Are either newly crafted examples or upgrades of existing Python examples

See:

Upgrading an existing example to use the improved VTK Python interface

  1. Copy the example from the src/Python folder into the src/PythonicAPI folder maintaining the same path structure. If there is a corresponding markdown file, copy it.
  2. Copy the corresponding test image from src/Testing/Baseline/Python/ into src/Testing/Baseline/PythonicAPI/
  3. Edit src/PythonicAPI.md, possibly creating a table and headings to match the original example in src/Python.
  4. Upgrade the Python example.
  5. The associated markdown file (if any) may need checking to ensure any links in the document remain valid.
  6. Check everything is working and do a Merge Request.

Adding a new example

Follow the documented procedure ForDevelopers remembering that the folder to use is PythonicAPI.

VTK Classes Summary

This Python script, SelectExamples, will let you select examples based on a VTK Class and language. It requires Python 3.7 or later. The following tables will produce similar information.

Tutorials

Hello World

Example Name Description Image
A hello world example Cylinder example from the VTK Textbook and source code. A hello world example.

Simple Operations

Example Name Description Image
DistanceBetweenPoints Distance between two points.
DistancePointToLine Distance between a point and a line.
GaussianRandomNumber Generates Gaussian random numbers.

Input and Output

Graph Formats

3D File Formats

Example Name Description Image
XGMLReader Read a .gml file

Standard Formats

Input
Example Name Description Image
ReadAllPolyDataTypesDemo Read all VTK polydata file types.
ReadCML Read Chemistry Markup Language files.
ReadExodusData A simple script for reading and viewing ExodusII data interactively.
ReadSLC Read an SLC file.
TransientHDFReader Read transient data written inside a vtkhdf file.
Importers
Example Name Description Image
3DSImporter Import a 3D Studio scene that includes multiple actors.
ImportPolyDataScene Import a polydata scene using multiblock datasets.
ImportToExport Import a scene and optionally export the scene.
Output
Example Name Description Image
DelimitedTextWriter Write data to a delimited file.
WritePLY
WriteSTL
Exporters

VTK Formats

Input
Output
Example Name Description Image
ExodusIIWriter Write a time varying ExodusII file.

Legacy VTK Formats

Example Name Description Image
GenericDataObjectReader Read any type of legacy .vtk file.
ReadLegacyUnstructuredGrid Read an unstructured grid that contains 11 linear cells.
WriteLegacyLinearCells Write each linear cell into a legacy UnstructuredGrid file (.vtk).
WriteXMLLinearCells Write each linear cell into an XML UnstructuredGrid file (.vtu).

Image Format

Input

Example Name Description Image
HDRReader Read a high-dynamic-range imaging file.
ReadDICOM Read DICOM file.
ReadDICOMSeries This example demonstrates how to read a series of DICOM images and scroll through slices

Output

Geometric Objects

Example Name Description Image
Dodecahedron Create a dodecahedron using vtkPolyhedron.
GeometricObjectsDemo
PipelineReuse How to reuse a pipeline.
Planes We create a convex hull of the planes for display purposes.
PlanesIntersection
SourceObjectsDemo Examples of source objects that procedurally generate polygonal models. These nine images represent just some of the capability of VTK. From upper left in reading order: sphere, cone, cylinder, cube, plane, text, random point cloud, disk (with or without hole), and line source. Other polygonal source objects are available; check subclasses of vtkPolyDataAlgorithm.

Cells

Example Name Description Image
CellTypeSource Generate tessellated cells.
ConvexPointSet Generate a ConvexPointSet cell.
LinearCellsDemo Linear cell types found in VTK. The numbers define the ordering of the points making the cell.
Polyhedron Create an unstructured grid representation of a polyhedron (cube) and write it out to a file.

Sources

Example Name Description Image
EarthSource Create the Earth.
Frustum
OrientedArrow Orient an arrow along an arbitrary vector.
OrientedCylinder Orient a cylinder along an arbitrary vector.
PlatonicSolids All five platonic solids are displayed.
TessellatedBoxSource Generate a box with tessellated sides.

Non Linear

Example Name Description Image
IsoparametricCellsDemo Nonlinear isoparametric cell types in VTK.

Parametric Objects

Example Name Description Image
ParametricObjectsDemo Demonstrates the Parametric classes added by Andrew Maclean and additional classes added by Tim Meehan. The parametric spline is also included. Options are provided to display single objects, add backface, add normals and print out an image.
ParametricKuenDemo Interactively change the parameters for a Kuen Surface.

Implicit Functions and Iso-surfaces

Example Name Description Image
BooleanOperationImplicitFunctions Demonstrate booleans of two different implicit functions
ContourTriangulator Create a contour from a structured point set (image) and triangulate it.
DiscreteFlyingEdges3D Generate surfaces from labeled data.
ExtractData Implicit functions used to select data: Two ellipsoids are combined using the union operation used to select voxels from a volume. Voxels are shrunk 50 percent.
ExtractLargestIsosurface Extract largest isosurface.
IceCream How to use boolean combinations of implicit functions to create a model of an ice cream cone.
ImplicitDataSet Convert an imagedata to an implicit function.
ImplicitQuadric Create an ellipsoid using an implicit quadric
ImplicitSphere Demonstrate sampling of a sphere implicit function
ImplicitSphere1 Demonstrate sampling of a sphere implicit function
IsoContours Visualize different isocontours using a slider.
Lorenz Visualizing a Lorenz strange attractor by integrating the Lorenz equations in a volume.
MarchingCubes Create a voxelized sphere.
SampleFunction Sample and visualize an implicit function.
SmoothDiscreteFlyingEdges3D Generate smooth surfaces from labeled data.

Working with 3D Data

Example Name Description Image
AlignTwoPolyDatas Align two vtkPolyData's.
BooleanPolyDataFilters This example performs a boolean operation (intersection, union or difference) of two PolyData using either a vtkBooleanOperationPolyDataFilter or a vtkLoopBooleanPolyDataFilter
Bottle Model a rotationally symmetric object.
CappedSphere Rotate an arc to create a capped sphere.
CellsInsideObject Extract cells inside a closed surface.
CenterOfMass Compute the center of mass of the points.
ConnectivityFilter Color any dataset type based on connectivity.
Curvatures Compute Gaussian, and Mean Curvatures.
CurvaturesAdjustEdges Get the Gaussian and Mean curvatures of a surface with adjustments for edge effects.
DecimatePolyline Decimate polyline.
DistancePolyDataFilter Compute the distance function from one vtkPolyData to another.
ExternalContour Get the external contour of a PolyData object.
ExtractPolyLinesFromPolyData Extract polylines from polydata.
ExtractSelection Extract selected points.
ExtractSelectionOriginalId Extract selection and find the correspondence between the new and original ids.
ExtractSelectionUsingCells Extract cell, select cell.
ExtractSelectionUsingPoints Extract points but bring cells that are still complete with them.
ExtractVisibleCells Extract and highlight visible cells.
Finance Visualization of multidimensional financial data. The gray/wireframe surface represents the total data population. The red surface represents data points delinquent on loan payment.
FinanceFieldData Visualization of multidimensional financial data. The yellow surface represents the total data population. The red surface represents data points delinquent on loan payment.
FitSplineToCutterOutput Fit a spline to cutter output.
Glyph2D
GradientFilter Compute the gradient of a scalar field on a data set.
ImplicitPolyDataDistance
IntersectionPolyDataFilter Compute the intersection of two vtkPolyData objects.
KMeansClustering KMeans Clustering
LineOnMesh Plot a spline on a terrain-like surface.
KochanekSplineDemo Interactively change the parameters of the Kochanek spline.
MergeSelections Merge selected points.
MeshLabelImageColor Mesh a single label from a label image. Then smooth and color the vertices according to the displacement error introduced by the smoothing.
OrientedBoundingCylinder Create an oriented cylinder that encloses a vtkPolyData. The axis of the cylinder is aligned with the longest axis of the vtkPolyData.
Outline Draw the bounding box of the data.
PerlinNoise
PolyDataContourToImageData
PolyDataToImageDataStencil
ResamplePolyLine
RuledSurfaceFilter
Silhouette
SmoothMeshGrid Create a terrain with regularly spaced points and smooth it with vtkLoopSubdivisionFilter and vtkButterflySubdivisionFilter.
Spring Rotation in combination with linear displacement and radius variation.
ThinPlateSplineTransform
VertexConnectivity Get a list of vertices attached (through an edge) to a vertex.
WarpTo Deform geometry by warping towards a point.
WarpVector This example warps/deflects a line.

Data Types

Example Name Description Image
CompositePolyDataMapper
OverlappingAMR Demonstrates how to create and populate VTK's Overlapping AMR Grid type with data.

Data Type Conversions

Point Cloud Operations

Example Name Description Image
DensifyPoints Add points to a point cloud.
ExtractClusters From a set of randomly distributed spheres, extract connected clusters.
ExtractPointsDemo Extract points inside an implicit function.
ExtractSurface Create a surface from unorganized points using point filters.
ExtractSurfaceDemo Create a surface from unorganized points using point filters (DEMO).
FitImplicitFunction Extract points within a distance to an implicit function.
MaskPointsFilter Extract points within an image mask.
SignedDistance Compute signed distance to a point cloud.
UnsignedDistance Compute unsigned distance to a point cloud.

Working with Meshes

This section includes examples of manipulating meshes.

Example Name Description Image
ClosedSurface Check if a surface is closed.
DeformPointSet Use the vtkDeformPointSet filter to deform a vtkSphereSource with arbitrary polydata.
DelaunayMesh Two-dimensional Delaunay triangulation of a random set of points. Points and edges are shown highlighted with sphere glyphs and tubes.
DijkstraGraphGeodesicPath Find the shortest path between two points on a mesh.
ElevationFilter Color a mesh by height.
FillHoles Close holes in a mesh.
FitToHeightMap Drape a polydata over an elevation map.
GreedyTerrainDecimation Create a mesh from an ImageData
IdentifyHoles Close holes in a mesh and identify the holes.
ImplicitSelectionLoop Select a region of a mesh with an implicit function.
InterpolateFieldDataDemo Resample a fine grid and interpolate field data.
PointInterpolator Plot a scalar field of points onto a PolyData surface.

Clipping

Example Name Description Image
BoxClipStructuredPoints Clip vtkStructuredPoints with a box. The results are unstructured grids with tetrahedra.
BoxClipUnstructuredGrid Clip a vtkUnstructuredGrid with a box. The results are unstructured grids with tetrahedra.
ClipClosedSurface Clip a surface with multiple planes.
ClipDataSetWithPolyData Clip a vtkRectilinearGrid with arbitrary polydata. In this example, use a vtkConeSource to generate polydata to slice the grid, resulting in an unstructured grid.
ClipDataSetWithPolyData1 Clip a vtkRectilinearGrid with arbitrary polydata. In this example, use a vtkConeSource to generate polydata to slice the grid, resulting in an unstructured grid.
ImplicitDataSetClipping Clip using an implicit data set.
SolidClip Create a "solid" clip. The "ghost" of the part clipped away is also shown.
TableBasedClipDataSetWithPolyData2 Clip a vtkRectilinearGrid with a checkerboard pattern.

Working with Structured 3D Data

vtkImageData

Example Name Description Image
ClipVolume Clip a volume and produce a vtkUnhstructuredGrid.
ImageIterator
ImageIteratorDemo Demonstrate using indexing to access pixels in a region.
ImageTranslateExtent Change the extent of a vtkImageData.
ImageWeightedSum Add two or more images.

vtkExplicitStructuredGrid

Example Name Description Image
CreateESGrid Create an explicit structured grid and convert this to an unstructured grid or vice versa.
LoadESGrid Load a VTU file and convert the dataset to an explicit structured grid.

vtkStructuredGrid

Example Name Description Image
BlankPoint Blank a point of a vtkStructuredGrid.
SGrid Creating a structured grid dataset of a semi-cylinder. Vectors are created whose magnitude is proportional to radius and oriented in tangential direction.

vtkStructuredPoints

Example Name Description Image
Vol Creating a image data dataset. Scalar data is generated from the equation for a sphere. Volume dimensions are 26 x 26 x 26.

vtkRectilinearGrid

Example Name Description Image
RGrid Creating a rectilinear grid dataset. The coordinates along each axis are defined using an instance of vtkDataArray.
VisualizeRectilinearGrid Visualize the cells of a rectilinear grid.

Working with Unstructured 3D Data

This section includes vtkUnstructuredGrid.

vtkUnstructuredGrid

Example Name Description Image
ClipUnstructuredGridWithPlane Clip a UGrid with a plane.
ClipUnstructuredGridWithPlane2 Clip a UGrid with a plane.

Registration

Medical

Example Name Description Image
GenerateCubesFromLabels Create cubes from labeled volume data.
GenerateModelsFromLabels Create models from labeled volume data.
MedicalDemo1 Create a skin surface from volume data.

Surface reconstruction

Example Name Description Image
Delaunay3DDemo Interactively adjust Alpha for Delaunay3D.

Utilities

Example Name Description Image
BoundingBox Bounding Box construction.
BoundingBoxIntersection Box intersection and Inside tests.
CheckVTKVersion Check the VTK version and provide alternatives for different VTK versions.
ClassesInLang1NotInLang2 Select VTK classes with corresponding examples in one language but not in another.
ConstrainedDelaunay2D Perform a 2D Delaunay triangulation on a point set respecting a specified boundary.
Delaunay2D Perform a 2D Delaunay triangulation on a point set.
FileOutputWindow Write errors to a log file instead of the usual vtk pop-up window.
JSONColorMapToLUT Take a JSON description of a colormap and convert it to a VTK colormap.
ColorMapToLUT Use vtkDiscretizableColorTransferFunction to generate a VTK colormap.
DetermineActorType Determine the type of an actor.
OffScreenRendering Off Screen Rendering.
PCADemo Project 2D points onto the best 1D subspace using PCA values.
PCAStatistics Compute Principal Component Analysis (PCA) values.
RescaleReverseLUT Demonstrate how to adjust a colormap so that the colormap scalar range matches the scalar range on the object. You can optionally reverse the colors.
ResetCameraOrientation Reset camera orientation to a previously saved orientation.
SaveSceneToFieldData Save a vtkCamera's state in a vtkDataSet's vtkFieldData and restore it.
SaveSceneToFile Save a vtkCamera's state in a file and restore it.
Screenshot
SelectExamples Given a VTK Class and a language, select the matching examples.
ShareCamera Share a camera between multiple renderers.
VTKWithNumpy
XMLColorMapToLUT Take an XML description of a colormap and convert it to a VTK colormap.

Arrays

Example Name Description Image
ArrayCalculator Perform in-place operations on arrays.
ArrayToTable Convert a vtkDenseArray to a vtkTable.
ArrayWriter Write a DenseArray or SparseArray to a file.
ExtractArrayComponent Extract a component of an array.

Events

Math Operations

Graphs

Example Name Description Image
AdjacencyMatrixToEdgeTable Convert an adjacency matrix to an edge table.
AdjacentVertexIterator Get all vertices connected to a specified vertex.
ConstructTree Construct a tree.
CreateTree Create a tree and label the vertices and edges.
EdgeListIterator Iterate over edges of a graph.
GraphToPolyData Convert a graph to a PolyData.
InEdgeIterator Iterate over edges incoming to a vertex.
LabelVerticesAndEdges Label vertices and edges.
RandomGraphSource Create a random graph.
SideBySideGraphs Display two graphs side by side.
ScaleVertices Size/scale vertices based on a data array.
SelectedVerticesAndEdges Get a list of selected vertices and edges.
SelectedVerticesAndEdgesObserver Get a list of selected vertices and edges using an observer of AnnotationChangedEvent.
VisualizeDirectedGraph Visualize a directed graph.

Graph Conversions

Example Name Description Image
DirectedGraphToMutableDirectedGraph vtkDirectedGraph to vtkMutableDirectedGraph.
MutableDirectedGraphToDirectedGraph vtkMutableDirectedGraph to vtkDirectedGraph.
TreeToMutableDirectedGraph vtkTree to vtkMutableDirectedGraph

Data Structures

Example Name Description Image
AttachAttributes Attach attributes to a VTK array.
CellTreeLocator Points on an object using vtkCellTreeLocator.

Timing Demonstrations

KD-Tree

Example Name Description Image
DataStructureComparison Illustrates, side by side, the differences between several spatial data structures
KDTree
KDTreeAccessPoints Access the points of a KDTree.

Oriented Bounding Box (OBB) Tree

Example Name Description Image
OBBTreeExtractCells Intersect a line with an OBB Tree and display all intersected cells.

Octree

Modified BSP Tree

Example Name Description Image
IncrementalOctreePointLocator Insert points into an octree without rebuilding it.
ModifiedBSPTreeExtractCells Intersect a line with a modified BSP Tree and display all intersected cells.

HyperTreeGrid

Example Name Description Image
HyperTreeGridSource Create a vtkHyperTreeGrid.

VTK Concepts

Rendering

Example Name Description Image
ColoredSphere A simple sphere.
GradientBackground Demonstrates the background shading options.
InterpolateCamera Use vtkCameraInterpolator to generate a smooth interpolation between camera views.
LayeredActors Demonstrates the use of two linked renderers. The orientation of objects in the non active layer is linked to those in the active layer.
MotionBlur Example of motion blur.
MultipleLayersAndWindows Demonstrates the use of four renderers in two layers.
OutlineGlowPass Demonstrates how to render a object in a scene with a glowing outline.
PBR_Anisotropy Render spheres with different anisotropy values.
PBR_Clear_Coat Render a cube with custom texture mapping and a coat normal texture.
PBR_Edge_Tint Render spheres with different edge colors using a skybox as image based lighting.
PBR_HDR_Environment Renders spheres with different materials using a skybox as image based lighting.
PBR_Mapping Render a cube with custom texture mapping.
PBR_Materials Renders spheres with different materials using a skybox as image based lighting.
PBR_Materials_Coat Render spheres with different coat materials using a skybox as image based lighting.
PBR_Skybox Demonstrates physically based rendering, a skybox and image based lighting.
PBR_Skybox_Texturing Demonstrates physically based rendering, a skybox, image based lighting and texturing.
PBR_Skybox_Anisotropy Demonstrates physically based rendering, a skybox, image based lighting, and anisotropic texturing.
StringToImageDemo Demonstrates how to generate images from strings.
StripFran Triangle strip examples. (a) Structured triangle mesh consisting of 134 strips each of 390 triangles. (b) Unstructured triangle mesh consisting of 2227 strips of average length 3.94, longest strip 101 triangles. Images are generated by displaying every other triangle strip.
TransformSphere The addition of a transform filter to ColoredSphere.
TransparentBackground Demonstrates the use of two renderers. Notice that the second (and subsequent) renderers will have a transparent background.

Lighting

Example Name Description Image
ShadowsLightsDemo Show lights casting shadows.

Texture Mapping

Example Name Description Image
AnimateVectors One frame from a vector field animation using texture maps.
TextureCutQuadric Cut a quadric with boolean textures.
TextureCutSphere Examples of texture thresholding using a boolean combination of two planes to cut nested spheres.
TexturePlane Example of texture mapping.
TextureThreshold Demonstrate the use of scalar thresholds to show values of flow density on three planes.
TexturedSphere Texture a sphere.

Tutorial

If you are new to VTK then these tutorials will help to get you started.

Visualization

See this tutorial for a brief explanation of the VTK terminology of mappers, actors, etc.

Example Name Description Image
AnnotatedCubeActor Annotated cube.
AssignCellColorsFromLUT Demonstrates how to assign colors to cells in a vtkPolyData structure using lookup tables.
AxisActor Generate a single axis.
BillboardTextActor3D Label points with billboards.
Blow Ten frames from a blow molding finite element analysis.
CameraActor Visualize a camera (frustum) in a scene.
CameraModel1 Illustrate camera movement around the focal point.
CameraModel2 Illustrate camera movement centered at the camera position.
CaptionActor2D Draw a caption/bubble pointing to a particular point.
ClipSphereCylinder A plane clipped with a sphere and an ellipse. The two transforms place each implicit function into the appropriate position. Two outputs are generated by the clipper.
ColoredAnnotatedCube How to color the individual faces of an annotated cube.
CollisionDetection Collison between two spheres.
CombineImportedActors Combine actors from a scene into one actor.
CornerAnnotation Write text in the corners of a window.
CorrectlyRenderTranslucentGeometry Correctly Rendering Translucent Geometry.
CreateBFont A scanned image clipped with a scalar value of 1/2 its maximum intensity produces a mixture of quadrilaterals and triangles.
CubeAxesActor Display three orthogonal axes with with labels.
CubeAxesActor2D This example uses the vtkCubeAxesActor2D to show your scene with axes to indicate the spatial extent of your data.
CurvaturesNormalsElevations Gaussian and Mean curvatures of a surface with arrows colored by elevation to display the normals.
Cursor2D
Cursor3D
DataSetSurface Cutting a hexahedron with a plane. The red line on the surface shows the cut.
DepthSortPolyData Poly Data Depth Sorting.
DisplacementPlot Show modal lines for a vibrating beam.
DistanceToCamera
EdgePoints Generate points along an edge.
FastSplatter Convolve a splat image with every point in an input image.
FireFlow Combine geometry from a VRML file and a solution from a vtkUnstructuredGrid file.
FireFlowDemo Combine geometry from a VRML file and a solution from a vtkUnstructuredGrid file (interactive).
FlyingHeadSlice Flying edges used to generate contour lines.
FroggieSurface Construct surfaces from a segmented frog dataset. Up to fifteen different surfaces may be extracted. You can turn on and off surfaces and control the camera position.
FroggieView View surfaces of a segmented frog dataset using preprocessed *.vtk tissue files. You can turn on and off surfaces, control their opacity through the use of sliders and control the camera position.
Hanoi Towers of Hanoi.
HanoiInitial Towers of Hanoi - Initial configuration.
HanoiIntermediate Towers of Hanoi - Intermediate configuration.
HeadBone Marching cubes surface of human bone.
HyperStreamline Example of hyperstreamlines, the four hyperstreamlines shown are integrated along the minor principal stress axis. A plane (colored with a different lookup table) is also shown.
IsosurfaceSampling Demonstrates how to create point data on an isosurface.
Kitchen Demonstrates stream tracing in a kitchen.
LabeledMesh Label Mesh.
LoopShrink A network with a loop. VTK 5.0 and later do not allow you to execute a looping visualization network; this was possible in previous versions of VTK.
MovableAxes Movable axes.
Office Using random point seeds to create streamlines.
OfficeA Corresponds to Fig 9-47(a) in the VTK textbook.
OfficeTube The stream polygon. Sweeping a polygon to form a tube.
PineRootConnectivity Applying the connectivity filter to remove noisy isosurfaces.
PineRootConnectivityA The isosurface, with no connectivity filter applied.
PineRootDecimation Applying the decimation and connectivity filters to remove noisy isosurfaces and reduce data size.
PlateVibration Demonstrates the motion of a vibrating beam.
PointDataSubdivision Demonstrates the use of the vtkLinearSubdivisionFilter and vtkButterflySubdivisionFilter.
ProgrammableGlyphFilter Generate a custom glyph at each point.
ProgrammableGlyphs Generate programmable glyphs.
PseudoVolumeRendering Here we use 20 cut planes, each with an opacity of of 0.25. They are then rendered back-to-front to simulate volume rendering.
QuadricVisualization Visualizing a quadric function.
ReverseAccess Demonstrates how to access the source (e.g. vtkSphereSource) of an actor reversely.
StreamlinesWithLineWidget Using the vtkLineWidget to produce streamlines in the combustor dataset. The StartInteractionEvent turns the visibility of the streamlines on; the InteractionEvent causes the streamlines to regenerate themselves.
TensorEllipsoids Display the scaled and oriented principal axes as tensor ellipsoids representing the stress tensor.
TransformActorCollection Transform an actor collection.
VoxelsOnBoundary Extract voxels on the border of an isosurface.
WarpCombustor Carpet plots of combustor flow energy in a structured grid. Colors and plane displacement represent energy values.

Working with vtkImageData

Example Name Description Image
ImageNormalize Normalize an image.
WriteReadVtkImageData Generate, edit and read out vtk image data.

Volume Rendering

Example Name Description Image
IntermixedUnstructuredGrid A mix of poly data and unstructured grid volume mapping.
MinIntensityRendering Min intensity rendering.
RayCastIsosurface Isosufaces produced by volume rendering.

User Interaction

Example Name Description Image
AreaPicking Area Picking.
Assembly Combine/group actors into an assembly.
CallBack Setting up a callback with client data. Two different methods are demonstrated.
CellPicking Cell Picking.
EllipticalButton Create an elliptical button.
HighlightPickedActor Pick and highlight an actor based on mouse clicks.
HighlightSelection Highlight selection.
HighlightWithSilhouette Highlight a picked actor by adding a silhouette.
ImageClip Demonstrates how to interactively select and display a region of an image.
ImageRegion Select a region of an image.
InteractorStyleTrackballActor
InteractorStyleTrackballCamera
MouseEvents Subclass the interactor style.
MouseEventsObserver Use an observer.
RubberBand3D
RubberBandZoom
StyleSwitch Choose between multiple interaction modes.

Working with Images

Example Name Description Image
BackgroundImage Display an image as the "background" of a scene, and render a superquadric in front of it.
CannyEdgeDetector Perform Canny edge detection on an image.
DotProduct Compute the pixel-wise dot product of two vector images.
ExtractComponents Extract components of an image. This can be used to get, for example, the red channel of an image.
ImageCityBlockDistance Compute the Manhattan distance from every point to every black point in a binary image.
ImageGridSource Create a image of a grid.
ImageHistogram Compute the histogram of an image.
ImageMask Mask a region of an image.
ImageNonMaximumSuppression Find peaks in an image using non maximum suppression.
ImageOpenClose3D Open or close (morphologically) an image.
ImageOrientation Reorder the axes of the image.
ImageRange3D Replace every pixel with the range of its neighbors according to a kernel.
ImageSeparableConvolution Convolve a separable kernel with an image.
ImageSlice Visualize and interact with an image. This is even more powerful than vtkImageSliceMapper. It can also do oblique slices.
ImageStack Display layers of images.
ImageToPolyDataFilter Convert a vtkImageData to a vtkPolyData.
MarkKeypoints Mark keypoints in an image.

Image Processing

Example Name Description Image
Attenuation This MRI image illustrates attenuation that can occur due to sensor position. The artifact is removed by dividing by the attenuation profile determined manually.
CenterAnImage Center an image.
CombiningRGBChannels Combine layers into an RGB image.
EnhanceEdges High-pass filters can extract and enhance edges in an image. Subtraction of the Laplacian (middle) from the original image (left) results in edge enhancement or a sharpening operation (right).
GaussianSmooth Low-pass filters can be implemented as convolution with a Gaussian kernel.
HybridMedianComparison Comparison of median and hybrid-median filters. The hybrid filter preserves corners and thin lines, better than the median filter.
IdealHighPass This figure shows two high-pass filters in the frequency domain. The Butterworth high-pass filter has a gradual attenuation that avoids ringing produced by the ideal high-pass filter with an abrupt transition.
ImageContinuousDilate3D Dilate an image.
ImageContinuousErode3D Erode an image.
ImageConvolve Convolve an image with a kernel.
ImageCorrelation Correlate two images.
ImageDifference Compute the difference image of two images.
ImageDivergence Divergence of a vector field.
ImageEllipsoidSource Create an image of an ellipsoid.
ImageGradient Create an imaging pipeline to visualize gradient information.
ImageGradientMagnitude Compute the magnitude of the gradient at each pixel of an image.
ImagePermute Reorder the axes of the image.
ImageSobel2D Sobel edge detection 2D.
ImageVariance3D Construct a new image consisting of the variance of the input image at each pixel.
ImageWarp Combine the imaging and visualization pipelines to deform an image in the z-direction. The vtkMergeFilter is used to combine the warped surface with the original color data.
IsoSubsample This figure demonstrates aliasing that occurs when a high-frequency signal is subsampled. High frequencies appear as low frequency artifacts. The left image is an isosurface of a skull after subsampling. The right image used a low-pass filter before subsampling to reduce aliasing.
MorphologyComparison This figure demonstrates various binary filters that can alter the shape of segmented regions.
Pad Convolution in frequency space treats the image as a periodic function. A large kernel can pick up features from both sides of the image. The left image has been padded with a constant to eliminate wraparound during convolution. On the right, mirror padding has been used to remove artificial edges introduced by borders.
RGBToHSI Convert RGB to HSI.
RGBToHSV Convert RGB to HSV.
RGBToYIQ Convert RGB to YIQ.
ResizeImage Resize an image using a sinc interpolator.
VTKSpectrum The discrete Fourier transform changes an image from the spatial domain into the frequency domain, where each pixel represents a sinusoidal function. This figure shows an image and its power spectrum displayed using a logarithmic transfer function.

Widgets

Example Name Description Image
AffineWidget Apply an affine transformation interactively.
AngleWidget
AngleWidget2D vtkAngleWidget + vtkAngleRepresentation2D.
BalloonWidget Uses a vtkBalloonWidget to draw labels when the mouse stays above an actor.
BiDimensionalWidget Used to measure a 2D (X, Y) size of some aspect of an object.
BorderWidget 2D selection, 2D box.
BoxWidget This 3D widget defines a region of interest that is represented by an arbitrarily oriented hexahedron with interior face angles of 90 degrees (orthogonal faces). The object creates 7 handles that can be moused on and manipulated.
BoxWidget2 This 3D widget defines a region of interest that is represented by an arbitrarily oriented hexahedron with interior face angles of 90 degrees (orthogonal faces). The object creates 7 handles that can be moused on and manipulated. vtkBoxWidget2 and vtkBoxRepresentation are used in this example.
CameraOrientationWidget Demonstrates a 3D camera orientation widget.
CaptionWidget
CheckerboardWidget Compare two images using a checkerboard.
CompassWidget Draws an interactive compass.
ContourWidget Draw a contour (line) which can be deformed by the user.
DistanceWidget
HoverWidget How to detect a hover.
ImagePlaneWidget
ImageTracerWidgetInsideContour Highlight pixels inside a non-regular region scribbled on an image.
ImageTracerWidgetNonPlanar Draw on a non-planar surface.
ImplicitConeWidget An interactive implicit cone widget.
ImplicitPlaneWidget2 Clip polydata with an implicit plane.
PolygonalSurfacePointPlacer Used in conjunction with vtkContourWidget to draw curves on a surface.
RectilinearWipeWidget Compare two images.
Slider2D 2D Slider.
Slider3D 3D Slider.
SphereWidget This 3D widget defines a sphere that can be interactively placed in a scene.
SplineWidget This example shows how to use vtkSplineWidget with a callback being used to get the length of the spline widget.

Plotting

Example Name Description Image
AreaPlot Plot the area between two curves.
BoxChart Box plot.
ChartMatrix Create a marix of plots.
FunctionalBagPlot Functional Bag Plot.
Histogram2D 2D Histogram of a vtkImageData.
HistogramBarChart Histogram using bar chart.
LinePlot2D Line plot of 2D data.
LinePlot3D Line plot of 3D data.
MultiplePlots Display multiple plots by using viewports in a single render window.
ParallelCoordinates Parallel coordinates.
PieChart Pie chart.
ScatterPlot Scatter plot.
SpiderPlot Spider plot.
StackedBar Stacked bar.
SurfacePlot Surface plot.

Animation

Example Name Description Image
AnimateSphere Animate a sphere by opening it to an angle of 90°.
Animation Move a sphere across a scene.
AnimationScene Animation (the right way). Zoom in on a sphere.

Annotation

Example Name Description Image
TextOrigin This example demonstrates the use of vtkVectorText and vtkFollower. vtkVectorText is used to create 3D annotation.

InfoVis

Example Name Description Image
ParallelCoordinatesView How to use Parallel Coordinates View to plot and compare data set attributes.

PyQt