Ejemplo n.º 1
0
def test_rotation():
    target = np.array(Image.open('im.jpg'))
    result = target.copy()
    for _ in range(4):
        result = img.rotate(result)

    assert np.array_equal(target, result) is True
Ejemplo n.º 2
0
def test():
    target = np.array([
        [1, 2, 3],
        [4, 5, 6],
        [7, 8, 9],
    ])
    rotate = np.array([
        [7, 4, 1],
        [8, 5, 2],
        [9, 6, 3],
    ])
    mirror = np.array([
        [3, 2, 1],
        [6, 5, 4],
        [9, 8, 7],
    ])
    inverse = np.array([
        [254, 253, 252],
        [251, 250, 249],
        [248, 247, 246],
    ])
    lighten = np.array([
        [1, 3, 4],
        [6, 7, 9],
        [10, 12, 13],
    ])
    darken = np.array([
        [0, 1, 1],
        [2, 2, 3],
        [3, 4, 4],
    ])
    sharp = np.array([
        [0, 1, 7],
        [7, 5, 13],
        [23, 19, 31],
    ])
    assert np.array_equal(rotate, img.rotate(target)) is True
    assert np.array_equal(mirror, img.mirror(target)) is True
    assert np.array_equal(inverse, img.negative(target)) is True
    assert np.array_equal(lighten, img.lighten(target, 50)) is True
    assert np.array_equal(darken, img.darken(target, 50)) is True
    assert np.array_equal(sharp, img.sharpening(target)) is True
Ejemplo n.º 3
0
def main():
    im = Image.open('1.jpg')
    im = im.convert('1')  # convert image to black and white
    print 'Centroid ', find_centroid(im)
    print 'Top Left ', find_vertex1(im)
    print 'Bottom Left ', find_vertex2(im)
    print 'Top Right', find_vertex3(im)
    print 'Bottom Right ', find_vertex4(im)
    C = find_centroid(im)
    V1 = find_vertex1(im)
    V2 = find_vertex3(im)
    V3 = find_vertex2(im)
    V4 = find_vertex4(im)
    vertices = [V1, V2, V3, V4]
    direction = find_direction(vertices, C)
    print 'angle: ', find_angle(V1, V2, direction)
    s = find_angle(V1, V2, direction)
    from SimpleCV import *
    img = Image('1.jpg')
    rot = img.rotate(s[0])
    rot.save('teste.jpg')
Ejemplo n.º 4
0
def main():
    im = Image.open('1.jpg')
    im = im.convert('1') # convert image to black and white
    print 'Centroid ', find_centroid(im)
    print 'Top Left ', find_vertex1 (im)
    print 'Bottom Left ', find_vertex2 (im)
    print 'Top Right', find_vertex3 (im)
    print 'Bottom Right ', find_vertex4 (im)
    C = find_centroid (im)
    V1 = find_vertex1 (im)
    V2 = find_vertex3 (im)
    V3 = find_vertex2 (im)
    V4 = find_vertex4 (im)
    vertices = [V1,V2,V3,V4]
    direction = find_direction(vertices, C)
    print 'angle: ', find_angle(V1,V2,direction)
    s = find_angle(V1, V2, direction)
    from SimpleCV import *
    img = Image('1.jpg')
    rot = img.rotate(s[0])
    rot.save('teste.jpg')