#!/bin/env python3

import numpy as np
import matplotlib.pyplot as plt
from scipy.ndimage import imread

def rgb2gray(img):
	return np.dot(img, [0.299, 0.587, 0.114])



if __name__ == "__main__":
	img_name = "1920x1080.jpg"

	img = imread(img_name)

	gray_img = rgb2gray(img)
	plt.imshow(gray_img, cmap=plt.cm.gray)
	plt.show()

	resized = np.ndarray((64, 64))
	for (i,j),_ in np.ndenumerate(resized):
		f1, f2 = gray_img.shape[0] // 64, gray_img.shape[1] // 64
		slisse =  gray_img[i*f1:(i+1)*f1,j*f2:(j+1)*f2]
		resized[i,j] = np.max(slisse)

	plt.imshow(resized, cmap=plt.cm.gray)
	plt.show()
@@ -165,169 +165,39 @@
 %5D)%0A%0A
-%0A%0Aif __name__ == %22__main__%22:%0A%09img_name = %221920x1080.jpg%22%0A%0A%09img = imread(img_name)%0A%0A%09gray_img = rgb2gray(img)%0A%09plt.imshow(gray_img, cmap=plt.cm.gray)%0A%09plt.show()%0A
+def resize(img, shape=(64,64)):
 %0A%09re
@@ -219,16 +219,13 @@
 ray(
-(64, 64)
+shape
 )%0A%09f
@@ -271,12 +271,8 @@
 %09%09f1
-, f2
  = g
@@ -291,19 +291,31 @@
 e%5B0%5D // 
-64,
+shape%5B0%5D%0A%09%09f2 =
  gray_im
@@ -328,18 +328,25 @@
 e%5B1%5D // 
-64
+shape%5B1%5D%0A
 %0A%09%09sliss
@@ -421,16 +421,221 @@
 lisse)%0A%0A
+%09return resized%0A%0Aif __name__ == %22__main__%22:%0A%09img_name = %221920x1080.jpg%22%0A%0A%09img = imread(img_name)%0A%0A%09gray_img = rgb2gray(img)%0A%09plt.imshow(gray_img, cmap=plt.cm.gray)%0A%09plt.show()%0A%0A%09resized = resize(gray_img)%0A
 %09plt.ims

Refactor resizing.