Tiled
Image tiling module
- pydantic model PixelValueModel[source]
Bases:
BaseModel
Pydantic model class for VisiOmatic pixel values.
Show JSON schema
{ "title": "PixelValueModel", "description": "Pydantic model class for VisiOmatic pixel values.\n\nParameters\n----------\nvalues: list[float | None]\n Pixel values.", "type": "object", "properties": { "values": { "items": { "anyOf": [ { "type": "number" }, { "type": "null" } ] }, "title": "Values", "type": "array" } }, "required": [ "values" ] }
- Fields:
- pydantic model PixelModel[source]
Bases:
BaseModel
Pydantic model class for pixels.
- Parameters:
Show JSON schema
{ "title": "PixelModel", "description": "Pydantic model class for pixels.\n\nParameters\n----------\nx: int\n x coordinate of the pixel.\ny: int\n y coordinate of the pixel.\nvalues: list[float, None]\n Pixel values.", "type": "object", "properties": { "x": { "title": "X", "type": "integer" }, "y": { "title": "Y", "type": "integer" }, "values": { "items": { "anyOf": [ { "type": "number" }, { "type": "null" } ] }, "title": "Values", "type": "array" } }, "required": [ "x", "y", "values" ] }
- pydantic model ProfileModel[source]
Bases:
BaseModel
Pydantic model class for VisiOmatic profiles.
- Parameters:
profile (list[PixelModel]) -- List of pixel models.
Show JSON schema
{ "title": "ProfileModel", "description": "Pydantic model class for VisiOmatic profiles.\n\nParameters\n----------\nprofile: list[PixelModel]\n List of pixel models.", "type": "object", "properties": { "profile": { "items": { "$ref": "#/$defs/PixelModel" }, "title": "Profile", "type": "array" } }, "$defs": { "PixelModel": { "description": "Pydantic model class for pixels.\n\nParameters\n----------\nx: int\n x coordinate of the pixel.\ny: int\n y coordinate of the pixel.\nvalues: list[float, None]\n Pixel values.", "properties": { "x": { "title": "X", "type": "integer" }, "y": { "title": "Y", "type": "integer" }, "values": { "items": { "anyOf": [ { "type": "number" }, { "type": "null" } ] }, "title": "Values", "type": "array" } }, "required": [ "x", "y", "values" ], "title": "PixelModel", "type": "object" } }, "required": [ "profile" ] }
- field profile: list[PixelModel] [Required]
- pydantic model TiledModel[source]
Bases:
BaseModel
Pydantic tiled model class.
- Parameters:
type (str) -- Name of the web service.
version (str) -- Version of the web service.
full_size (List[int]) -- Full raster size, FITS style (x comes first).
tile_size (List[int]) -- Tile size, FITS style.
tile_levels (int) -- Number of levels in the image pyramid.
channels (int) -- Number of channels.
bits_per_channel (int) -- Number of bits per pixel.
brightness (float) -- Relative tile brightness (black level).
contrast (float) -- Relative tile contrast.
color_saturation (float) -- Tile color saturation.
gamma (float) -- Tile display gamma.
quality (int) -- JPEG quality (0-100).
header (dict) -- Image header keyword/value pairs.
images (List[ImageModel]) -- List of image model objects.
Show JSON schema
{ "title": "TiledModel", "description": "Pydantic tiled model class.\n\nParameters\n----------\ntype: str\n Name of the web service.\nversion: str\n Version of the web service.\nfull_size: List[int]\n Full raster size, FITS style (x comes first).\ntile_size: List[int]\n Tile size, FITS style.\ntile_levels: int\n Number of levels in the image pyramid.\nchannels: int\n Number of channels.\nbits_per_channel: int \n Number of bits per pixel.\nbrightness: float\n Relative tile brightness (black level).\ncontrast: float\n Relative tile contrast.\ncolor_saturation: float\n Tile color saturation.\ngamma: float\n Tile display gamma.\nquality: int\n JPEG quality (0-100).\nheader: dict\n Image header keyword/value pairs.\nimages: List[ImageModel]\n List of image model objects.", "type": "object", "properties": { "type": { "title": "Type", "type": "string" }, "version": { "title": "Version", "type": "string" }, "image_name": { "title": "Image Name", "type": "string" }, "object_name": { "title": "Object Name", "type": "string" }, "full_size": { "items": { "type": "integer" }, "title": "Full Size", "type": "array" }, "tile_size": { "items": { "type": "integer" }, "title": "Tile Size", "type": "array" }, "tile_levels": { "title": "Tile Levels", "type": "integer" }, "channels": { "title": "Channels", "type": "integer" }, "bits_per_channel": { "title": "Bits Per Channel", "type": "integer" }, "brightness": { "title": "Brightness", "type": "number" }, "contrast": { "title": "Contrast", "type": "number" }, "color_saturation": { "title": "Color Saturation", "type": "number" }, "gamma": { "title": "Gamma", "type": "number" }, "quality": { "title": "Quality", "type": "integer" }, "header": { "title": "Header", "type": "object" }, "images": { "items": { "$ref": "#/$defs/ImageModel" }, "title": "Images", "type": "array" } }, "$defs": { "ImageModel": { "description": "Pydantic image model class.\n\nParameters\n----------\nsize: List[int]\n Image shape, FITS style (x comes first)\ndataslice: List[List[int]]\n Active area slice parameters, FITS style\ndetslice: List[List[int]]\n Mosaic area slice parameters, FITS style\nmin_max: List[List[float]]\n Lower and upper intensity cuts for each channel\nheader: dict\n FITS header dictionary", "properties": { "size": { "items": { "type": "integer" }, "title": "Size", "type": "array" }, "dataslice": { "items": { "items": { "type": "integer" }, "type": "array" }, "title": "Dataslice", "type": "array" }, "detslice": { "items": { "items": { "type": "integer" }, "type": "array" }, "title": "Detslice", "type": "array" }, "background_level": { "items": { "type": "number" }, "title": "Background Level", "type": "array" }, "background_mad": { "items": { "type": "number" }, "title": "Background Mad", "type": "array" }, "min_max": { "items": { "items": { "type": "number" }, "type": "array" }, "title": "Min Max", "type": "array" }, "header": { "title": "Header", "type": "object" } }, "required": [ "size", "dataslice", "detslice", "background_level", "background_mad", "min_max", "header" ], "title": "ImageModel", "type": "object" } }, "required": [ "type", "version", "image_name", "object_name", "full_size", "tile_size", "tile_levels", "channels", "bits_per_channel", "brightness", "contrast", "color_saturation", "gamma", "quality", "header", "images" ] }
- Fields:
- field images: List[ImageModel] [Required]
- class Tiled(filename: str, extnum: int | None = None, tilesize: Tuple[int, int] = (256, 256), minmax: Tuple[int, int] | None = None, brightness: float | None = None, contrast: float | None = None, color_saturation: float | None = None, gamma: float | None = None, quality: int | None = None, max_region_tile_count: int | None = None, nthreads: int | None = None)[source]
Bases:
object
Class for the tiled image pyramid to be visualized.
- Parameters:
extnum (int, optional) -- Extension number (for Multi-Extension FITS files).
tilesize (tuple[int, int], optional) -- shape of the served tiles.
minmax (tuple[float, float], optional) -- Intensity cuts of the served tiles.
brightness (float, optional) -- Relative tile black level of the served tiles.
contrast (float, optional) -- Relative tile contrast of the served tiles.
color_saturation (float, optional) -- Default color saturation of the served tiles.
gamma (float, optional) -- Display gamma of the served tiles.
nthreads (int, optional) -- Number of compute threads for parallelized operations.
- compute_nlevels() int [source]
Return the number of image resolution levels.
- Returns:
nlevels (int) -- Number of image resolution levels in the pyramid.
- compute_grid_shape(level: int = 0) Tuple[int, int, int] [source]
Return the number of tiles per axis at a given image resolution level.
- Returns:
shape (tuple[int, int, int]) -- Number of tiles.
- compute_tile_bordershape(level=0) Tuple[int, int, int] [source]
Return the border shape of tiles at a given image resolution level.
- Returns:
shape (tuple[int, int, int]) -- Border shape.
- get_model() TiledModel [source]
Return a Pydantic model of the tiled object.
- Returns:
model (TiledModel) -- Pydantic model instance of the tiled object
- make_header() fits.header [source]
Generate a FITS header with a global WCS for the mosaic.
- Returns:
header (~astropy.io.fits.Header) -- FITS header for the mosaic.
- get_iipheaderstr() str [source]
Generate an IIP image header.
- Returns:
header (str) -- IIP image header.
- convert_tile(tile: ndarray, channel: int | None = None, minmax: Tuple[Tuple[int, float, float], ...] | None = None, mix: Tuple[Tuple[int, float, float, float], ...] | None = None, brightness: float | None = None, contrast: float | None = None, gamma: float | None = None, colormap: str = 'grey', invert: bool = False) ndarray [source]
Process the dynamic range of a tile.
- Parameters:
tile (ndarray) -- Input tile.
channel (int, optional) -- Image channel
minmax (list[float, float], optional) -- Tile intensity cuts.
mix (list[int, float, float, float], optional) -- Tile slice RGB colors.
brightness (float, optional) -- Relative tile brightness (black level).
contrast (float, optional) -- Relative tile contrast.
gamma (float, optional) -- Inverse tile display gamma.
colormap (str, optional) -- Colormap: 'grey' (default), 'jet', 'cold', or 'hot'.
invert (bool, optional) -- Invert the colormap.
- Returns:
raster (~numpy.ndarray) -- Processed tile image raster.
- get_tile_raster(tilelevel: int, tileindex: int, channel: int | None = None, minmax: Tuple[Tuple[int, float, float], ...] | None = None, mix: Tuple[Tuple[int, float, float, float], ...] | None = None, brightness: float | None = None, contrast: float | None = None, gamma: float | None = None, colormap: str = 'grey', invert: bool = False, **_: Any) ndarray [source]
Compute a gray-level or color image raster from a tile.
- Parameters:
tilelevel (int) -- Tile resolution level.
tileindex (int) -- Tile index.
channel (int) -- Data channel (first channel is 1)
minmax (list[float, float], optional) -- Tile intensity cuts.
brightness (float, optional) -- Relative tile brightness.
contrast (float, optional) -- Relative tile contrast.
gamma (float, optional) -- Inverse tile display gamma.
colormap (str, optional) -- Colormap: 'grey' (default), 'jet', 'cold', or 'hot'.
invert (bool, optional) -- Invert the colormap.
- Returns:
raster (~numpy.ndarray) -- The computed tile image raster.
- encode(raster: ndarray, channel: int | None = None, colormap: str = 'grey', quality: int | None = None, **_: Any) bytes [source]
Generate a JPEG bytestream from an image raster (e.g., a tile).
- get_encoded_region(bounds: Tuple[Tuple[int, int], Tuple[int, int]], binning: int = 1, channel: int | None = None, colormap: str = 'grey', **kwargs: Any) bytes [source]
Return a JPEG bytestream of a specific image region by stitching tiles that fall in that region.
- Parameters:
bounds (tuple[tuple[int, int], tuple[int, int]]) -- Image boundaries in pixels.
binning (int, optional) -- Binning factor per axis, in pixels.
channel (int, optional) -- Data channel (first channel is 1)
colormap (str, optional) -- Colormap: 'grey' (default), 'jet', 'cold', or 'hot'.
**kwargs -- Additional get_tile_raster() and encode() keyword arguments.
- Returns:
tile (bytes) -- JPEG bytestream of the tile.
- Raises:
IndexError -- exception: An error occurred because of unexpected bounding box coordinates. It is raised if any of the following occur: - The number of requested region tiles exceeds max_region_tile_count. - Bounding box coordinates are inconsistent.
- get_pixel_values(channels: Tuple[int], pos: Tuple[int, int]) PixelValueModel [source]
Get pixel values at the given pixel coordinates in merged frame.
- get_profiles(channels: Tuple[int, ...] | None, pos1: Tuple[int, int], pos2: Tuple[int, int]) ProfileModel [source]
Get image profile(s) between the given pixel coordinates in the merged frame.
- Parameters:
- Returns:
profile (ProfileModel) -- Profile pydantic model of pixel value(s) along the line.
- pickledTiled(filename: str, **kwargs) Tiled [source]
Return pickled Tiled object if available, or initialized otherwise.
- get_object_filename(image_filename: str) str [source]
Return the name of the file containing the pickled Tiled object.
- Parameters:
filename (Image) -- Full image filename.
- Returns:
filename (str) -- Pickled object filename.
- get_data_filename(image_filename: str) str [source]
Return the name of the file containing the memory-mapped image data.
- Parameters:
filename (Image) -- Full image filename.
- Returns:
filename (str) -- Filename of the memory-mapped image data.