add folder img

This commit is contained in:
xixu-me committed 2024-05-04 18:46:15 +08:00
1 parent c59622aec4
commit b02cd70ac3
147 files changed
+31 -36

No files matched your search

+5 -5
View File
@@ -20,7 +20,7 @@ def histogram_equalization(im):
if __name__ == "__main__":
im = cv.imread(r"src.jpg", cv.IMREAD_GRAYSCALE)
im = cv.imread(r"img\iris.jpg", cv.IMREAD_GRAYSCALE)
im1 = global_linear_transmation(im, 0, 150)
im2 = global_linear_transmation(im, 100)
im3 = global_linear_transmation(im, 50, 150)
@@ -39,11 +39,11 @@ if __name__ == "__main__":
plt.imshow(im4, cmap="gray")
plt.title("equalized")
plt.subplot(245)
plt.hist(im1.flatten(), 256, [0, 256])
plt.hist(im1.flatten(), 256, [0, 256]) # type: ignore
plt.subplot(246)
plt.hist(im2.flatten(), 256, [0, 256])
plt.hist(im2.flatten(), 256, [0, 256]) # type: ignore
plt.subplot(247)
plt.hist(im3.flatten(), 256, [0, 256])
plt.hist(im3.flatten(), 256, [0, 256]) # type: ignore
plt.subplot(248)
plt.hist(im4.flatten(), 256, [0, 256])
plt.hist(im4.flatten(), 256, [0, 256]) # type: ignore
plt.show()
+1 -1
View File
@@ -10,7 +10,7 @@ def gamma_trans(img, gamma=1.0):
if __name__ == "__main__":
im = cv.imread(r"src.jpg", cv.IMREAD_GRAYSCALE)
im = cv.imread(r"img\iris.jpg", cv.IMREAD_GRAYSCALE)
im1 = gamma_trans(im, 0.5)
im2 = gamma_trans(im, 1.5)
plt.figure()
+2 -3
View File
@@ -1,9 +1,9 @@
import cv2 as cv
from matplotlib import pyplot as plt
import matplotlib.pyplot as plt
import numpy as np
if __name__ == "__main__":
img = cv.imread(r"src.jpg", 0)
img = cv.imread(r"img\iris.jpg", 0)
fil1 = 1 / 16 * np.array([[1, 2, 1], [2, 4, 2], [1, 2, 1]])
fil2 = 1 / 9 * np.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]])
fil3 = 1 / 10 * np.array([[1, 1, 1], [1, 2, 1], [1, 1, 1]])
@@ -12,7 +12,6 @@ if __name__ == "__main__":
ImgSmoothed2 = cv.filter2D(img, -1, fil2, borderType=cv.BORDER_DEFAULT)
ImgSmoothed3 = cv.filter2D(img, -1, fil3, borderType=cv.BORDER_DEFAULT)
ImgSharp = cv.filter2D(img, -1, fil4, borderType=cv.BORDER_DEFAULT)
plt.figure()
plt.subplot(221)
plt.imshow(ImgSmoothed1, cmap="gray")
+4 -4
View File
@@ -33,15 +33,15 @@ def addGaussianNoise(src, means, sigma):
if __name__ == "__main__":
im = cv.imread(r"src.jpg", cv.IMREAD_GRAYSCALE)
im = cv.imread(r"img\iris.jpg", cv.IMREAD_GRAYSCALE)
im1 = addSaltAndPepper(im, 0.1)
im11 = cv.blur(im1, (3, 3))
im12 = cv.medianBlur(im1, 3)
im13 = cv.GaussianBlur(im1, (3, 3), 1)
im2 = addGaussianNoise(im, 0, 0.1)
im21 = cv.blur(im2, (3, 3))
im22 = cv.medianBlur(im2, 3)
im23 = cv.GaussianBlur(im2, (3, 3), 1)
im21 = cv.blur(im2, (3, 3)) # type: ignore
im22 = cv.medianBlur(im2, 3) # type: ignore
im23 = cv.GaussianBlur(im2, (3, 3), 1) # type: ignore
plt.figure()
plt.subplot(241)
plt.imshow(im1, cmap="gray")
+1 -2
View File
@@ -3,12 +3,11 @@ from matplotlib import pyplot as plt
import numpy as np
if __name__ == "__main__":
img = cv.imread(r"src.jpg", 0)
img = cv.imread(r"img\iris.jpg", 0)
lplc = np.array([[0, -1, 0], [-1, 4, -1], [0, -1, 0]])
lplcEnhance = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]])
ImgLplc = cv.filter2D(img, -1, lplc, borderType=cv.BORDER_DEFAULT)
ImgLplcEnhance = cv.filter2D(img, -1, lplcEnhance, borderType=cv.BORDER_DEFAULT)
plt.figure()
plt.subplot(131)
plt.imshow(img, cmap="gray")