Created
February 27, 2020 09:05
-
-
Save prateekjoshi565/5a7b905cd898375773bbc6dd96cc8916 to your computer and use it in GitHub Desktop.
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
# 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