Compare 1 and 2 which is better. 1: def adjust_values(img: np.ndarray) -> tuple[np.ndarray, int, int]:
    """Adjust the values of a grayscale image."""
    try:
        # Calculate modal white value in the range [250, 256)
        hist_white, bins_white = np.histogram(img[img >= 250], bins=6, range=(250, 256))
        modal_white = int(bins_white[np.argmax(hist_white)])

        # Calculate modal black value in the range [0, 61)
        hist_black, bins_black = np.histogram(img[img < 61], bins=61, range=(0, 61))
        modal_black = int(bins_black[np.argmax(hist_black)])

        # Convert image to float for processing
        adjusted = img.astype(np.float64)

        # Scale image if modal white is not at maximum intensity
        if modal_white != 255:
            adjusted *= 255.0 / modal_white
            adjusted = np.clip(adjusted, 0, 255)

        # Adjust image based on modal black value
        if modal_black:
            adjusted = (adjusted - modal_black) * (255.0 / (255 - modal_black))
            adjusted = np.clip(adjusted, 0, 255)

            gamma = 1.0 - (modal_black / 255.0)
            adjusted = np.power(adjusted / 255.0, gamma) * 255

            # Preserve original extreme values
            adjusted[img == 0] = 0
            adjusted[img == 255] = 255

        # Convert back to unsigned 8-bit integer
        adjusted = adjusted.astype(np.uint8)

        return adjusted, modal_black, modal_white

    except ValueError as e:
        log_error(f"Error adjusting values for image: {e}")
        return img, 0, 255     2: def adjust_values(img: np.ndarray) -> tuple[np.ndarray, int, int]:
    """Adjust the values of a grayscale image, excluding extreme pixels from certain adjustments."""
    try:
        # Create masks for minimum and maximum intensity pixels
        min_mask = img == 0
        max_mask = img == 255

        # Calculate modal white value in the range [250, 256)
        hist_white, bins_white = np.histogram(img[img >= 250], bins=6, range=(250, 256))
        modal_white = int(bins_white[np.argmax(hist_white)])

        # Calculate modal black value in the range [0, 61)
        hist_black, bins_black = np.histogram(img[img < 61], bins=61, range=(0, 61))
        modal_black = int(bins_black[np.argmax(hist_black)])

        # Convert image to float for processing
        adjusted = img.astype(np.float64)

        # Scale image if modal white is not at maximum intensity
        if modal_white != 255:
            # Apply scaling only to pixels not at maximum intensity
            non_max_mask = ~max_mask
            adjusted[non_max_mask] *= 255.0 / modal_white
            adjusted = np.clip(adjusted, 0, 255)

        # Exclude extreme pixels from black value adjustments
        if modal_black:
            # Create a mask for pixels to adjust (excluding min and max intensity pixels)
            adjust_mask = ~(min_mask | max_mask)

            # Adjust image based on modal black value
            adjusted[adjust_mask] -= modal_black
            adjusted[adjust_mask] *= 255.0 / (255 - modal_black)
            adjusted = np.clip(adjusted, 0, 255)

            # Apply gamma correction to adjusted pixels
            gamma = 1.0 - (modal_black / 255.0)
            adjusted[adjust_mask] = np.power(adjusted[adjust_mask] / 255.0, gamma) * 255

        # Convert back to unsigned 8-bit integer
        adjusted = adjusted.astype(np.uint8)

        return adjusted, modal_black, modal_white

    except ValueError as e:
        log_error(f"Error adjusting values for image: {e}")
        return img, 0, 255