Exemple #1
0
    def test_findDistanceToMask(self):
        image_1 = self.images[0]
        image_2 = self.images[1]
        num_matches = 10
        kp1, kp2, matches = pano.findMatchesBetweenImages(
            image_1, image_2, num_matches)
        homography = pano.findHomography(kp1, kp2, matches)
        corners_1 = pano.getImageCorners(image_1)
        corners_2 = pano.getImageCorners(image_2)
        min_xy, max_xy = pano.getBoundingCorners(corners_1, corners_2,
                                                 homography)
        left_image = pano.warpCanvas(image_1, homography, min_xy, max_xy)
        right_image = np.zeros_like(left_image)
        min_xy = min_xy.astype(np.int)
        right_image[-min_xy[1]:-min_xy[1] + image_2.shape[0],
                    -min_xy[0]:-min_xy[0] + image_2.shape[1]] = image_2

        left_mask = pano.createImageMask(left_image)
        right_mask = pano.createImageMask(right_image)
        left_only_mask, overlap_mask, right_only_mask = pano.createRegionMasks(
            left_mask, right_mask)

        left_distance_mask = pano.findDistanceToMask(left_mask)
        left_only_distance_mask = pano.findDistanceToMask(left_only_mask)
        write_mask_image(left_only_distance_mask,
                         "left_only_distance_mask.png")
        overlap_distance_mask = pano.findDistanceToMask(overlap_mask)
        right_distance_mask = pano.findDistanceToMask(right_mask)
        right_only_distance_mask = pano.findDistanceToMask(right_only_mask)
        write_mask_image(right_only_distance_mask,
                         "right_only_distance_mask.png")
Exemple #2
0
 def test_getImageCorners(self):
     # getCorners_cv2 = []
     # cv2.getPerspectiveTransform(self.images[0], getCorners_cv2)
     # print(getCorners_cv2)
     print(self.images[0].shape)
     getCorners_my = pano.getImageCorners(self.images[0])
     print(getCorners_my)
Exemple #3
0
from os import path

#import assignment8 as a8
import panorama as a8

SRC_FOLDER = "images/source"
num_matches = 10

from matplotlib import pyplot as plt

image1 = plt.imread('images/source/sample/1.jpg')
image2 = plt.imread('images/source/sample/2.jpg')
image3 = plt.imread('images/source/sample/3.jpg')

corner_1 = a8.getImageCorners(image1)
corner_2 = a8.getImageCorners(image2)
corner_3 = a8.getImageCorners(image3)

image_1_kp, image_2_kp, matches = a8.findMatchesBetweenImages(
    image1, image2, num_matches)
#print image_1_kp

homography = a8.findHomography(image_1_kp, image_2_kp, matches)
print homography

min_xy, max_xy = a8.getBoundingCorners(corner_1, corner_2, homography)
print min_xy, max_xy

warped_image = a8.warpCanvas(image1, homography, min_xy, max_xy)
print warped_image