Transformers
Transformers can be accessed using the transformer
attribute of the image object.
From here you can access all the specific transformer attributes: cropper
, geometrizer
, morphologyzer
, binarizer
.
However to make the developer experience more user friendly, the transformers are also available as direct methods of the image object. For example, cropping an image is as easy as:
import otary as ot
im = ot.Image.from_file(filepath="path/to/file/image")
im.crop(x0=50, y0=50, x1=450, y1=450)
Otary gives you the choice between being more explicit or more synthetic in your code.
Components
Here are the different specialized components that can be used to transform images:
- Cropping: cropping methods
- Geometry: geometric operations
- Morphology: morphological operations
- Binarization & Thresholding: binarization and thresholding
The copy
parameter
Some methods (all the cropping methods, some morphology methods like resize, etc...) have a boolean copy
parameter.
By default, the copy
parameter is set to False
which means that the original image is modified and then returned.
This is the default behaviour of all the methods in the Otary library.
However, when copy
is set to True
, a new Image
object is returned and the original image is not modified.
This is useful when you want to create a new image after the transformation without modifying the original image.
Consider an example where you want to crop an image:
Wrong way of cropping and preserving the original image
This approach works but can be considerably slower especially when the image is large because you first copy the image and then crop it.
This would instead be the correct way to crop and preserve the original image: