from PIL import Image import numpy as np import matplotlib.pyplot as plt from blur import convert # Gaussian kernel gaussian_kernel = [[1 / 256, 4 / 256, 6 / 256, 4 / 256, 1 / 256], [4 / 256, 16 / 256, 24 / 256, 16 / 256, 4 / 256], [6 / 256, 24 / 256, 36 / 256, 24 / 256, 6 / 256], [4 / 256, 16 / 256, 24 / 256, 16 / 256, 4 / 256], [1 / 256, 4 / 256, 6 / 256, 4 / 256, 1 / 256]] image = np.array(Image.open("roi.jpg")) gaussian_blur = Image.fromarray(np.uint8(convert(image, gaussian_kernel))) gaussian_blur.save("gaussian_output.png")
from PIL import Image import numpy as np import matplotlib.pyplot as plt from blur import convert #sharpening kernel sharpening_kernel = kernel = [[1 / 25, 1 / 25, 1 / 25, 1 / 25, 1 / 25], [1 / 25, 1 / 25, 1 / 25, 1 / 25, 1 / 25], [1 / 25, 1 / 25, -1, 1 / 25, 1 / 25], [1 / 25, 1 / 25, 1 / 25, 1 / 25, 1 / 25], [1 / 25, 1 / 25, 1 / 25, 1 / 25, 1 / 25]] image1 = np.array(Image.open("sharpen_input.png")) sharpened = Image.fromarray(np.uint8(convert(image1, sharpening_kernel))) sharpened.save("sharpened_image.png")
from PIL import Image import numpy as np import matplotlib.pyplot as plt from blur import convert # Box Blur kernel box_kernel = [[1 / 25, 1 / 25, 1 / 25, 1 / 25, 1 / 25], [1 / 25, 1 / 25, 1 / 25, 1 / 25, 1 / 25], [1 / 25, 1 / 25, 1 / 25, 1 / 25, 1 / 25], [1 / 25, 1 / 25, 1 / 25, 1 / 25, 1 / 25], [1 / 25, 1 / 25, 1 / 25, 1 / 25, 1 / 25]] image = np.array(Image.open("blur.jpeg")) box_blur = Image.fromarray(np.uint8(convert(image, box_kernel))) box_blur.save("box_blur.png")
from PIL import Image import numpy as np import matplotlib.pyplot as plt from blur import convert # Weighted Average Filter w_average_kernel = [[1/40, 1/40, 1/40, 1/40, 1/40], [1/40, 1/40, 1/40, 1/40, 1/40], [1/40, 1/40,16/40, 1/40, 1/40], [1/40, 1/40, 1/40, 1/40, 1/40], [1/40, 1/40, 1/40, 1/40, 1/40]] image = np.array(Image.open("blur.jpeg")) w_average_blur = Image.fromarray(np.uint8(convert(image, w_average_kernel))) w_average_blur.save("weighted_average_blur.png")