Ejemplo n.º 1
0
    return time.strftime(ID_FORMAT, time.gmtime(d["timestamp"]))
ims = OrderedDict((metadata_to_id(d),
                   cv2.imread(d["image_path"], cv2.IMREAD_GRAYSCALE))
                      for d in sorted(metadata, key=lambda d: d['timestamp']))
times = OrderedDict((metadata_to_id(d), d["timestamp"]) for d in metadata)

print "Filtering images which are too bright"
filtered_ims = OrderedDict((im_id, im) for im_id, im in ims.items()
                                if numpy.mean(im) <= args.max_brightness)

print "Extracting stars from {} / {} images".format(len(filtered_ims),
                                                    len(ims))
im_stars = OrderedDict()
for im_id, im in filtered_ims.items():
    try:
        im_stars[im_id] = list(stars.extract(im))
    except stars.ExtractFailed as e:
        print "Failed to extract stars for {}: {}".format(im_id, e)

print "Registering {} / {} images".format(len(im_stars), len(ims))
transforms = OrderedDict()
for im_id, reg_result in zip(im_stars.keys(),
                             reg.register_many(im_stars.values())):
    try:
        M = reg_result.result()
    except reg.RegistrationFailed as e:
        print "Failed to register {}: {}".format(im_id, e)
    else:
        transforms[im_id] = M

print "Stacking {} / {} images".format(len(transforms), len(ims))
Ejemplo n.º 2
0
ims = OrderedDict(
    (metadata_to_id(d), cv2.imread(d["image_path"], cv2.IMREAD_GRAYSCALE))
    for d in sorted(metadata, key=lambda d: d['timestamp']))
times = OrderedDict((metadata_to_id(d), d["timestamp"]) for d in metadata)

print "Filtering images which are too bright"
filtered_ims = OrderedDict((im_id, im) for im_id, im in ims.items()
                           if numpy.mean(im) <= args.max_brightness)

print "Extracting stars from {} / {} images".format(len(filtered_ims),
                                                    len(ims))
im_stars = OrderedDict()
for im_id, im in filtered_ims.items():
    try:
        im_stars[im_id] = list(stars.extract(im))
    except stars.ExtractFailed as e:
        print "Failed to extract stars for {}: {}".format(im_id, e)

print "Registering {} / {} images".format(len(im_stars), len(ims))
transforms = OrderedDict()
for im_id, reg_result in zip(im_stars.keys(),
                             reg.register_many(im_stars.values())):
    try:
        M = reg_result.result()
    except reg.RegistrationFailed as e:
        print "Failed to register {}: {}".format(im_id, e)
    else:
        transforms[im_id] = M

print "Stacking {} / {} images".format(len(transforms), len(ims))
Ejemplo n.º 3
0
                     lineType=cv2.CV_AA)
        
        output_image("step{}.png".format(step_num), im1_copy, im2_copy)
        step_num += 1

if __name__ == "__main__":
    import sys

    import cv2

    import stars

    if sys.argv[1] == "register_pair":
        im1 = cv2.imread(sys.argv[2], cv2.IMREAD_GRAYSCALE)
        im2 = cv2.imread(sys.argv[3], cv2.IMREAD_GRAYSCALE)
        stars1 = stars.extract(im1)
        stars2 = stars.extract(im2)

        A = register_pair(stars1, stars2)

        print A
    if sys.argv[1] == "draw_correspondences":
        im1 = cv2.imread(sys.argv[2], cv2.IMREAD_GRAYSCALE)
        im2 = cv2.imread(sys.argv[3], cv2.IMREAD_GRAYSCALE)
        stars1 = list(stars.extract(im1))
        stars2 = list(stars.extract(im2))

        correspondences = _find_correspondences(stars1, stars2)
        _draw_correspondences(correspondences, im1, im2, stars1, stars2)
        
    if sys.argv[1] == "register_many":