def main(): img = Img.load_image('../gletscher.jpg') # 45 Grad rotation_matrix = Img.get_2d_rotation_matrix(np.radians(45)) translation_vector = np.array([50, 600]) RestructuringMethod.affine_transform(img, rotation_matrix, translation_vector)
def b1(): img = Img.load_image(image_path) scale_matrix = Img.get_2d_rotation_matrix(np.radians(30)) translation_vector = np.array([0, 1]) img_bilinear = RestructuringMethod.affine_transform(img, scale_matrix, translation_vector, RestructuringMethod.BilinearInterpolation) img_nearest = RestructuringMethod.affine_transform(img, scale_matrix, translation_vector, RestructuringMethod.NearestNeighbor) imsave("../images/gletscher_b1_bilinear.jpg", img_bilinear) imsave("../images/gletscher_b1_nearest.jpg", img_nearest)
def b1(): img = Img.load_image(image_path) scale_matrix = Img.get_2d_rotation_matrix(np.radians(30)) translation_vector = np.array([0, 1]) img_bilinear = RestructuringMethod.affine_transform( img, scale_matrix, translation_vector, RestructuringMethod.BilinearInterpolation) img_nearest = RestructuringMethod.affine_transform( img, scale_matrix, translation_vector, RestructuringMethod.NearestNeighbor) imsave("../images/gletscher_b1_bilinear.jpg", img_bilinear) imsave("../images/gletscher_b1_nearest.jpg", img_nearest)
def b3(): img = Img.load_image(image_path) scale_matrix = Img.get_2d_scale_matrix(0.7).dot(Img.get_2d_x_y_scale_matrix(0.8, 1.2)) transform_matrix = Img.get_2d_rotation_matrix(np.radians(30)).dot(scale_matrix) #scale_matrix = get_2d_x_scale_matrix() translation_vector = np.array([0, 0]) img_bilinear = RestructuringMethod.affine_transform(img, transform_matrix, translation_vector, RestructuringMethod.BilinearInterpolation) img_nearest = RestructuringMethod.affine_transform(img, transform_matrix, translation_vector, RestructuringMethod.NearestNeighbor) imsave("../images/gletscher_b3_bilinear.jpg", img_bilinear) imsave("../images/gletscher_b3_nearest.jpg", img_nearest)
def b1(): image = Img.load_image(image_path) target_image_size_height = 900 target_image_size_witdh = 600 new_x_size = target_image_size_witdh * 3 new_y_size = target_image_size_height * 3 new_image = np.zeros((new_x_size, new_y_size, 3)) # links oben pass_point_1_x = 344.0 pass_point_1_y = 334.0 target_point_1_x = 0.0 target_point_1_y = 0.0 # links unten pass_point_2_x = 300.0 pass_point_2_y = 456.0 target_point_2_x = 0.0 target_point_2_y = target_image_size_height pass_point_3_x = 694.0 pass_point_3_y = 432.0 #rechts unten #pass_point_3_x = 690.0 #pass_point_3_y = 460.0 target_point_3_x = target_image_size_witdh target_point_3_y = target_image_size_height #recht oben pass_point_4_x = 548.0 pass_point_4_y = 330.0 target_point_4_x = target_image_size_witdh target_point_4_y = 0.0 translation_factor = 0 points = [ DistortionCorrectionPoint(344.0, 344.0, 0.0 + translation_factor, 0.0 + translation_factor), # links oben DistortionCorrectionPoint( 300.0, 456.0, 0.0 + translation_factor, target_image_size_height + translation_factor), # links unten DistortionCorrectionPoint( 694.0, 432.0, target_image_size_witdh + translation_factor, target_image_size_height + translation_factor), DistortionCorrectionPoint(548.0, 330.0, target_image_size_witdh + translation_factor, 0.0 + translation_factor) ] # rechts unten new_image = DistortionCorrection.distortion_correction( points, image, new_image) imsave("../images/test.jpg", new_image)
def b5(): img = Img.load_image('../ambassadors.jpg') scale = 0.5 scale_matrix = Img.get_2d_x_y_scale_matrix(9.0, 1.5) transform_matrix = Img.get_2d_rotation_matrix(np.radians(30)).dot(scale_matrix) transform_matrix = scale*transform_matrix*Img.get_scale_diagonal_matrix(0.4)*Img.get_scale_orthogonal_matrix(0.9) translation_vector = np.array([-2000, 0]) img_bilinear = RestructuringMethod.affine_transform(img, transform_matrix, translation_vector, RestructuringMethod.BilinearInterpolation) img_nearest = RestructuringMethod.affine_transform(img, transform_matrix, translation_vector, RestructuringMethod.NearestNeighbor) imsave("../images/ambassadors_b5_bilinear.jpg", img_bilinear) imsave("../images/ambassadors_b5_nearest.jpg", img_nearest)
def b3(): img = Img.load_image(image_path) scale_matrix = Img.get_2d_scale_matrix(0.7).dot( Img.get_2d_x_y_scale_matrix(0.8, 1.2)) transform_matrix = Img.get_2d_rotation_matrix( np.radians(30)).dot(scale_matrix) #scale_matrix = get_2d_x_scale_matrix() translation_vector = np.array([0, 0]) img_bilinear = RestructuringMethod.affine_transform( img, transform_matrix, translation_vector, RestructuringMethod.BilinearInterpolation) img_nearest = RestructuringMethod.affine_transform( img, transform_matrix, translation_vector, RestructuringMethod.NearestNeighbor) imsave("../images/gletscher_b3_bilinear.jpg", img_bilinear) imsave("../images/gletscher_b3_nearest.jpg", img_nearest)
def b4(): img = Img.load_image(image_path) scale = 0.7 #scale_matrix = Img.get_2d_x_y_scale_matrix(0.8, 1.2) scale_matrix = Img.get_2d_x_y_scale_matrix(0.8, 1.2) transform_matrix = Img.get_2d_rotation_matrix(np.radians(30)).dot(scale_matrix) transform_matrix = scale*transform_matrix * Img.get_scale_diagonal_matrix(1.5) * Img.get_scale_orthogonal_matrix(0.5) translation_vector = np.array([0, 0]) img_bilinear = RestructuringMethod.affine_transform(img, transform_matrix, translation_vector, RestructuringMethod.BilinearInterpolation) img_nearest = RestructuringMethod.affine_transform(img, transform_matrix, translation_vector, RestructuringMethod.NearestNeighbor) imsave("../images/gletscher_b4_bilinear.jpg", img_bilinear) imsave("../images/gletscher_b4_nearest.jpg", img_nearest)
def b5(): img = Img.load_image('../ambassadors.jpg') scale = 0.5 scale_matrix = Img.get_2d_x_y_scale_matrix(9.0, 1.5) transform_matrix = Img.get_2d_rotation_matrix( np.radians(30)).dot(scale_matrix) transform_matrix = scale * transform_matrix * Img.get_scale_diagonal_matrix( 0.4) * Img.get_scale_orthogonal_matrix(0.9) translation_vector = np.array([-2000, 0]) img_bilinear = RestructuringMethod.affine_transform( img, transform_matrix, translation_vector, RestructuringMethod.BilinearInterpolation) img_nearest = RestructuringMethod.affine_transform( img, transform_matrix, translation_vector, RestructuringMethod.NearestNeighbor) imsave("../images/ambassadors_b5_bilinear.jpg", img_bilinear) imsave("../images/ambassadors_b5_nearest.jpg", img_nearest)
def b4(): img = Img.load_image(image_path) scale = 0.7 #scale_matrix = Img.get_2d_x_y_scale_matrix(0.8, 1.2) scale_matrix = Img.get_2d_x_y_scale_matrix(0.8, 1.2) transform_matrix = Img.get_2d_rotation_matrix( np.radians(30)).dot(scale_matrix) transform_matrix = scale * transform_matrix * Img.get_scale_diagonal_matrix( 1.5) * Img.get_scale_orthogonal_matrix(0.5) translation_vector = np.array([0, 0]) img_bilinear = RestructuringMethod.affine_transform( img, transform_matrix, translation_vector, RestructuringMethod.BilinearInterpolation) img_nearest = RestructuringMethod.affine_transform( img, transform_matrix, translation_vector, RestructuringMethod.NearestNeighbor) imsave("../images/gletscher_b4_bilinear.jpg", img_bilinear) imsave("../images/gletscher_b4_nearest.jpg", img_nearest)
def b1(): image = Img.load_image(image_path) target_image_size_height = 900 target_image_size_witdh = 600 new_x_size = target_image_size_witdh*3 new_y_size = target_image_size_height*3 new_image = np.zeros((new_x_size, new_y_size, 3)) # links oben pass_point_1_x = 344.0 pass_point_1_y = 334.0 target_point_1_x = 0.0 target_point_1_y = 0.0 # links unten pass_point_2_x = 300.0 pass_point_2_y = 456.0 target_point_2_x = 0.0 target_point_2_y = target_image_size_height pass_point_3_x = 694.0 pass_point_3_y = 432.0 #rechts unten #pass_point_3_x = 690.0 #pass_point_3_y = 460.0 target_point_3_x = target_image_size_witdh target_point_3_y = target_image_size_height #recht oben pass_point_4_x = 548.0 pass_point_4_y = 330.0 target_point_4_x = target_image_size_witdh target_point_4_y = 0.0 translation_factor = 0 points = [DistortionCorrectionPoint(344.0, 344.0, 0.0+translation_factor, 0.0+translation_factor), # links oben DistortionCorrectionPoint(300.0, 456.0, 0.0+translation_factor, target_image_size_height+translation_factor), # links unten DistortionCorrectionPoint(694.0, 432.0, target_image_size_witdh+translation_factor, target_image_size_height+translation_factor), DistortionCorrectionPoint(548.0, 330.0, target_image_size_witdh+translation_factor, 0.0+translation_factor)] # rechts unten new_image = DistortionCorrection.distortion_correction(points, image, new_image) imsave("../images/test.jpg", new_image)
def zwei_bilder_stiching(): links = Img.load_image('../gGebaeude/links.jpg') mitte_links = Img.load_image('../gGebaeude/mitteLinks.jpg') mitte_rechts = Img.load_image('../gGebaeude/mitteRechts.jpg') rechts = Img.load_image('../gGebaeude/rechts.jpg') points_links = [DistortionCorrectionPoint(1215.0, 919.0, 0.0, 0.0), # links oben DistortionCorrectionPoint(1001.0, 3066.0, 0.0, 650), # links unten DistortionCorrectionPoint(4439.0, 461.0, 1125, 0), # rechts oben DistortionCorrectionPoint(4392.0, 3321.0, 1125, 650)] # rechts unten points_mitte_links = [DistortionCorrectionPoint(549.0, 496.0, 0.0, 0.0), # links oben DistortionCorrectionPoint(366.0, 3230.0, 0.0, 650), # links unten DistortionCorrectionPoint(4175.0, 461.0, 1011, 0.0), # rechts oben DistortionCorrectionPoint(4261.0, 3249.0, 1011, 650)] # rechts unten # Verschiebe Bild zum nächsten Passpunkt DistortionCorrectionPoint.set_move_to_right_in_array(points_mitte_links, 992) points_mitte_rechts = [DistortionCorrectionPoint(505.0, 395.0, 0.0, 0.0), # links oben DistortionCorrectionPoint(489.0, 3181.0, 0.0, 650), # links unten DistortionCorrectionPoint(4058.0, 493.0, 990, 0), # rechts oben DistortionCorrectionPoint(4250.0, 3027.0, 990, 650)] # rechts unten DistortionCorrectionPoint.set_move_to_right_in_array(points_mitte_rechts, 992+1011) points_rechts = [DistortionCorrectionPoint(763.0, 771.0, 0.0, 0.0), # links oben DistortionCorrectionPoint(817.0, 3164.0, 0.0, 650), # links unten DistortionCorrectionPoint(3272.0, 1191.0, 1169, 0), # rechts oben DistortionCorrectionPoint(3417.0, 3019.0, 1169, 650)] # rechts unten DistortionCorrectionPoint.set_move_to_right_in_array(points_rechts, 992 + 1011 + 990) stichting_images = [ ImageAndPasspoints(links,points_links), ImageAndPasspoints(mitte_links, points_mitte_links), ImageAndPasspoints(mitte_rechts, points_mitte_rechts), ImageAndPasspoints(rechts, points_rechts)] mode = StitchMode.MODE_MULTIBAND_BLENDING stitched_image = Img.sticht_images_vignete(stichting_images, mode) imsave('../gGebaeude/stitched_image_{}.jpg'.format(mode), stitched_image) mode = StitchMode.MODE_SUM stitched_image = Img.sticht_images_vignete(stichting_images, mode) imsave('../gGebaeude/stitched_image_{}.jpg'.format(mode), stitched_image) mode = StitchMode.MODE_STRONGEST stitched_image = Img.sticht_images_vignete(stichting_images, mode) imsave('../gGebaeude/stitched_image_{}.jpg'.format(mode), stitched_image)