<filename>src/Day 2/3_filter/sharpening/custom_2D_kernel.py
import cv2
import numpy as np

image = cv2.imread(r'C:\Users\harrizazham98\Desktop\OpenCVForPython\resources\Day 2\wood.jpg')

# Print error message if image is null
if image is None:
    print('Could not read image')

"""
Apply sharpening using kernel
"""
kernel3 = np.array([[0, -1, 0],
                    [-1, 5, -1],
                    [0, -1, 0]])
sharp_img = cv2.filter2D(src=image, ddepth=-1, kernel=kernel3)

cv2.imshow('Original', image)
cv2.imshow('Sharpened', sharp_img)

cv2.waitKey()
#cv2.imwrite('sharp_image.jpg', sharp_img)
cv2.destroyAllWindows()
<filename>src/Day 2/3_filter/sharpening/custom_2D_kernel.py
import cv2
import numpy as np

image = cv2.imread(r'C:\Users\harrizazham98\Desktop\OpenCVForPython\resources\Day 2\wood.jpg')

# Print error message if image is null
if image is None:
    print('Could not read image')

"""
Apply sharpening using kernel
"""
kernel3 = np.array([[0, -1, 0],
                    [-1, 5, -1],
                    [0, -1, 0]])
sharp_img = cv2.filter2D(src=image, ddepth=-1, kernel=kernel3)

cv2.imshow('Original', image)
cv2.imshow('Sharpened', sharp_img)

cv2.waitKey()
#cv2.imwrite('sharp_image.jpg', sharp_img)
cv2.destroyAllWindows()
# Print error message if image is null Apply sharpening using kernel #cv2.imwrite('sharp_image.jpg', sharp_img)