visumorph.Image
Module Contents
Classes
The main class for VisuMorph Image objects. |
Functions
|
Load an image from filesystem and return an Image object. |
- class visumorph.Image.Image(image)[source]
The main class for VisuMorph Image objects.
- save(file_path)[source]
Saves the image to a file.
- Parameters:
file_path (str) – The path where the image should be saved.
- __self_inject(func)
Wrapper method to self-inject into visumorph functions.
- flip(*args, **kwargs)[source]
Flip image vertically or horizontally.
- Parameters:
v (int, optional) – Flip vertically if v=1, horizontally if v=0. By default, v=0.
- Returns:
Flipped VisuMorph image.
- Return type:
image
- Raises:
TypeError – If the image is not a valid VisuMorph Image and/or v is not 0 or 1.
Examples
>>> import visumorph >>> from visumorph.flip import flip >>> img = visumorph.load_image("exampleimage.jpg") >>> img.flip(v=1)
- rotate(*args, **kwargs)[source]
Rotate an image with a given rotation.
This method will rotate a VisuMorph image by a given degree of rotation. A background image can be specified for filling any empty spaces which are not covered by the image after rotation.
- Parameters:
rotation (float) – The desired rotation angle in degrees. +ve means clockwise while -ve means counter-clockwise.
background (visumorph.Image, optional) – The background image to be filled in where the rotated image is not covered. Default is None, which a black background image would be used.
- Returns:
The VisuMorph Image after rotation.
- Return type:
image
- Raises:
TypeError – If the image is not a valid VisuMorph Image and/or rotation given is not a number.
Examples
>>> import visumorph as vm >>> img = vm.load_image("test.jpg") >>> rotated_45_img = img.rotate(img, 45.0)
- scale(*args, **kwargs)[source]
Enlarge/Shrink an image with a given scale.
This method will scale a VisuMorph image by a given scale with 1.0 as the original scale. The final transformed image would have a dimension of (scale * original_width, scale * original_height), rounded top to the nearest integer.
- Parameters:
scale (float or int) – The desired scale. The original scale of the image is 1.0. A scale larger than 1.0 will result in a final image having a larger dimension, and vice versa. Cannot be equal or smaller than 0.0.
- Returns:
The VisuMorph Image scaled.
- Return type:
image
- Raises:
TypeError – If the image is not a valid VisuMorph Image and/or scale given is not a number.
ValueError – If the scale provided is equal 0 or is a negative number.
Examples
>>> import visumorph as vm >>> img = vm.load_image("test.jpg") >>> scaled_img = img.scale(img, 1.15)
- change_hue(*args, **kwargs)[source]
Change the hue of a VisuMorph Image object by blending it with a layer of specified color.
- Parameters:
color (str, optional) – The color used for the blending layer (default is “white”).
delta_hue (float or int, optional) – The degree of blending with the color layer. A value of 0 means no change, and 1 means complete replacement with the color layer (default is 1).
- Returns:
Image – A new VisuMorph Image object with the modified hue.
- Return type:
- Raises:
TypeError – If the input is not a valid VisuMorph Image object.
ValueError – If ‘delta_hue’ is not a number.
Examples
>>> import visumorph as vm >>> img = vm.load_image("test.jpg") >>> hue_changed = img.change_hue(img)