Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential test case: normalise image to its intensity STD and AVG #157

Open
Romain-Laine opened this issue Nov 29, 2024 · 0 comments
Open

Comments

@Romain-Laine
Copy link

There are many ways to normalise an image to 0-1 range. One fun way is to use the image intensity STD and AVG to do that, here's a snippet.

def std_avg_normalisation(img: np.ndarray) -> np.ndarray:
    """
    Arguments:
    - img: input image to normalise
    Output:
    - np.array: the normalised version of the image, as np.float32
    """

    # Convert the data to float32
    img = img.astype(np.float32)

    img_mean = np.mean(img)
    img_std = np.std(img)
    return (img - img_mean)/(4*img_std) + 0.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant