Created
October 1, 2018 09:56
-
-
Save rfzeg/dd0e72ae06f52eded9db2510d9718bf0 to your computer and use it in GitHub Desktop.
Normalize a grayscale image with Min-Max scaling to a range of [0.1, 0.9]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def normalize_grayscale(image_data): | |
""" | |
Normalize the image data with Min-Max scaling to a range of [0.1, 0.9] | |
:param image_data: The image data to be normalized | |
:return: Normalized image data | |
""" | |
# Implement Min-Max scaling for grayscale image data | |
a = 0.1 | |
b = 0.9 | |
grayscale_min = 0 | |
grayscale_max = 255 | |
return a + ( ( (image_data - grayscale_min)*(b - a) )/( grayscale_max - grayscale_min ) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment