6.7. tracer.image Submodule¶
6.7.1. tracer.base_image¶
- class optrace.tracer.image.base_image.BaseImage(data, s=None, extent=None, projection=None, quantity='', limit=None, **kwargs)¶
Init an Image object. Parent class of ScalarImage, GrayscaleImage and RGBImage
Image dimensions should be either provided by the s or extent parameter.
When parameter ‘data’ is provided as array, element [0, 0] defines the lower left corner (negative x, negative y)
- Parameters:
image – Three-dimensional numpy array with data range [0, 1] or a file path to an image
extent (list | ndarray) – image extent in the form [xs, xe, ys, ye]
quantity (str) – name of the stored image quantity/property
limit (float) – resolution limit information. Single value in micrometers.
kwargs – additional keyword arguments for the BaseClass
projection (str)
- profile(x=None, y=None)¶
Create an image profile. Only specify one of parameters x or y.
There is no interpolation, the nearest pixel value is chosen (nearest neighbor ‘interpolation’)
- save(path, params=[], flip=False)¶
Save the image data as image file. The image is rescaled (and therefore interpolated) so we have square pixels before the export.
6.7.2. tracer.scalar_image¶
- class optrace.tracer.image.scalar_image.ScalarImage(data, s=None, extent=None, **kwargs)¶
Init a ScalarImage object.
When provided as numpy array, the image data must be non-negative and have only one channel (simple 2D array). When provided as image path, the image must have no color information.
When parameter ‘data’ is provided as array, element [0, 0] defines the lower left corner (negative x, negative y)
6.7.3. tracer.grayscale_image¶
- class optrace.tracer.image.grayscale_image.GrayscaleImage(data, s=None, extent=None, **kwargs)¶
Init a GrayscaleImage object. Subclass of ScalarImage, but communicates an image in sRGB grayscale with gamma compression.
When parameter ‘data’ is provided as array, element [0, 0] defines the lower left corner (negative x, negative y)
6.7.4. tracer.render_image¶
- class optrace.tracer.image.render_image.RenderImage(extent, projection=None, **kwargs)¶
Init an RenderImage object. This class is used to calculate and hold an Image consisting of the channels X, Y, Z, Illuminance and Irradiance.
- Parameters:
- static load(path)¶
Load a saved RenderImage (.npz) from disk.
- get(mode, N=315, L_th=0, chroma_scale=None)¶
Get a converted image with mode ‘mode’. Must be one of RenderImage.image_modes.
N describes the pixel count (of the smaller side) to which the image is rescaled to. N should be one of RenderImage.SIZES, but the nearest value is automatically selected. Rescaling is done by joining bins, so there is no interpolation.
Depending on the image mode, the returned image is an RGBImage with three channels or a ScalarImage with one channel.
Parameters L_th and chroma_scale are only needed for mode=’sRGB (Perceptual RI)’, see function color.xyz_to_srgb_linear for more details.
- Parameters:
- Returns:
RGBImage or ScalarImage, depending on ‘mode’
- Return type:
- render(p=None, w=None, wl=None, limit=None, _dont_filter=False)¶
Creates an pixel image from ray positions on the detector.
- Parameters:
- Return type:
None
- save(path)¶
Save the RenderImage as .npz archive. Files are overridden. Throws IOError if the file could not been saved.
- Parameters:
path (str) – path to save to
- Return type:
None
- MAX_IMAGE_RATIO: int = 5¶
maximum ratio of image side lengths. Images with ratios beyond will be corrected
- SIZES: list[int] = [1, 3, 5, 7, 9, 15, 21, 27, 35, 45, 63, 105, 135, 189, 315, 945]¶
valid image side lengths (smallest side)
6.7.5. tracer.rgb_image¶
- class optrace.tracer.image.rgb_image.RGBImage(data, s=None, extent=None, **kwargs)¶
Init a RGBImage object.
When provided as numpy array, the image data must have values in range [0, 1] and three channels in the third dimension. When provided as image path, the image is loaded with three channels regardless of colorspace.
When parameter ‘data’ is provided as array, element [0, 0] defines the lower left corner (negative x, negative y)
- Parameters:
- to_grayscale_image()¶
Create an GrayscaleImage from this object. Channel values are averaged.
- Returns:
GrayscaleImage
- Return type: