“Grepper Python” Respostas de código

Grepper Python

import cv2
filename = 'lena.png'
image = cv2.imread(filename, cv2.IMREAD_GRAYSCALE)
plt.imshow(image, cmap='gray')
M Baseer

Grepper Python

import cv2
filename = 'lena.png'
image = cv2.imread(filename, cv2.IMREAD_GRAYSCALE)
plt.imshow(image, cmap='gray')
M Baseer

Grepper Python

width = 23
sigma = 3

# Create your Laplacian kernel
Laplacian_kernel = np.array([[1, 1, 1], [1, -8, 1], [1, 1, 1]])

# Create your Gaussian kernel
Gaussian_kernel = genGaussianKernel(width, sigma)

# Create your Laplacian of Gaussian
LoG = cv2.filter2D(Gaussian_kernel, -1, Laplacian_kernel)

# Plot Gaussian and Laplacian
fig = plt.figure(figsize=(18, 6))
plt.subplot(1, 3, 1)
plt.imshow(Gaussian_kernel, interpolation='none', cmap=cm.jet)
plt.title('Gaussian kernel')
plt.axis("off")

plt.subplot(1, 3, 2)
plt.imshow(LoG, interpolation='none', cmap=cm.jet)
plt.title('2D Laplacian of Gaussian')
plt.axis("off")

# Plot the 3D figure of LoG
# Fill in your code here
fig_3d = plt.figure()
ax = fig_3d.gca(projection='3d')
ax.view_init(30, 60)
X = [i for i in range(-len(LoG) // 2, len(LoG) // 2)]
Y = [i for i in range(-len(LoG[0]) // 2, len(LoG[0]) // 2)]
X, Y = np.meshgrid(X, Y)
surf = ax.plot_surface(X, Y, LoG, cmap=cm.jet)
plt.title('3D Laplacian of Gaussian')

img_noise_LOG = cv2.filter2D(img_noise, -1, LoG)
res_img_noise_kernel1d_x_LOG =  cv2.filter2D(res_img_noise_kernel1d_x, -1, LoG)
res_img_noise_kernel1d_xy_LOG = cv2.filter2D(res_img_noise_kernel1d_xy, -1, LoG)
res_img_noise_kernel2d_LOG = cv2.filter2D(res_img_noise_kernel2d, -1, LoG)


# Plot results
plt.figure(figsize=(18, 6))
plt.subplot(1, 4, 1)
plt.imshow(img_noise_LOG, 'gray')
plt.title('Image from Q2.1 convolved with LOG')
plt.axis("off")

plt.subplot(1, 4, 2)
plt.imshow(res_img_noise_kernel1d_x_LOG, 'gray')
plt.title('Image from Q2.2 convolved with LOG')
plt.axis("off")

plt.subplot(1, 4, 3)
plt.imshow(res_img_noise_kernel1d_xy_LOG, 'gray')
plt.title('Image from Q2.3 convolved with LOG')
plt.axis("off")

plt.subplot(1, 4, 4)
plt.imshow(res_img_noise_kernel2d_LOG, 'gray')
plt.title('Image from Q2.4 convolved with LOG')
plt.axis("off")

plt.show()
M Baseer

Respostas semelhantes a “Grepper Python”

Perguntas semelhantes a “Grepper Python”

Mais respostas relacionadas para “Grepper Python” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código