コード例 #1
0
ファイル: 0623.py プロジェクト: ta-oyama/PCV
def compute_feature(im):
    """ OCRの画像パッチの特徴量ベクトルを返す"""
    
    # 縮小して、境界を削除する
    norm_im = imtools.imresize(im,(30,30))
    norm_im = norm_im[3:-3,3:-3]
    
    return norm_im.flatten()
コード例 #2
0
def compute_feature(im):
    """ Returns a feature vector for an
  ocr image patch. """
    # resize and remove border
    norm_im = imtools.imresize(im, (30, 30))
    norm_im = norm_im[3:-3, 3:-3]

    return norm_im.flatten()
コード例 #3
0
import harris
from imtools import imresize
"""
This is the Harris point matching example in Figure 2-2.
"""

# Figure 2-2上面的图
im1 = array(Image.open("../data/crans_1_small.jpg").convert("L"))
im2 = array(Image.open("../data/crans_2_small.jpg").convert("L"))

# Figure 2-2下面的图
# im1 = array(Image.open("../data/sf_view1.jpg").convert("L"))
# im2 = array(Image.open("../data/sf_view2.jpg").convert("L"))

# resize to make matching faster
im1 = imresize(im1, (im1.shape[1] // 2, im1.shape[0] // 2))
im2 = imresize(im2, (im2.shape[1] // 2, im2.shape[0] // 2))

wid = 5
harrisim1 = harris.compute_harris_response(im1, 5)
filtered_coords1 = harris.get_harris_points(harrisim1, wid + 1)
d1 = harris.get_descriptors(im1, filtered_coords1, wid)

harrisim2 = harris.compute_harris_response(im2, 5)
filtered_coords2 = harris.get_harris_points(harrisim2, wid + 1)
d2 = harris.get_descriptors(im2, filtered_coords2, wid)

print('starting matching')
matches = harris.match_twosided(d1, d2)

figure()
コード例 #4
0
ファイル: ocr.py プロジェクト: PhilomontPhlea/PhleaBytesCV
def compute_feature(im):
  """Returns a feature vector for an ocr image patch."""
  norm_im = imtools.imresize(im, (30, 30))
  norm_im = norm_im[3:-3, 3:-3]  # Strip border.
  return norm_im.flatten()
コード例 #5
0
from pylab import *
import imtools  #查看imtools.py
im = imread('empire.jpg')  #用imread读取的结果是一个array而不是Image对象
height, width, channel = im.shape  #得到图像的高、宽和通道数量
sz = (int(width / 2), int(height / 2))
im_resized = imtools.imresize(im, sz)
subplot(121)
imshow(im)
subplot(122)
axis([0, width, height, 0])  #设置坐标轴与im相同,y方向与常规的坐标轴相反
imshow(im_resized)
show()
コード例 #6
0
from pylab import *
from numpy import *
from PIL import Image

import harris
from imtools import imresize
"""
This is the Harris point matching example in Figure 2-2.
"""

im1 = array(Image.open("../data/crans_1_small.jpg").convert("L"))
im2 = array(Image.open("../data/crans_2_small.jpg").convert("L"))

# resize to make matching faster
im1 = imresize(im1, (int(im1.shape[1] / 2), int(im1.shape[0] / 2)))
im2 = imresize(im2, (int(im2.shape[1] / 2), int(im2.shape[0] / 2)))

wid = 5
harrisim = harris.compute_harris_response(im1, 5)
filtered_coords1 = harris.get_harris_points(harrisim, wid + 1)
d1 = harris.get_descriptors(im1, filtered_coords1, wid)

harrisim = harris.compute_harris_response(im2, 5)
filtered_coords2 = harris.get_harris_points(harrisim, wid + 1)
d2 = harris.get_descriptors(im2, filtered_coords2, wid)

print('starting matching')
matches = harris.match_twosided(d1, d2)

figure()
gray()
コード例 #7
0
def compute_feature(im):
    """Returns a feature vector for an ocr image patch."""
    norm_im = imtools.imresize(im, (30, 30))
    norm_im = norm_im[3:-3, 3:-3]  # Strip border.
    return norm_im.flatten()
コード例 #8
0
ファイル: 0421.py プロジェクト: ta-oyama/PCV
print int(im3.min()), int(im3.max())
print int(im4.min()), int(im4.max())

#plt.imshow(im4)

pil_im = Image.fromarray(np.uint8(im))
pil_im2 = Image.fromarray(np.uint8(im2))
pil_im3 = Image.fromarray(np.uint8(im3))
pil_im4 = Image.fromarray(np.uint8(im4))
#numpyのarray型からPILのImage型に変換する。


### 1.3.3 画像のサイズ変更 ###
 #imtppls.pyにプログラムを追加する
im = np.array(Image.open('empire.jpg'))
im2 = imtools.imresize(im,(30,40))
plt.figure(1)
plt.imshow(im)
plt.figure(2)
plt.imshow(im2)


### 1.3.4 ヒストグラム平坦化 ###
 #imtppls.pyにプログラムを追加する
im = np.array(Image.open('AquaTermi_lowcontrast.jpg').convert('L'))
im2,cdf = imtools.histeq(im)

#ヒストグラムを表示してみる

plt.figure(1)
plt.hist(im2.flatten(),128)
コード例 #9
0
__author__ = 'modoso'

from PIL import Image
import matplotlib.pyplot as plt
from pylab import array
import imtools

# read image into array
im = array(Image.open(imtools.imagePath('test.jpg')))

im2 = imtools.imresize(im, (640, 640))

#draw image
plt.imshow(im2)

#Set title
plt.title('Plotting: "test.jpg"')

#close axis
plt.axis('off')

#show image
plt.show()