sharpedge.pooling_image ======================= .. py:module:: sharpedge.pooling_image Functions --------- .. autoapisummary:: sharpedge.pooling_image.pooling_image Module Contents --------------- .. py:function:: pooling_image(img, window_size, pooling_method=np.mean) Perform pooling on an image using a specified window size and pooling function. :param img: The input image as a 2D numpy array (grayscale) or 3D numpy array (RGB). :type img: numpy.ndarray :param window_size: The size of the pooling window (e.g., 10 for 10x10 windows). :type window_size: int :param pooling_method: The pooling function to apply to each window. Common options include `numpy.mean`, `numpy.median`, `numpy.max`, and `numpy.min`. Default is `numpy.mean`. :type pooling_method: callable, optional :returns: The resized image, reduced by the pooling operation based on the specified window size and pooling function. For grayscale images, the result is a 2D array. For RGB images, the result is a 3D array normalized to the range [0.0, 1.0]. :rtype: numpy.ndarray :raises TypeError: If `window_size` is not an integer or `pooling_method` is not callable. :raises ValueError: If the image dimensions are not divisible by the window size. .. rubric:: Examples >>> img = np.random.rand(100, 100) >>> pooled_img = pooling_image(img, window_size=10, pooling_method=np.mean) For an RGB image: >>> img_rgb = np.random.rand(100, 100, 3) >>> pooled_img = pooling_image(img_rgb, window_size=20, pooling_method=np.max)