46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
|
import numpy as np
|
||
|
import numpy.typing as npt
|
||
|
from matplotlib import pyplot as plt
|
||
|
import cv2
|
||
|
import uz_framework.image as uz_image
|
||
|
import uz_framework.text as uz_text
|
||
|
import os
|
||
|
|
||
|
##############################################
|
||
|
# EXCERCISE 1: Exercise 1: Image derivatives #
|
||
|
##############################################
|
||
|
|
||
|
def ex1():
|
||
|
one_a()
|
||
|
|
||
|
def one_a() -> None:
|
||
|
img = uz_image.imread_gray("data/graf/graf_a.jpg", uz_image.ImageType.float64)
|
||
|
# Get the hessian points
|
||
|
sigmas = [3, 6, 9, 12]
|
||
|
determinant, hessian_points = uz_image.hessian_points(img, 9, 0.004)
|
||
|
# Plot the points
|
||
|
fig, axs = plt.subplots(2, len(sigmas))
|
||
|
|
||
|
for i, sigma in enumerate(sigmas):
|
||
|
determinant, hessian_points = uz_image.hessian_points(img, sigma, 0.004)
|
||
|
# Plot determinant
|
||
|
axs[0, i].imshow(determinant)
|
||
|
axs[0, i].set_title(f"Sigma: {sigma}")
|
||
|
# Plot grayscale image
|
||
|
axs[1, i].imshow(img, cmap="gray")
|
||
|
# Plot scatter hessian points
|
||
|
axs[1, i].scatter(hessian_points[:, 1], hessian_points[:, 0], s=1, c="r", marker="x")
|
||
|
|
||
|
plt.show()
|
||
|
|
||
|
|
||
|
# ######## #
|
||
|
# SOLUTION #
|
||
|
# ######## #
|
||
|
|
||
|
def main():
|
||
|
ex1()
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|