HAlphaAnomalyzer._cell_average_calculator

Module Contents

Functions

_calculate_cell_average_per_image(image_path, label[, ...])

Calculate the average pixel value for each cell in a grid for a given

_calculate_cell_average_per_batch(image_paths, label)

Process a batch of training images and compute the average pixel value for each cell in each image.

_calculate_cell_average([non_anomalous_paths, ...])

Calculate the average pixel value for each cell in a grid for batches of

HAlphaAnomalyzer._cell_average_calculator._calculate_cell_average_per_image(image_path, label, grid_size=8)[source]

Calculate the average pixel value for each cell in a grid for a given image.

This function reads the image from the specified path in grayscale, divides it into a grid of the given size, and computes the average pixel value for each cell.

Parameters

image_pathstr

The path to the image file.

labelint

The label indicating if the image is anomalous (1) or non-anomalous (0).

grid_sizeint, optional

The number of rows and columns to divide the image into, by default 8.

Returns

image_dataList[List[str, int, int, float, int]]

A list containing the calculated average pixel values for each grid cell in the image.

HAlphaAnomalyzer._cell_average_calculator._calculate_cell_average_per_batch(image_paths, label, grid_size=8, desc='Processing Training Images')[source]

Process a batch of training images and compute the average pixel value for each cell in each image.

This function iterates through a list of image paths, processing each image to calculate the average pixel values for its grid cells.

Parameters

image_pathsList[str]

A list of paths to the image files.

labelint

The label indicating if the images are anomalous (1) or non-anomalous (0).

grid_sizeint, optional

The number of rows and columns to divide each image into, by default 8.

descstr, optional

Description for the tqdm progress bar, by default “Processing Training Images”.

Returns

result_dfpd.DataFrame

A DataFrame containing the calculated average pixel values for each grid cell in each training image.

HAlphaAnomalyzer._cell_average_calculator._calculate_cell_average(non_anomalous_paths=None, anomalous_paths=None, grid_size=8)[source]

Calculate the average pixel value for each cell in a grid for batches of anomalous and/or non-anomalous training images.

This function processes batches of anomalous and/or non-anomalous image paths, computing the average pixel values for their grid cells.

Parameters

non_anomalous_pathsList[str], optional

A list of paths to non-anomalous image files, by default None.

anomalous_pathsList[str], optional

A list of paths to anomalous image files, by default None.

grid_sizeint, optional

The number of rows and columns to divide each image into, by default 8.

Returns

result_dfpd.DataFrame

A DataFrame containing the calculated average pixel values for each grid cell in the anomalous and/or non-anomalous training image batches.