def test4(): imlist = imtools.get_imlist(data_path) averageim = imtools.compute_average(imlist) figure() imshow(averageim) show()
from PIL import Image import numpy as np import imtools image: np.ndarray = np.array(Image.open('demo.png').convert('L')) image_after, cdf = imtools.histequal(image) image_after = Image.fromarray(np.uint8(image_after)) image_after.show() image_avg = imtools.compute_average(['demo.png', 'pil_image']) image_avg = Image.fromarray(image_avg) image_avg.show()
#reload(sift) reload(homography) reload(imtools) """前回のプログラム""" #3.2.3 xmlFileName = 'jkfaces2008_small/jkfaces.xml' points = imregistration.read_points_from_xml(xmlFileName) #位置合わせする imregistration.rigid_alignment(points,'jkfaces2008_small/') """ """ # 平均画像の比較 imlist = imtools.get_imlist('jkfaces2008_small/') avgim = imtools.compute_average(imlist) plt.subplot(1,2,1) plt.imshow(avgim) plt.axis('off') imlist = imtools.get_imlist('jkfaces2008_small/aligned/') avgim_aligned = imtools.compute_average(imlist) plt.subplot(1,2,2) plt.imshow(avgim_aligned) plt.axis('off') #マスクの作成 imlist = imtools.get_imlist('jkfaces2008_small/') im = np.array(Image.open(imlist[0])) m,n = im.shape[0:2] #im.shape[0:1]->(400L,)となり、カンマまでになってしまうので[0:2]までにした imnbr = len(imlist)
#!/usr/bin/python # -*- coding: utf-8 -*- from pylab import * import imtools for dir in ('jkfaces2008_small', 'jkfaces2008_small/aligned'): imlist = imtools.get_imlist(dir) avgimg = imtools.compute_average(sorted(imlist)[:150]) figure() imshow(avgimg) gray() axis('off') title(dir) show()
from PIL import Image from pylab import * import imtools avg = imtools.compute_average(['coffee.jpeg', 'board.jpeg', 'sea.jpeg']) imshow(avg) show()
# -*- coding: utf-8 -*- # from PCV.tools.imtools import get_imlist from PIL import Image from pylab import * # from PCV.tools import imtools import imtools from imtools import get_imlist # 添加中文字体支持 # from matplotlib.font_manager import FontProperties # font = FontProperties(fname=r"c:\windows\fonts\SimSun.ttc", size=14) from matplotlib.font_manager import FontProperties font = FontProperties(fname="/System/Library/Fonts/PingFang.ttc", size=14) filelist = get_imlist('../data/avg/') #获取convert_images_format_test文件夹下的图片文件名(包括后缀名) avg = imtools.compute_average(filelist) for impath in filelist: im1 = array(Image.open(impath)) subplot(2, 2, filelist.index(impath)+1) imshow(im1) imNum=str(filelist.index(impath)+1) title(u'待平均图像'+imNum, fontproperties=font) axis('off') subplot(2, 2, 4) imshow(avg) title(u'平均后的图像', fontproperties=font) axis('off') show()
#!/usr/bin/python # -*- coding: utf-8 -*- from pylab import * import imtools imlist = imtools.get_imlist('a_thumbs') avgimg = imtools.compute_average(imlist) imshow(avgimg) gray() axis('off') show()
#im1 = np.array(Image.open('/home/jcshin/Pictures/trumper.jpg')) im1 = np.array(Image.open('/home/jcshin/Pictures/trumper.jpg').convert('L')) im4 = np.array(Image.open('/home/jcshin/Pictures/car.jpg').convert('L')) im5 = np.array(Image.open('/home/jcshin/Pictures/castle.jpg').convert('L')) # Simple Image Processing #im2 = 255 - im1 # inversion #im2 = np.uint8((100.0/255)*im1 + 100) #im2 = 255.0*(im1/255.0)**2 # Histogram Equalization #im2, cdf = imtools.histeq(im1) # Image Averaging im2 = imtools.compute_average(['/home/jcshin/Pictures/trumper.jpg','/home/jcshin/Pictures/car.jpg']) # scipy.misc image resize #im2 = scipy.misc.imresize(im4,im1.shape,interp='bilinear') print im1.dtype, im1.shape, im1.min(), im1.max(), im1.mean() print im2.dtype, im2.shape, im2.min(), im2.max(), im2.mean() #cv2.imshow('im2',im2) plt.figure() plt.gray() plt.subplot(211); plt.imshow(im1); plt.axis('equal'); plt.axis('off') plt.subplot(212); plt.imshow(im2); plt.axis('equal'); plt.axis('off') plt.show()