Class Scene¶
- class slideio.Scene(scene)¶
slideio Scene class.
Scene class represents a single 2D-4D image from a Slide object. The class implements methods for accessing the image raster and metadata. All raster channels of the scene have the same resolution and the same size. Raster channels may have different data types depending on the image format. A scene can represent a separate region of interest of the slide. A Scene object can be created by a “get_scene” method of a Slide object or by using the constructor:
scene = Scene(slide, scene_index)
- property acquisition_time¶
00Z, 0 if unknown.
This is the origin get_plane_timestamp measures from, so the absolute time of a plane is acquisition_time + get_plane_timestamp(…).
- Type:
Acquisition start in seconds since 1970-01-01T00
- Type:
00
- apply_transformation(transormation)¶
Transform scene raster
- Parameters:
transformation – transformation parameters
- close()¶
Release the underlying C++ scene object.
- property compression¶
Compression method for the scene raster data.
- property file_path¶
File path to the scene. In the most cases the same as file path of the slide.
- get_aux_image(image_name, size=(0, 0), channel_indices=None)¶
Get auxiliary image as a numpy array.
- Parameters:
image_name – name of the auxiliary image
channel_indices – array of channel indices to be retrieved. None or [] - all channels.
size – size of the block after rescaling. (0,0) - no scaling.
- get_aux_image_names()¶
Get list of auxiliary image names
- get_channel_data_type(channel)¶
Returns data type for a scene channel by index :param channel: channel index.
- get_channel_name(channel)¶
Returns name of a scene channel by index :param channel: channel index.
- get_channel_significant_bits(channel)¶
Returns the native significant bits of a scene channel by index.
This is the number of bits the acquisition actually filled, which can be narrower than the channel data type: 16 bit samples carrying 10 bits of camera data report 10. Returns 0 when the format does not state it or the index is out of range.
- Parameters:
channel – channel index.
- get_color_profile()¶
Raw ICC profile bytes embedded in the scene, or None if it carries none.
- get_color_profile_info()¶
Parsed ICC header of the scene colour profile, as a ColorProfileInfo.
- get_plane_timestamp(t_frame, channel, z_slice)¶
Returns when one plane was acquired, in seconds from the scene origin.
The origin is acquisition_time when the file records an acquisition start, and the scene’s earliest plane otherwise. Differences between planes are always meaningful; an absolute time needs acquisition_time to be non-zero. Returns 0 if has_plane_timestamps is False or an index is out of range.
- Parameters:
t_frame – time frame index.
channel – channel index.
z_slice – z slice index.
- get_raw_metadata()¶
Get raw metadata of the scene
- get_zoom_level_info(index)¶
Get information about a level in the internal image pyramid.
- property has_plane_timestamps¶
True if every plane of the scene has a timestamp.
- property magnification¶
Scanning magnification extracted from the slide metadata.
- property metadata¶
Scene metadata as a tree of dictionaries, lists and scalar values.
- property metadata_format¶
Get format of the metadata of the scene
- property name¶
Scene name extracted from slide metadata.”
- property num_aux_images¶
Number of auxiliary images of the scene.
- property num_channels¶
Number of raster channels in the scene raster data.
- property num_t_frames¶
Number of time frames in the scene raster data.
- property num_z_slices¶
Number slices along Z axis in the scene raster data.
- property num_zoom_levels¶
Number of zoom levels in internal image pyramid.
- property origin¶
Coordinates of the top left corner of the scene. A tuple (x, y).
- read_block(rect=(0, 0, 0, 0), size=(0, 0), channel_indices=None, slices=(0, 1), frames=(0, 1))¶
Reads rectangular block of the scene with optional rescaling.
- Parameters:
rect – block rectangle, defined as a tuple (x, y, width, height), where x,y - pixel coordinates of the top left corner of the block relatively to the scene top left corner, width, height - block width and height
size – size of the block after rescaling. (0,0) - no scaling.
channel_indices – array of channel indices to be retrieved. None or [] - all channels.
slices – range of z slices (first, last+1) to be retrieved. (0,3) for 0,1,2 slices. (0,0) for the first slice only.
frames – range of time frames (first, last+1) to be retrieved.
- Returns:
numpy array with pixel values
- read_block_from_level(level, rect=(0, 0, 0, 0), size=(0, 0), channel_indices=None, slices=(0, 1), frames=(0, 1))¶
Reads a rectangular block from an explicitly selected zoom level.
Unlike read_block, this reads from the level you name and no other, and rect is given in that level’s own pixel coordinates. Use it when you already know the level you want, so that no coordinate conversion and no implicit level selection happen on the way.
- Parameters:
level – index of the zoom level, in range(scene.num_zoom_levels)
rect – block rectangle in the coordinate system of the level, as a tuple (x, y, width, height). A width or height of 0 extends to the edge of the level. Parts outside the level come back as background.
size – size of the block after rescaling. (0,0) - no scaling. Rescaling is performed from the named level only.
channel_indices – array of channel indices to be retrieved. None or [] - all channels.
slices – range of z slices (first, last+1) to be retrieved.
frames – range of time frames (first, last+1) to be retrieved.
- Returns:
numpy array with pixel values
- property rect¶
Scene rectangle in pixels. A tuple (x-origin, y-origin, width, height).
- property resolution¶
Scene resolution in meters per pixel (pixel size in meters). A tuple (x-res, y-res)
- save_image(params, output_path, callback=None)¶
Save scene image to a file :param params: image format of the output file :param output_path: path to the output file :param callback: callback progress function
- property size¶
Scene size in pixels. A tuple (width, height).
- property t_resolution¶
Time distance between two time-frames in seconds.
- property z_resolution¶
Distance between two Z-slices in meters.