scistag.imagestag.image_base.ImageBase¶
- class ImageBase[source]¶
Bases:
objectDefines the base class for
Imageand provides object indepedent helper methods.Methods
Converts BGR to RGB or the otherwise round
Detects the format
Creates an image from a "classic" bgr, bgra or grayscale OpenCV source.
Guarantees that the output will be in the BGR or BGRA format
Guarantees that the output will be grayscale
Guarantees that the output will be in the RGB or RGBA format
Attributes
__dict____doc____module____weakref__list of weak references to the object (if defined)
- classmethod _pixel_data_from_source(source)[source]¶
Loads an arbitrary source and returns it as pixel data
- static bgr_to_rgb(pixel_data)[source]¶
Converts BGR to RGB or the otherwise round
- Parameters
pixel_data (
ndarray) – The input pixel data- Return type
ndarray- Returns
The output pixel data
- classmethod detect_format(pixels, is_cv2=False)[source]¶
Detects the format
- Parameters
pixels (
ndarray) – The pixelsis_cv2 – Defines if the source was OpenCV
- Returns
The pixel format. See PixelFormat
- classmethod from_cv2(pixel_data)[source]¶
Creates an image from a “classic” bgr, bgra or grayscale OpenCV source.
For more advanced type please use the standard constructor.
- Parameters
pixel_data (
ndarray) – The pixel data- Return type
- Returns
The image instance
- classmethod normalize_to_bgr(pixels, input_format=PixelFormat.RGB, keep_gray=False)[source]¶
Guarantees that the output will be in the BGR or BGRA format
- Parameters
pixels (
ndarray) – The pixel datainput_format (
PixelFormat) – The input format representation, e.g. seePixelFormatkeep_gray – Defines if single channel formats shall be kept intact. False by default.
- Return type
ndarray- Returns
The BGR image as numpy array. If keep_gray was set and the input was single channeled the original.
- classmethod normalize_to_gray(pixels, input_format=PixelFormat.RGB)[source]¶
Guarantees that the output will be grayscale
- Parameters
pixels (
ndarray) – The pixel datanp.ndarrayinput_format (
PixelFormat) – The input format representation, e.g. seePixelFormat
- Return type
ndarray- Returns
The grayscale image as
np.ndarray
- classmethod normalize_to_rgb(pixels, input_format=<enum 'PixelFormat'>, keep_gray=False)[source]¶
Guarantees that the output will be in the RGB or RGBA format
- Parameters
pixels (
ndarray) – The pixel data asnp.ndarrayinput_format (
PixelFormat) – The input format representation, e.g. seePixelFormatkeep_gray – Defines if single channel formats shall be kept intact. False by default.
- Return type
ndarray- Returns
The RGB image as numpy array. If keep_gray was set and the input was single channeled the original.