Beispiel #1
0
    def test_warpedImageToFixedSpaceRotateTransform(self):
        WarpedImagePath = os.path.join(
            self.ImportedDataPath,
            "0017_TEM_Leveled_image__feabinary_Cel64_Mes8_sp4_Mes8.png")
        self.assertTrue(os.path.exists(WarpedImagePath), "Missing test input")

        angle = 30
        arecord = AlignmentRecord(peak=(0, 0), weight=100, angle=angle)

        fixedImage = nornir_imageregistration.LoadImage(WarpedImagePath)
        warpedImage = nornir_imageregistration.LoadImage(WarpedImagePath)

        transform = arecord.ToTransform(fixedImage.shape, warpedImage.shape)

        transformedImage = assemble.WarpedImageToFixedSpace(
            transform, fixedImage.shape, warpedImage)
        imsave("C:\\Temp\\17Rotate.png", transformedImage)

        rotatedWarped = interpolation.rotate(warpedImage.astype(numpy.float32),
                                             angle=angle)
        #
        self.assertTrue(
            ShowComparison(
                [fixedImage, rotatedWarped, transformedImage],
                title=
                "Rotate transform should match scipy.interpolate.rotate result",
                PassFail=True))
Beispiel #2
0
    def test_Rotate180(self):

        arecord = AlignmentRecord(peak=(0, 0), weight=100, angle=180.0)
        canvasShape = (2, 6)
        flipCanvasShape = (6, 2)
        transform = arecord.ToTransform(canvasShape, canvasShape)

        (fixedpoints, points) = assemble.DestinationROI_to_SourceROI(
            transform, (0, 0), canvasShape)

        self.assertAlmostEqual(min(points[:, spatial.iPoint.Y]), 0, delta=0.01)
        self.assertAlmostEqual(max(points[:, spatial.iPoint.Y]), 1, delta=0.01)
        self.assertAlmostEqual(min(points[:, spatial.iPoint.X]), 0, delta=0.01)
        self.assertAlmostEqual(max(points[:, spatial.iPoint.X]), 5, delta=0.01)
Beispiel #3
0
    def test_identity(self):

        arecord = AlignmentRecord(peak=(0, 0), weight=100, angle=0.0)

        # Shape in numpy is (height, width)
        canvasShape = (2, 6)
        flipCanvasShape = (6, 2)
        transform = arecord.ToTransform(canvasShape, canvasShape)

        (fixedpoints, points) = assemble.DestinationROI_to_SourceROI(
            transform, (0, 0), canvasShape)

        # Transform ROI should return coordinates as
        # ([Y1,X1],
        # ([Y2,X2], ...

        self.assertAlmostEqual(min(points[:, spatial.iPoint.Y]), 0, delta=0.01)
        self.assertAlmostEqual(max(points[:, spatial.iPoint.Y]), 1, delta=0.01)
        self.assertAlmostEqual(min(points[:, spatial.iPoint.X]), 0, delta=0.01)
        self.assertAlmostEqual(max(points[:, spatial.iPoint.X]), 5, delta=0.01)
Beispiel #4
0
    def test_warpedImageToFixedSpaceIdentityTransform(self):
        WarpedImagePath = os.path.join(
            self.ImportedDataPath,
            "0017_TEM_Leveled_image__feabinary_Cel64_Mes8_sp4_Mes8.png")
        self.assertTrue(os.path.exists(WarpedImagePath), "Missing test input")

        arecord = AlignmentRecord(peak=(0, 0), weight=100, angle=0.0)

        fixedImage = nornir_imageregistration.LoadImage(WarpedImagePath)
        warpedImage = nornir_imageregistration.LoadImage(WarpedImagePath)

        transform = arecord.ToTransform(fixedImage.shape, warpedImage.shape)

        transformedImage = assemble.WarpedImageToFixedSpace(
            transform, fixedImage.shape, warpedImage, (0, 0), (64, 64))
        # imsave("C:\\Temp\\17.png", transformedImage)

        delta = fixedImage[0:64, 0:64] - transformedImage

        # nornir_imageregistration.ShowGrayscale([fixedImage[0:64, 0:64], transformedImage, delta])
        self.assertTrue((delta < 0.01).all())
Beispiel #5
0
    def test_warpedImageToFixedSpace(self):
        WarpedImagePath = os.path.join(
            self.ImportedDataPath,
            "0017_TEM_Leveled_image__feabinary_Cel64_Mes8_sp4_Mes8.png")
        self.assertTrue(os.path.exists(WarpedImagePath), "Missing test input")
        FixedImagePath = os.path.join(
            self.ImportedDataPath,
            "mini_TEM_Leveled_image__feabinary_Cel64_Mes8_sp4_Mes8.png")
        self.assertTrue(os.path.exists(FixedImagePath), "Missing test input")

        arecord = AlignmentRecord(peak=(22, -4), weight=100, angle=-132.0)

        fixedImage = nornir_imageregistration.LoadImage(FixedImagePath)
        warpedImage = nornir_imageregistration.LoadImage(WarpedImagePath)

        transform = arecord.ToTransform(fixedImage.shape, warpedImage.shape)

        transformedImage = assemble.WarpedImageToFixedSpace(
            transform, fixedImage.shape, warpedImage)
        imsave(
            os.path.join(self.VolumeDir, "test_warpedImageToFixedSpace.png"),
            transformedImage)