Exemplo n.º 1
0
    def test_frame_similarity_ssim(self):

        module = FrameSimilarityModule(name_in='simi3',
                                       image_tag='read',
                                       method='SSIM',
                                       mask_radius=(0., 1.),
                                       temporal_median='constant')

        self.pipeline.add_module(module)
        self.pipeline.run_module('simi3')

        similarity = self.pipeline.get_attribute('read', 'SSIM', static=False)

        assert len(similarity) == self.pipeline.get_shape('read')[0]
        assert np.min(similarity) > 0
        assert np.max(similarity) < 1
        assert similarity[4] != similarity[8]
        assert np.allclose(np.sum(similarity),
                           43.999059977871184,
                           rtol=limit,
                           atol=0.)
        assert np.allclose(similarity[0],
                           0.9999793908738922,
                           rtol=limit,
                           atol=0.)
Exemplo n.º 2
0
    def test_frame_similarity_pcc(self) -> None:

        module = FrameSimilarityModule(name_in='simi2',
                                       image_tag='read',
                                       method='PCC',
                                       mask_radius=(0., 0.2))

        self.pipeline.add_module(module)
        self.pipeline.run_module('simi2')

        attr = self.pipeline.get_attribute('read', 'PCC', static=False)
        assert np.min(attr) > 0.
        assert np.sum(attr) == pytest.approx(9.134820985662829,
                                             rel=self.limit,
                                             abs=0.)
        assert attr.shape == (10, )
Exemplo n.º 3
0
    def test_frame_similarity_mse(self) -> None:

        module = FrameSimilarityModule(name_in='simi1',
                                       image_tag='read',
                                       method='MSE',
                                       mask_radius=(0., 0.2))

        self.pipeline.add_module(module)
        self.pipeline.run_module('simi1')

        attr = self.pipeline.get_attribute('read', 'MSE', static=False)
        assert np.min(attr) > 0.
        assert np.sum(attr) == pytest.approx(0.11739141370277852,
                                             rel=self.limit,
                                             abs=0.)
        assert attr.shape == (10, )
Exemplo n.º 4
0
    def test_frame_similarity_ssim(self) -> None:

        module = FrameSimilarityModule(name_in='simi3',
                                       image_tag='read',
                                       method='SSIM',
                                       mask_radius=(0., 0.2),
                                       temporal_median='constant')

        self.pipeline.add_module(module)
        self.pipeline.run_module('simi3')

        attr = self.pipeline.get_attribute('read', 'SSIM', static=False)
        assert np.min(attr) > 0.
        assert np.sum(attr) == pytest.approx(9.096830542868524,
                                             rel=self.limit,
                                             abs=0.)
        assert attr.shape == (10, )
Exemplo n.º 5
0
    def test_frame_similarity_mse(self):

        module = FrameSimilarityModule(name_in='simi1',
                                       image_tag='read',
                                       method='MSE')

        self.pipeline.add_module(module)
        self.pipeline.run_module('simi1')

        similarity = self.pipeline.get_attribute('read', 'MSE', static=False)

        assert len(similarity) == self.pipeline.get_shape('read')[0]
        assert np.min(similarity) > 0
        assert similarity[4] != similarity[8]
        assert np.allclose(np.sum(similarity),
                           1.4345237709250252e-06,
                           rtol=limit,
                           atol=0.)
        assert np.allclose(similarity[0],
                           3.292787144877646e-08,
                           rtol=limit,
                           atol=0.)
Exemplo n.º 6
0
    def test_frame_similarity_mse(self):

        module = FrameSimilarityModule(name_in='simi1',
                                       image_tag='read',
                                       method='MSE',
                                       mask_radius=(0., 1.))

        self.pipeline.add_module(module)
        self.pipeline.run_module('simi1')

        similarity = self.pipeline.get_attribute('read', 'MSE', static=False)

        assert len(similarity) == self.pipeline.get_shape('read')[0]
        assert np.min(similarity) > 0
        assert similarity[4] != similarity[8]
        assert np.allclose(np.sum(similarity),
                           1.7938335695664495e-06,
                           rtol=limit,
                           atol=0.)
        assert np.allclose(similarity[0],
                           4.103008589430469e-08,
                           rtol=limit,
                           atol=0.)
Exemplo n.º 7
0
    def test_frame_similarity_pcc(self):

        module = FrameSimilarityModule(name_in='simi2',
                                       image_tag='read',
                                       method='PCC')

        self.pipeline.add_module(module)
        self.pipeline.run_module('simi2')

        similarity = self.pipeline.get_attribute('read', 'PCC', static=False)

        assert len(similarity) == self.pipeline.get_shape('read')[0]
        assert np.min(similarity) > 0
        assert np.max(similarity) < 1
        assert similarity[4] != similarity[8]
        assert np.allclose(np.sum(similarity),
                           43.854202044574045,
                           rtol=limit,
                           atol=0.)
        assert np.allclose(similarity[0],
                           0.9966447074865488,
                           rtol=limit,
                           atol=0.)
Exemplo n.º 8
0
    def test_frame_similarity_pcc(self):

        module = FrameSimilarityModule(name_in='simi2',
                                       image_tag='read',
                                       method='PCC',
                                       mask_radius=(0., 1.))

        self.pipeline.add_module(module)
        self.pipeline.run_module('simi2')

        similarity = self.pipeline.get_attribute('read', 'PCC', static=False)

        assert len(similarity) == self.pipeline.get_shape('read')[0]
        assert np.min(similarity) > 0
        assert np.max(similarity) < 1
        assert similarity[4] != similarity[8]
        assert np.allclose(np.sum(similarity),
                           43.974652830856314,
                           rtol=limit,
                           atol=0.)
        assert np.allclose(similarity[0],
                           0.9994193494590345,
                           rtol=limit,
                           atol=0.)