Blame view

mfeat/__init__.py 966 Bytes
c7fa1d60   Chunk   refractoration st...
1
2
__author__ = 'chunk'

84648488   Chunk   reverted.
3
4
5
6
7
8
from ..common import *

import numpy as np
from PIL import Image
import cv2
from skimage.feature import hog
0d9a20ea   Chunk   staged.
9
from skimage import io, color, transform, exposure
c7fa1d60   Chunk   refractoration st...
10

84648488   Chunk   reverted.
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
__all__ = ['FeatureBase']

timer = ctimer()


def PILtest(image):
    img = Image.open(image).convert('RGB')
    print img
    img.save('res/tmp.jpg', format='JPEG')


def RGBtest():
    img = np.arange(256 * 256 * 3).reshape((256, 256, 3)) % 255
    # img.fill(122)
    img = img.astype(np.uint8)
    print type(img), img.dtype, img.shape
    print img

    img = np.array(img)
    img = Image.fromarray(img)
    img.save('res/tmp.jpg', format='JPEG')

    img2 = np.array([[[255, 0, 0]]], dtype=np.uint8)
    img2 = img2.repeat(128, axis=1).repeat(128, axis=0)
    print type(img2), img2.dtype, img2.shape
    print img2

    cv2.imshow('test img', img2)
c7fa1d60   Chunk   refractoration st...
39
40
41
42
    cv2.waitKey(0)


class FeatureBase(object):
1d19f0e7   Chunk   staged.
43
44
45
    def __init__(self):
        pass

84648488   Chunk   reverted.
46
    def feat(self, image):