NoiseAdder Module
Warning
This module is considered internal.
NoiseAdder is an abstract base class designed to handle the application of noise to images. Subclasses inheriting from NoiseAdder must implement its abstract methods to define specific noise-adding behaviors.
Attributes
-
noises :
list[Noise]A list of
Noiseobjects that represent different noise types to be applied to the images. EachNoiseobject should adhere to the structure and behavior defined by theNoiseclass from the iftg.noises module. -
output_path :
strThe path where the processed image will be saved.
-
identifier :
strA unique identifier for the noise adder instance. This is used to distinguish between different noise adders or configurations.
Methods
_apply_noises()
This method applies the specified noises to an image. It is an abstract method that must be implemented by any subclass.
-
Parameters:
-
image :
ImageThe image object to which noises will be applied.
-
-
Returns:
- A
tuplecontaining:- The transformed
Imageobject (after applying noise), - A
strrepresenting the name or format of the image, - A
strrepresenting the extension or format for saving the image (e.g.,.tif,.jpg).
- The transformed
- A
add_noises()
This method generates a list of images or a single image with noises applied. Subclasses must implement this method to handle batch noise application to multiple images.
-
Returns:
- A
list[tuple]where each tuple contains:- The transformed
Image, - The image name
str, - The image format or extension
str.
- The transformed
- A
save_image()
This method saves an image after noises have been applied. It takes a tuple containing the image, name, and format and saves the image to the corresponding file.
-
Parameters:
-
img_info :
tuple[Image.Image, str, str]The tuple representing the image and its saving information.
-
-
Returns:
None