2022-10-15 17:07:41 +02:00
|
|
|
import UZ_utils as uz
|
|
|
|
import numpy as np
|
2022-10-15 18:20:50 +02:00
|
|
|
import numpy.typing as npt
|
2022-10-15 17:07:41 +02:00
|
|
|
|
2022-10-15 17:12:38 +02:00
|
|
|
#######################################
|
|
|
|
# EXCERCISE 1: Basic image processing #
|
|
|
|
#######################################
|
|
|
|
|
|
|
|
def excercise_one() -> None:
|
|
|
|
image = one_a()
|
|
|
|
one_b(image)
|
|
|
|
|
2022-10-15 17:07:41 +02:00
|
|
|
# Display image
|
2022-10-15 18:20:50 +02:00
|
|
|
def one_a() -> npt.NDArray[np.float64]:
|
2022-10-15 17:07:41 +02:00
|
|
|
image = uz.imread('./images/bird.jpg')
|
2022-10-15 17:12:38 +02:00
|
|
|
uz.imshow(image, 'Birdie')
|
2022-10-15 18:20:50 +02:00
|
|
|
return image
|
2022-10-15 17:07:41 +02:00
|
|
|
|
|
|
|
# Convert loaded image into grayscale
|
2022-10-15 18:20:50 +02:00
|
|
|
def one_b(image: npt.NDArray[np.float64]) -> None:
|
|
|
|
grayscale_image = np.zeros(image.shape[:2])
|
2022-10-15 17:07:41 +02:00
|
|
|
|
2022-10-15 18:20:50 +02:00
|
|
|
for i in range(image.shape[0]):
|
|
|
|
for j in range(image.shape[1]):
|
|
|
|
grayscale_image[i, j] = (image[i, j, 0] + image[i,j, 1] + image[i, j, 2]) / 3
|
|
|
|
|
|
|
|
uz.imshow(grayscale_image, 'Birdie grayscale')
|
2022-10-15 17:07:41 +02:00
|
|
|
|
2022-10-15 18:20:50 +02:00
|
|
|
def one_c():
|
|
|
|
#todo
|
|
|
|
assert(1 == 1)
|
|
|
|
|
2022-10-15 17:12:38 +02:00
|
|
|
def main() -> None:
|
|
|
|
excercise_one()
|
2022-10-15 17:07:41 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|