def anomaly_map_to_color_map(anomaly_map: np.ndarray, normalize: bool = True) -> np.ndarray:
    """Convert an anomaly map to a color heatmap visualization.

    This function converts a grayscale anomaly map into a color heatmap using the JET
    colormap. The anomaly map can optionally be normalized before coloring.

    Args:
        anomaly_map (np.ndarray): Grayscale anomaly map computed by the model's
            distance metric. Should be a 2D array of float values.
        normalize (bool, optional): Whether to normalize the anomaly map to [0,1] range
            before applying the colormap. If ``True``, the map is normalized using
            min-max scaling. Defaults to ``True``.

    Returns:
        np.ndarray: RGB color heatmap visualization of the anomaly map. Values are in
            range [0,255] and type uint8.

    Examples:
        Convert anomaly map without normalization:

        >>> heatmap = anomaly_map_to_color_map(anomaly_map, normalize=False)
        >>> heatmap.shape
        (224, 224, 3)
        >>> heatmap.dtype
        dtype('uint8')

        Convert with normalization (default):

        >>> heatmap = anomaly_map_to_color_map(anomaly_map)
        >>> heatmap.min(), heatmap.max()
        (0, 255)

    Note:
        - Input map is converted to uint8 by scaling to [0,255] range
        - Uses OpenCV's JET colormap for visualization
        - Output is converted from BGR to RGB color format
        - Shape of output matches input with added channel dimension
    """
    if normalize:
        anomaly_map = (anomaly_map - anomaly_map.min()) / np.ptp(anomaly_map)
    anomaly_map = anomaly_map * 255
    anomaly_map = anomaly_map.astype(np.uint8)

    anomaly_map = cv2.applyColorMap(anomaly_map, cv2.COLORMAP_JET)
    return cv2.cvtColor(anomaly_map, cv2.COLOR_BGR2RGB)
Convert an anomaly map to a color heatmap visualization.

    This function converts a grayscale anomaly map into a color heatmap using the JET
    colormap. The anomaly map can optionally be normalized before coloring.

    Args:
        anomaly_map (np.ndarray): Grayscale anomaly map computed by the model's
            distance metric. Should be a 2D array of float values.
        normalize (bool, optional): Whether to normalize the anomaly map to [0,1] range
            before applying the colormap. If ``True``, the map is normalized using
            min-max scaling. Defaults to ``True``.

    Returns:
        np.ndarray: RGB color heatmap visualization of the anomaly map. Values are in
            range [0,255] and type uint8.

    Examples:
        Convert anomaly map without normalization:

        >>> heatmap = anomaly_map_to_color_map(anomaly_map, normalize=False)
        >>> heatmap.shape
        (224, 224, 3)
        >>> heatmap.dtype
        dtype('uint8')

        Convert with normalization (default):

        >>> heatmap = anomaly_map_to_color_map(anomaly_map)
        >>> heatmap.min(), heatmap.max()
        (0, 255)

    Note:
        - Input map is converted to uint8 by scaling to [0,255] range
        - Uses OpenCV's JET colormap for visualization
        - Output is converted from BGR to RGB color format
        - Shape of output matches input with added channel dimension
    
src/anomalib/utils/post_processing.py