:py:mod:`HAlphaAnomalyzer._cell_average_calculator` =================================================== .. py:module:: HAlphaAnomalyzer._cell_average_calculator Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: HAlphaAnomalyzer._cell_average_calculator._calculate_cell_average_per_image HAlphaAnomalyzer._cell_average_calculator._calculate_cell_average_per_batch HAlphaAnomalyzer._cell_average_calculator._calculate_cell_average .. py:function:: _calculate_cell_average_per_image(image_path, label, grid_size=8) 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_path : str The path to the image file. label : int The label indicating if the image is anomalous (1) or non-anomalous (0). grid_size : int, optional The number of rows and columns to divide the image into, by default 8. Returns ------- image_data : List[List[str, int, int, float, int]] A list containing the calculated average pixel values for each grid cell in the image. .. py:function:: _calculate_cell_average_per_batch(image_paths, label, grid_size=8, desc='Processing Training Images') 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_paths : List[str] A list of paths to the image files. label : int The label indicating if the images are anomalous (1) or non-anomalous (0). grid_size : int, optional The number of rows and columns to divide each image into, by default 8. desc : str, optional Description for the tqdm progress bar, by default "Processing Training Images". Returns ------- result_df : pd.DataFrame A DataFrame containing the calculated average pixel values for each grid cell in each training image. .. py:function:: _calculate_cell_average(non_anomalous_paths=None, anomalous_paths=None, grid_size=8) 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_paths : List[str], optional A list of paths to non-anomalous image files, by default None. anomalous_paths : List[str], optional A list of paths to anomalous image files, by default None. grid_size : int, optional The number of rows and columns to divide each image into, by default 8. Returns ------- result_df : pd.DataFrame A DataFrame containing the calculated average pixel values for each grid cell in the anomalous and/or non-anomalous training image batches.