本文整理匯總了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)