Skip to content

Instantly share code, notes, and snippets.

@rfzeg
Created October 1, 2018 09:56
Show Gist options
  • Save rfzeg/dd0e72ae06f52eded9db2510d9718bf0 to your computer and use it in GitHub Desktop.
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]
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