Example #1
0
    def test_transforms_graphical(self):
        im = PewImage(self.img)
        A1, A2, A3 = zoom(1, 1.5), shear(0.3, 0), rotate(45)
        _im1 = im.affine_transform(A1)
        _im2 = im.affine_transform(A2)
        _im3 = im.affine_transform(A3)

        centre = np.array(im.image.size) / 2.0
        fig, ax = plt.subplots(2, 4, figsize=(12, 3), sharex=True, sharey=True)
        ax[0, 0].scatter(*centre, color="r")
        # get the max extent of images
        x0, x1, y0, y1 = 0, 1, 0, 1
        for ix, I in enumerate([im, _im1, _im2, _im3]):
            x0, x1, y0, y1 = (
                min(x0, np.min(I.extent[:2])),
                max(x1, np.max(I.extent[:2])),
                min(y0, np.min(I.extent[2:])),
                max(y1, np.max(I.extent[2:])),
            )
            ax[0, ix].imshow(I.image)
            ax[1, ix].imshow(I.image, extent=I.extent)

        size = np.max(im.image.size) * np.sqrt(2)
        ax = ax.flat

        for a in ax:
            a.set_aspect("equal")
            a.axis([x0, x1, y0, y1])
Example #2
0
 def test_affine_transform(self):
     im = PewImage(self.img)
     affine_im = im.affine_transform(rotate(30))