darsia.OpticalImage#
- class OpticalImage(img, transformations=None, **kwargs)[source]#
Bases:
ImageSpecial case of 2d trichromatic optical images, typically originating from photographs.
Specialized constructor for optical images.
In addition to the constructor of general images, the color space is required to be specified through the keyword arguments.
Methods
add_grid([origin, dx, dy, color, thickness])Adds a grid on the image and returns new image.
append(image[, offset])Append other image to current image.
astype(data_type)For scalar data types, change the data type of the data array.
copy()Copy constructor.
eval(point[, interpolation])Evaluate the image array at a given point location.
geometry()Generate (flat) geometry object corresponding to the image.
img_as(data_type)Change data type via skimage.
integral()Integrate the image over its spatial dimensions.
metadata()Generator of metadata; can be used to init a new optical image with same specs.
reset_origin([return_image])Reset origin and coordinatesystem.
reset_reference_time()Pick date of first image in a series as reference date.
resize(cx[, cy])roi(roi)Extraction of spatial subregion using a darsia.ROI object.
save(path[, verbose])Save image to file.
set_time([time])Setter for time array.
shape_metadata()Return all metadata connected to dimensions of image and voxels.
show([title, duration, mode])Show image using matplotlib.pyplots or plotly built-in methods.
show_matplotlib([title, duration])Show the image using
matplotlib.pyplot.show_plain([title])Show image using matplotlib.pyplots in plain mode.
show_plotly([title, duration])Show the image using
plotly(often faster than matplotlib).slice(cut, axis)Extract of spatial slice.
subregion(roi)Extraction of spatial subregion.
time_interval(indices)Extraction of temporal subregion, only for space-time images.
time_slice(time_index)Extraction of single time slice.
to_monochromatic(key)Returns monochromatic version of the image.
to_trichromatic(color_space[, return_image])Transforms image to another trichromatic color space.
to_vtk(path[, name])Save image to file in vtk format.
update_metadata([meta])Update metadata of image.
update_reference_time(reference)Update reference time.
write(path, **kwargs)Write the image to file.
Attributes
coordinatesystemPhysical coordinate system with equipped transformation from voxel to Cartesian space.
domainPhysical domain.
dtypeData type of the (current) image array.
num_voxelsNumber of voxels in each dimension.
opposite_cornerCartesian coordinate of the corner opposite to origin.
shapeShape of the image array, incl.
space_numSpatial resolution, i.e., number of voxels.
voxel_sizeSize of each voxel in each direction, ordered as indexing.
Color space of the trichromatic data space.
imgData array.
original_dtypeOriginal dtype at construction of the object.
space_dimDimension of the spatial domain.
indexingIndexing of each axis in context of matrix indexing (ijk) or Cartesian coordinates (xyz).
dimensionsDimension in the directions corresponding to the indexings.
nameName of image, e.g., used to describe the origin.
originCartesian coordinates associated to the [0,0,0] voxel (after applying transformations), using Cartesian indexing.
seriesFlag controlling whether the data array corresponds to a time series.
time_dimDimensionality of the image in temporal sense.
time_numNumber of time points.
dateTime in datetime format.
reference_dateReference date (for defining relative time).
timeRelative time in scalar format (in seconds).
scalarFlag controlling whether the data array is scalar, i.e., it does not use an extra axis to encode the range.
range_dimDimensionality of the image in data sense.
range_numNumber of entries for each data entry.
- add_grid(origin=None, dx=1, dy=1, color=(0, 0, 125), thickness=9)[source]#
Adds a grid on the image and returns new image.
- Parameters:
- origin
np.ndarray Origin of the grid, in physical units - the reference coordinate system is provided by the corresponding attribute coordinatesystem.
- dx
float Grid size in x-direction, in physical units.
- dy
float Grid size in y-direction, in physical units.
- color
tupleofint BGR color of the grid.
- thickness
int Thickness of the grid lines.
- origin
- Returns:
OpticalImageOriginal image with grid on top.
- copy()[source]#
Copy constructor.
- Returns:
OpticalImageCopy of the image object.
- metadata()[source]#
Generator of metadata; can be used to init a new optical image with same specs.
- Returns:
dictMetadata with keys equal to all keywords agurments.
- to_monochromatic(key)[source]#
Returns monochromatic version of the image.
- Returns:
ScalarImageMonochromatic image.
- to_trichromatic(color_space, return_image=False)[source]#
Transforms image to another trichromatic color space.
- Parameters:
- Returns:
OpticalImage(optional):convertedimage,ifrequestedvia‘return_image’.
- write(path, **kwargs)[source]#
Write the image to file.
- Parameters:
- path
Path Full path to the output image.
- **kwargs
quality(int) – 0-100, resolution for a jpg image.compression(int) – 0-9, compression level for a png image.
- path
- color_space#
Color space of the trichromatic data space.