Skip to content
Snippets Groups Projects
Verified Commit eade7d6a authored by iliya.saroukha's avatar iliya.saroukha :first_quarter_moon:
Browse files

feat: sharpening (done in guess) lab4

parent 055b1dd9
No related branches found
No related tags found
No related merge requests found
......@@ -93,7 +93,19 @@ def laplace(img: Img, isotropy: Isotropy) -> Img:
case _:
print("Invalid isotropy value")
return xcorr(img, kernel)
laplacian = xcorr(img, kernel)
# return thresholding(laplacian, 180)
return laplacian
def sharpen(img: Img, isotropy: Isotropy) -> Img:
new_image = img.copy()
laplacian = laplace(img, isotropy)
new_image += laplacian
return new_image
if __name__ == "__main__":
......@@ -103,13 +115,19 @@ if __name__ == "__main__":
laplacian = laplace(gray, Isotropy.ISO_45)
thresholded = thresholding(laplacian, 50)
fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(10, 10))
sharp_iso_90 = sharpen(gray, Isotropy.ISO_90)
sharp_iso_45 = sharpen(gray, Isotropy.ISO_45)
fig, axs = plt.subplots(nrows=1, ncols=3, figsize=(12, 6))
axs[0].imshow(gray, cmap="gray", vmin=0, vmax=255)
axs[0].set_title('Original image')
axs[0].imshow(laplacian, cmap="gray", vmin=0, vmax=255)
axs[0].set_title('Laplacian filter')
axs[1].imshow(sharp_iso_90, cmap="gray", vmin=0, vmax=255)
axs[1].set_title('Sharpened (Laplacian filter, isotropy 90)')
axs[1].imshow(thresholded, cmap="gray", vmin=0, vmax=255)
axs[1].set_title('Thresholded laplacian')
axs[2].imshow(sharp_iso_45, cmap="gray", vmin=0, vmax=255)
axs[2].set_title('Sharpened (Laplacian filter, isotropy 45)')
plt.tight_layout()
plt.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment