'Sharpen image with scipy convolve2d - odd results
I am trying to use the convolve2d function from scipy for sharpening a RGB image. The code is shown below. For convolution, I am using the sharpen kernel from wikipedia:https://en.wikipedia.org/wiki/Kernel_(image_processing)
The output looks odd. I'm not sure what is incorrect here. I have experimented with changing data types of the array, it has given me some odd images. '''
import numpy as np
from PIL import Image
image = Image.open("1.jpg")
img_array = np.array(image)
def RGB_convolve(image,kern):
image2 = np.empty_like(image)
for dim in range(image.shape[-1]):
image2[:,:,dim]=convolve2d(image[:,:,dim],kern, 'same')
return image2
KERNEL_sharpen = np.array([[0,-1,0],[-1,5,-1],[0,-1,0]])
im_filtered = RGB_convolve(img_array,KERNEL_sharpen)
output_image = Image.fromarray(im_filtered)
display(output_image)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
