pyvista.ImageData

Contents

pyvista.ImageData#

class ImageData(*args, **kwargs)[source]#

Models datasets with uniform spacing in the three coordinate directions.

Can be initialized in one of several ways:

  • Create empty grid

  • Initialize from a vtk.vtkImageData object

  • Initialize based on dimensions, cell spacing, and origin.

Changed in version 0.33.0: First argument must now be either a path or vtk.vtkImageData. Use keyword arguments to specify the dimensions, spacing, and origin of the uniform grid.

Changed in version 0.37.0: The dims parameter has been renamed to dimensions.

Parameters:
uinputstr, vtk.vtkImageData, pyvista.ImageData, optional

Filename or dataset to initialize the uniform grid from. If set, remainder of arguments are ignored.

dimensionssequence[int], optional

dimensions of the uniform grid.

spacingsequence[float], default: (1.0, 1.0, 1.0)

spacing of the uniform grid in each dimension. Must be positive.

originsequence[float], default: (0.0, 0.0, 0.0)

origin of the uniform grid.

deepbool, default: False

Whether to deep copy a vtk.vtkImageData object. Keyword only.

direction_matrixRotationLike, optional

The direction_matrix is a 3x3 matrix which controls the orientation of the image data.

Added in version 0.45.

offsetint | VectorLike[int], default: (0, 0, 0)

The offset defines the minimum extent of the image. Offset values can be positive or negative. In physical space, the offset is relative to the image’s origin.

Added in version 0.45.

Examples

Create an empty ImageData.

>>> import pyvista as pv
>>> grid = pv.ImageData()

Initialize from a vtk.vtkImageData object.

>>> import vtk
>>> vtkgrid = vtk.vtkImageData()
>>> grid = pv.ImageData(vtkgrid)

Initialize using just the grid dimensions and default spacing and origin. These must be keyword arguments.

>>> grid = pv.ImageData(dimensions=(10, 10, 10))

Initialize using dimensions and spacing.

>>> grid = pv.ImageData(
...     dimensions=(10, 10, 10),
...     spacing=(2, 1, 5),
... )

Initialize using dimensions, spacing, and an origin.

>>> grid = pv.ImageData(
...     dimensions=(10, 10, 10),
...     spacing=(2, 1, 5),
...     origin=(10, 35, 50),
... )

Initialize from another ImageData.

>>> grid = pv.ImageData(
...     dimensions=(10, 10, 10),
...     spacing=(2, 1, 5),
...     origin=(10, 35, 50),
... )
>>> grid_from_grid = pv.ImageData(grid)
>>> grid_from_grid == grid
True

Methods

ImageData.cast_to_rectilinear_grid()

Cast this uniform grid to a rectilinear grid.

ImageData.cast_to_structured_grid()

Cast this uniform grid to a structured grid.

ImageData.to_tetrahedra([tetra_per_cell, ...])

Create a tetrahedral mesh structured grid.

Attributes

ImageData.active_normals

Return the active normals as an array.

ImageData.active_scalars

Return the active scalars as an array.

ImageData.active_scalars_info

Return the active scalar's association and name.

ImageData.active_scalars_name

Return the name of the active scalars.

ImageData.active_t_coords

Return the active texture coordinates on the points.

ImageData.active_tensors

Return the active tensors array.

ImageData.active_tensors_info

Return the active tensor's field and name: [field, name].

ImageData.active_tensors_name

Return the name of the active tensor array.

ImageData.active_texture_coordinates

Return the active texture coordinates on the points.

ImageData.active_vectors

Return the active vectors array.

ImageData.active_vectors_info

Return the active vector's association and name.

ImageData.active_vectors_name

Return the name of the active vectors array.

ImageData.actual_memory_size

Return the actual size of the dataset object.

ImageData.area

Return the mesh area if 2D.

ImageData.array_names

Return a list of array names for the dataset.

ImageData.arrows

Return a glyph representation of the active vector data as arrows.

ImageData.bounds

Return the bounding box of this dataset.

ImageData.cell

A generator that provides an easy way to loop over all cells.

ImageData.cell_data

Return cell data as DataSetAttributes.

ImageData.cell_ghost_array

read-only, Calls GetCellGhostArray

ImageData.cell_types_array

read-only, Calls GetCellTypesArray

ImageData.cells

read-only, Calls GetCells

ImageData.center

Return the center of the bounding box.

ImageData.class_name

read-only, Calls GetClassName

ImageData.data_description

read-only, Calls GetDataDescription

ImageData.data_dimension

read-only, Calls GetDataDimension

ImageData.data_object_type

read-only, Calls GetDataObjectType

ImageData.data_released

read-only, Calls GetDataReleased

ImageData.debug

read-write, Calls GetDebug/SetDebug

ImageData.dimensionality

Return the dimensionality of the grid.

ImageData.dimensions

Return the grid's dimensions.

ImageData.direction_matrix

Set or get the direction matrix.

ImageData.extent

Return or set the extent of the ImageData.

ImageData.extent_type

read-only, Calls GetExtentType

ImageData.field_data

Return FieldData as DataSetAttributes.

ImageData.global_release_data_flag

read-write, Calls GetGlobalReleaseDataFlag/SetGlobalReleaseDataFlag

ImageData.global_warning_display

read-write, Calls GetGlobalWarningDisplay/SetGlobalWarningDisplay

ImageData.increments

read-only, Calls GetIncrements

ImageData.index_to_physical_matrix

Return or set 4x4 matrix to convert coordinates from index space (ijk) to physical space (xyz).

ImageData.information

read-write, Calls GetInformation/SetInformation

ImageData.is_empty

Return True if there are no points.

ImageData.is_in_memkind

read-only, Calls GetIsInMemkind

ImageData.length

Return the length of the diagonal of the bounding box.

ImageData.length2

read-only, Calls GetLength2

ImageData.m_time

read-only, Calls GetMTime

ImageData.max_cell_size

read-only, Calls GetMaxCellSize

ImageData.max_spatial_dimension

read-only, Calls GetMaxSpatialDimension

ImageData.memkind_directory

write-only, Calls SetMemkindDirectory

ImageData.memory_address

Get address of the underlying VTK C++ object.

ImageData.mesh_m_time

read-only, Calls GetMeshMTime

ImageData.n_arrays

Return the number of arrays present in the dataset.

ImageData.n_cells

Return the number of cells in the entire dataset.

ImageData.n_points

Return the number of points in the entire dataset.

ImageData.number_of_cells

Return the number of cells.

ImageData.number_of_points

Return the number of points.

ImageData.number_of_scalar_components

read-only, Calls GetNumberOfScalarComponents

ImageData.object_description

read-only, Calls GetObjectDescription

ImageData.object_name

read-write, Calls GetObjectName/SetObjectName

ImageData.offset

Return or set the index offset of the ImageData.

ImageData.origin

Return the origin of the grid (bottom southwest corner).

ImageData.physical_to_index_matrix

Return or set 4x4 matrix to convert coordinates from physical space (xyz) to index space (ijk).

ImageData.point_data

Return point data as DataSetAttributes.

ImageData.point_ghost_array

read-only, Calls GetPointGhostArray

ImageData.points

Build a copy of the implicitly defined points as a numpy array.

ImageData.reference_count

read-write, Calls GetReferenceCount/SetReferenceCount

ImageData.scalar_pointer

read-only, Calls GetScalarPointer

ImageData.scalar_range

read-only, Calls GetScalarRange

ImageData.scalar_size

read-only, Calls GetScalarSize

ImageData.scalar_type

read-only, Calls GetScalarType

ImageData.scalar_type_max

read-only, Calls GetScalarTypeMax

ImageData.scalar_type_min

read-only, Calls GetScalarTypeMin

ImageData.spacing

Return or set the spacing for each axial direction.

ImageData.update_time

read-only, Calls GetUpdateTime

ImageData.user_dict

Set or return a user-specified data dictionary.

ImageData.using_memkind

read-only, Calls GetUsingMemkind

ImageData.volume

Return the mesh volume.

ImageData.x

Return all the X points.

ImageData.y

Return all the Y points.

ImageData.z

Return all the Z points.