Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# function to reduce image resolution while keeping the image size constant
def pixalate_image(image, scale_percent = 40):
width = int(image.shape[1] * scale_percent / 100)
height = int(image.shape[0] * scale_percent / 100)
dim = (width, height)
small_image = cv2.resize(image, dim, interpolation = cv2.INTER_AREA)
# scale back to original size
width = int(small_image.shape[1] * 100 / scale_percent)
height = int(small_image.shape[0] * 100 / scale_percent)
dim = (width, height)
low_res_image = cv2.resize(small_image, dim, interpolation = cv2.INTER_AREA)
return low_res_image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment