Exemplo n.º 1
0
def main():
    two_path = 'pgm/two_objects.pgm'
    many_path = 'pgm/many_objects_1.pgm'
    # many_path = 'pgm/many_objects_2.pgm'

    # Load the image in grayscale
    gray_in = cv2.imread(two_path, 0)
    many_in = cv2.imread(many_path, 0)
 
    # Convert a gray-level image to a binary one
    binary_in = p1(gray_in, 120) 
    many_in = p1(many_in, 120)

    # Segment the binary image into several connected regions
    two_labels = p2(binary_in)
    many_labels = p2(many_in)

    # Display the colored the image
    # plt.imshow(two_labels)
    # plt.show()

    # Computes object attributes, and generate the objects database
    [database_two, overlays] = p3(two_labels)

    # Recognize objects from the database
    overlays_out = p4(many_labels, database_two)

    # Display the results
    plt.axis("off")
    plt.imshow(overlays_out)
    plt.show()
Exemplo n.º 2
0
from p4 import *

tests = ( 
    (2, 2, 9009),
    (3, 2, 906609),
)
for a, b, r in tests:
    assert r == p4(a, b), (a, b, r)

for i in xrange(4, 10):
    p4(i)