示例#1
0
 def test_wavelet_transformations(self):
     """ Test all the registered transformations.
     """
     for image in self.images:
         print("Process test with image '{0}'...".format(
             image.metadata["path"]))
         for nb_scale in self.nb_scales:
             print("- Number of scales: {0}".format(nb_scale))
             for transform in self.transforms:
                 print("    Transform: {0}".format(transform))
                 transform = transform(nb_scale=nb_scale, verbose=0)
                 self.assertFalse(transform.use_wrapping)
                 transform.info
                 transform.data = image
                 transform.analysis()
                 # transform.show()
                 recim = transform.synthesis()
                 # recim.show()
                 mismatch = (1. - numpy.mean(
                     numpy.isclose(
                         recim.data, image.data, atol=1e-8, rtol=1e-5)))
                 print("      mismatch = ", mismatch)
                 print("      analysis = ",
                       [band.shape for band in transform.analysis_data],
                       len(transform.analysis_data))
                 print("      bands = ", transform.nb_band_per_scale)
                 print("      synthesis = ", recim.shape)
示例#2
0
 def test_speed(self):
     """ Test the bindings time advantages.
     """
     # With/without bindings
     for strategy, name in ((True, "Without"), (False, "With")):
         tic = time.time()
         transform = pysap.load_transform(
             "LinearWaveletTransformATrousAlgorithm")
         transform = transform(nb_scale=4, verbose=0)
         transform.use_wrapping = strategy
         transform.data = self.images[0]
         for i in range(self.nb_iter):
             transform.analysis()
             recim = transform.synthesis()
         toc = time.time()
         print("[result] {0} bindings execution time: {1}.".format(
             name, toc - tic))
示例#3
0
    def test_wavelet_transformations(self):
        """ Test all the registered transformations.
        """
        for image_i in self.images:
            print("Process test with image '{0}'...".format(
                image_i.metadata["path"]))
            for nb_scale in self.nb_scales:
                print("- Number of scales: {0}".format(nb_scale))
                for transform in self.transforms:
                    print("    Transform: {0}".format(transform))
                    if transform.__family__ == "isap-2d":
                        transform = transform(nb_scale=nb_scale,
                                              verbose=0,
                                              padding_mode="symmetric")
                    else:
                        transform = transform(nb_scale=nb_scale, verbose=0)

                    image = numpy.copy(image_i)

                    if transform.data_dim == 3:
                        image = image[64:192, 64:192]
                        image = numpy.tile(image, (image.shape[0], 1, 1))
                        transform.data = image
                    else:
                        transform.data = image

                    self.assertFalse(transform.use_wrapping)
                    transform.info
                    transform.analysis()
                    # transform.show()
                    recim = transform.synthesis()
                    # recim.show()
                    mismatch = (1. - numpy.mean(
                        numpy.isclose(recim.data, image, atol=1e-8,
                                      rtol=1e-5)))
                    print("      mismatch = ", mismatch)
                    print("      analysis = ",
                          [band.shape for band in transform.analysis_data],
                          len(transform.analysis_data))
                    print("      bands = ", transform.nb_band_per_scale)
                    print("      synthesis = ", recim.shape)