Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import cv2
- import math
- from matplotlib import pyplot as plt
- def resize(input, percentage):
- original_width, original_height, channels = input.shape
- print("Original dimensions: [%d ; %d ; %d]" % (original_width, original_height, channels))
- new_width = int(math.ceil(original_width * (percentage/100)))
- new_height = int(math.ceil(original_height * (percentage / 100)))
- print("New dimensions: [%d ; %d ; %d]" % (new_width, new_height, channels))
- output = np.zeros((new_width,new_height,channels))
- print("New matrix created, type: %s" % (type(output)))
- for i in range(new_width):
- for j in range(new_height):
- output[i, j, 0] = input[math.floor(i / (percentage / 100)), math.floor(j / (percentage / 100)), 0]
- output[i, j, 1] = input[math.floor(i / (percentage / 100)), math.floor(j / (percentage / 100)), 1]
- output[i, j, 2] = input[math.floor(i / (percentage / 100)), math.floor(j / (percentage / 100)), 2]
- return output
- ajtaci = cv2.imread('itcrowd.bmp', 1)
- invader = cv2.imread('invader.bmp', 1)
- cv2.imshow("test", resize(ajtaci, 50))
- cv2.imshow("Ajtaci", ajtaci)
- cv2.waitKey(0)
- cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement