本文整理汇总了Python中Img.create_gauss_kernel方法的典型用法代码示例。如果您正苦于以下问题:Python Img.create_gauss_kernel方法的具体用法?Python Img.create_gauss_kernel怎么用?Python Img.create_gauss_kernel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Img
的用法示例。
在下文中一共展示了Img.create_gauss_kernel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: f1
# 需要导入模块: import Img [as 别名]
# 或者: from Img import create_gauss_kernel [as 别名]
def f1():
""" Convolves image and kernel """
(imgarr,w,h) = pgm.pgmread('cameraman.pgm')
imgs = Img.Img(imgarr)
k1 = Img.create_gauss_kernel(Img.find_gauss_support(0.8))
k2 = Img.create_gauss_kernel(Img.find_gauss_support(1.2))
k3 = Img.create_gauss_kernel(Img.find_gauss_support(1.6))
imgt1 = imgs.conv(k1)
imgt2 = imgs.conv(k2)
imgt3 = imgs.conv(k3)
# print imgt1.col, imgt1.row
# print imgt2.col, imgt2.row
# print imgt3.col, imgt3.row
plt.figure(1)
plt.imshow(imgs.pix, cmap=cm.gray)
plt.title('Original image')
plt.figure(2)
plt.imshow(imgt1.pix, cmap=cm.gray)
plt.title('Img convolved with Gaussian kernel' + str(shape(k1)))
plt.figure(3)
plt.imshow(imgt2.pix, cmap=cm.gray)
plt.title('Img convolved with Gaussian kernel' + str(shape(k2)))
plt.figure(4)
plt.imshow(imgt3.pix, cmap=cm.gray)
plt.title('Img convolved with Gaussian kernel' + str(shape(k3)))
plt.show()
示例2: f1
# 需要导入模块: import Img [as 别名]
# 或者: from Img import create_gauss_kernel [as 别名]
def f1():
import pgm
#imgarray,w,h = pgm.pgmread('histo_inp_image.pgm')
#imgarray,w,h = pgm.pgmread('histo_ref_image.pgm')
#imgarray,w,h = pgm.pgmread('histo_inp_image2.pgm')
#imgarray,w,h = pgm.pgmread('histo_ref_image2.pgm')
imgarray,w,h = pgm.pgmread('lena.pgm')
#imgarray,w,h = pgm.pgmread('fourier_transform.pgm')
imgs = Img.Img(imgarray)
imgt = imgs.add_salt_pepper(0.65)
imgt1 = imgt.median_filter(np.ones((3,3)))
imgt1 = imgt1.median_filter(np.ones((5,5)))
#imgt1 = imgt.median_filter(np.ones((7,7)))
#imgt1 = imgt.median_filter(np.array([[2,2,2],[2,1,2],[2,2,2]]))
k = Img.create_gauss_kernel(Img.find_gauss_support(0.75), 0.75)
imgt2 = imgt.conv(k)
plot_fig(imgs.pix, 'Original image')
plot_fig(imgt.pix, 'Added salt and pepper noise')
plot_fig(imgt1.pix, 'Median filtered image')
plot_fig(imgt2.pix, 'Gaussian LP filtered image')
#plot_hist(imgs, 'Original image')
#plot_hist(imgt, 'Added salt and pepper noise')
#plot_hist(imgt1, 'Median filtered image')
#plot_hist(imgt2, 'Gaussian LP filtered image')
print np.sum((imgs.pix - imgt1.pix)**2)