Create_DDB module#

The database generated by the CreeBD class is designed to make the data base.

The CreeBD class performs several steps on the input images before generating the database:

1. Conversion to Grayscale

The images are converted to grayscale using the convert(‘L’) method. Grayscale conversion simplifies the image representation by reducing it to a single channel, eliminating the color information. This is also advantageous as it reduces the input dimensionality and removes potential noise or variations caused by color channels.

2. Thresholding

The seuil method applies a threshold to the grayscale image. Thresholding involves converting the image into a binary format by assigning a fixed value to pixels based on a predefined threshold. This help in simplifying the image by distinguishing between foreground and background regions or separating important features from the background.

3. Resizing

The resize method resizes the image to a fixed width and height. Resizing is beneficial for neural networks as it ensures uniform input dimensions, which is often required for efficient processing. Additionally, resizing help in reducing computational complexity and memory requirements.

4. Translation and Rotation

The translation and rotation methods perform geometric transformations on the image data. These transformations enhance the network’s ability to generalize by introducing variations and augmenting the training dataset. By applying random translations and rotations, the network becomes more robust to changes in position and orientation of the objects in the images.

Note

By applying these preprocessing techniques, the CreeBD class simplifies the original image data and prepares it for the neural network training process.

The simplified representations help the network focus on relevant patterns and features.

class Create_DDB.CreeBD(Test=True, nbrimageset=500)[source]#

Bases: object

Class for creating the image database.

Parameters: - Test (bool): Indicates whether to run the create test database mode or not. Default is True. - nbrimageset (int): Number of image sets to generate. Default is 500.

__init__(Test=True, nbrimageset=500)[source]#

Initializes the CreeBD class.

Args: - Test (bool): Indicates whether to run the test mode or not. Default is True. - nbrimageset (int): Number of image sets to generate. Default is 500.

randgen(im, ni, tq=True)[source]#

Generates random images.

Args: - im: Input image. - ni (int): Number of images to generate. - tq (bool): Indicates whether to display progress bar. Default is True.

Returns: - X (list): List of generated images.

resize(image, l, m)[source]#

Resizes the image.

Args: - image: Input image. - l (int): Width of the resized image. - m (int): Height of the resized image.

Returns: - Resized image.

rotation(image, deg)[source]#

Rotates the image.

Args: - image: Input image. - deg (float): Rotation angle in degrees.

Returns: - Rotated image.

seuil(imNB, s)[source]#

Applies a threshold to the image.

Args: - imNB: Input grayscale image. - s (int): Threshold value.

Returns: - Thresholded image.

translation(image, x, y)[source]#

Translates the image.

Args: - image: Input image. - x (float): Translation along the x-axis. - y (float): Translation along the y-axis.

Returns: - Translated image.