Popravil 3b
parent
ab95afdea7
commit
1186b8c982
BIN
assignment2/.png
BIN
assignment2/.png
Binary file not shown.
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 129 KiB |
|
@ -186,11 +186,10 @@ def one_e(distances: list, selected_dists: list):
|
||||||
############################
|
############################
|
||||||
|
|
||||||
def ex2():
|
def ex2():
|
||||||
#two_b()
|
two_b()
|
||||||
#two_c()
|
two_d()
|
||||||
two_e()
|
two_e()
|
||||||
|
|
||||||
|
|
||||||
def two_b():
|
def two_b():
|
||||||
"""
|
"""
|
||||||
Implement the function simple_convolution that uses a 1-D signal I and a kernel
|
Implement the function simple_convolution that uses a 1-D signal I and a kernel
|
||||||
|
@ -289,7 +288,7 @@ def two_e():
|
||||||
# EXCERCISE 3: Image Filtering #
|
# EXCERCISE 3: Image Filtering #
|
||||||
################################
|
################################
|
||||||
def ex3():
|
def ex3():
|
||||||
#three_a()
|
three_a()
|
||||||
three_b()
|
three_b()
|
||||||
|
|
||||||
def three_a():
|
def three_a():
|
||||||
|
@ -341,18 +340,17 @@ def three_b():
|
||||||
Convolution can also be used for image sharpening. Look at its definition in the
|
Convolution can also be used for image sharpening. Look at its definition in the
|
||||||
lecture slides and implement it. Test it on the image from file museum.jpg.
|
lecture slides and implement it. Test it on the image from file museum.jpg.
|
||||||
"""
|
"""
|
||||||
museum_grayscale = cv2.imread('./data/images/museum.jpg', 0)
|
museum_grayscale = uz_image.imread_gray('./data/images/museum.jpg', uz_image.ImageType.uint8)
|
||||||
|
|
||||||
#https://blog.demofox.org/2022/02/26/image-sharpening-convolution-kernels/
|
#https://blog.demofox.org/2022/02/26/image-sharpening-convolution-kernels/ # Pa tui na slajdih lepo pise
|
||||||
# Pa tui na slajdih lepo pise
|
|
||||||
|
|
||||||
kernel = np.array([[-1, -1, -1],
|
kernel = np.array([[-1, -1, -1],
|
||||||
[-1, 17, -1],
|
[-1, 17, -1],
|
||||||
[-1, -1,-1]])
|
[-1, -1,-1]])
|
||||||
|
|
||||||
kernel = kernel * 1./9.
|
kernel = kernel * 1./9.
|
||||||
|
|
||||||
museo = cv2.filter2D(museum_grayscale, cv2.CV_64F, kernel)
|
museo = cv2.filter2D(museum_grayscale, -1, kernel)
|
||||||
museo = cv2.filter2D(museo, cv2.CV_64F, kernel.T)
|
|
||||||
|
|
||||||
fig, axs = plt.subplots(1, 2)
|
fig, axs = plt.subplots(1, 2)
|
||||||
axs[0].imshow(museum_grayscale, cmap='gray')
|
axs[0].imshow(museum_grayscale, cmap='gray')
|
||||||
|
@ -369,8 +367,8 @@ def three_b():
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
#ex1()
|
#ex1()
|
||||||
ex2()
|
#ex2()
|
||||||
# ex3()
|
ex3()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue