Last modified: February 14, 2023
Contents
Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] nested_list_to_image (object nested_list, Choice [ONEBIT|GREYSCALE|GREY16|RGB|FLOAT] image_type)
Returns: | Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] |
---|---|
Category: | Utility/NestedLists |
Defined in: | image_utilities.py |
Author: | Michael Droettboom and Karl MacMillan |
Converts a nested Python list to an Image. Is the inverse of to_nested_list.
The resulting image type. Should be one of the integer Image type constants (ONEBIT, GREYSCALE, GREY16, RGB, FLOAT). If image_type is not provided or less than 0, the image type will be determined by auto-detection from the list. The following list shows the mapping from Python type to image type:
To obtain other image types, the type number must be explicitly passed.
NOTE: This will not scale very well and should only be used for small images, such as convolution kernels.
Examples:
# Sobel kernel (implicitly will be a FLOAT image)
kernel = nested_list_to_image([[0.125, 0.0, -0.125],
[0.25 , 0.0, -0.25 ],
[0.125, 0.0, -0.125]])
# Single row image (note that nesting is optional)
image = nested_list_to_image([RGBPixel(255, 0, 0),
RGBPixel(0, 255, 0),
RGBPixel(0, 0, 255)])
object to_nested_list ()
Operates on: | Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] |
---|---|
Returns: | object |
Category: | Utility/NestedLists |
Defined in: | image_utilities.py |
Author: | Michael Droettboom and Karl MacMillan |
Converts an image to a nested Python list. This method is the inverse of nested_list_to_image.
The following table describes how each image type is converted to Python types:
- ONEBIT -> int
- GREYSCALE -> int
- GREY16 -> int
- RGB -> RGBPixel
- FLOAT -> float
NOTE: This will not scale very well and should only be used for small images, such as convolution kernels.
[object] ccs_from_labeled_image ()
Operates on: | Image [OneBit] |
---|---|
Returns: | [object] |
Category: | Utility |
Defined in: | image_utilities.py |
Author: | Christoph Dalitz and Hasan Yildiz |
Returns all Cc's represented by unique labels in the given onebit image. The bounding boxes are computed as tight as possible.
This is mostly useful for reading manually labeled groundtruth data from color PNG files in combination with the plugin colors_to_labels. Example:
labeled = rgb.colors_to_labels()
ccs = labeled.ccs_from_labeled_image()
Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] clip_image (Rect other)
Operates on: | Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] |
---|---|
Returns: | Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] |
Category: | Utility |
Defined in: | image_utilities.py |
Author: | Michael Droettboom and Karl MacMillan |
Crops an image so that the bounding box includes only the intersection of it and another image. Returns a zero-sized image if the two images do not intersect.
generate_features (list features, bool force)
Operates on: | Image [OneBit] |
---|---|
Category: | Utility |
Defined in: | features.py |
Author: | Michael Droettboom and Karl MacMillan |
Generates features for the image by calling a number of feature functions and storing the results in the image's features member variable (a Python array).
Warning
For efficiency, if the given feature functions match those that have been already generated for the image, the features are not recalculated. If you want to force recalculation, pass the optional argument force=True.
Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] image_copy (Choice [DENSE|RLE] storage_format)
Operates on: | Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] |
---|---|
Returns: | Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] |
Category: | Utility |
Defined in: | image_utilities.py |
Author: | Michael Droettboom and Karl MacMillan |
Copies an image along with all of its underlying data. Since the data is copied, changes to the new image do not affect the original image.
image_save (FileSave image_file_name, Choice [TIFF|PNG] File format)
Operates on: | Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] |
---|---|
Category: | Utility |
Defined in: | image_utilities.py |
Author: | Michael Droettboom and Karl MacMillan |
Saves an image to file with specified name and format.
float mse (Image [RGB] None)
Operates on: | Image [RGB] |
---|---|
Returns: | float |
Category: | Utility |
Defined in: | image_utilities.py |
Author: | Michael Droettboom and Karl MacMillan |
Calculates the mean square error between two images.
Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] pad_image (int top, int right, int bottom, int left, Pixel value)
Operates on: | Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] |
---|---|
Returns: | Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] |
Category: | Utility |
Defined in: | image_utilities.py |
Author: | Michael Droettboom and Karl MacMillan |
Pads an image with any value. When no pixel value is given, the value corresponding to the color white is used.
Example 1: pad_image(5, 10, 15, 20)
reset_onebit_image ()
Operates on: | Image [OneBit] |
---|---|
Category: | Utility |
Defined in: | image_utilities.py |
Author: | Christoph Dalitz |
Resets all black pixel values in a onebit image to one. This can be necessary e.g. after a CC analysis which sets black pixels to some other label value.
Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] subimage (Point upper_left, Point lower_right)
Operates on: | Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] |
---|---|
Returns: | Image [OneBit|GreyScale|Grey16|RGB|Float|Complex] |
Category: | Utility |
Defined in: | plugin.py |
Author: | Michael Droettboom and Karl MacMillan |
Creates a new view on existing data.
There are a number of ways to create a subimage:
- subimage(Point upper_left, Point lower_right)
- subimage(Point upper_left, Size size)
- subimage(Point upper_left, Dim dim)
- subimage(Rect rectangle)
Changes to subimages will affect all other subimages viewing the same data.
Warning
The upper_left and lower_right coordinates are absolute and not relative to the image origin. Hence, for all practical use cases, you must add the image offset to the coordinates, e.g.
subimg = image.subimage(Point(p.x + image.offset_x, p.y + image.offset_y), dim)
# or, equivalently:
subimg = image.subimage(p + image.ul, dim)
Image [OneBit|GreyScale|Grey16|Float|RGB] trim_image (Pixel PixelValue = None)
Operates on: | Image [OneBit|GreyScale|Grey16|Float|RGB] |
---|---|
Returns: | Image [OneBit|GreyScale|Grey16|Float|RGB] |
Category: | Utility |
Defined in: | image_utilities.py |
Author: | Tobias Bolten |
Returns minimal view so that outside of the view only Pixels with PixelValue exists. When no PixelValue is given, white is used.