Esempio n. 1
0
    def test_large_factor_fails(self):
        """Test raising of RuntimeError for very large scaling factors."""
        base_image = _generate_image()

        with self.assertRaises(RuntimeError):
            merge.compute_scaling(base_image / 1000, base_image)
        with self.assertRaises(RuntimeError):
            merge.compute_scaling(base_image / 1e-3, base_image)
Esempio n. 2
0
    def test_scaled(self):
        """Basic functinality test."""
        base_image = _generate_image()

        image = base_image / 1.5
        result = merge.compute_scaling(image, base_image)
        self.assertTrue(np.isclose(result, 1.5))

        image = base_image / 0.5
        result = merge.compute_scaling(image, base_image)
        self.assertTrue(np.isclose(result, 0.5))
Esempio n. 3
0
    def test_unscaled(self):
        """Same brightness for both input images."""
        base_image = _generate_image()
        image = np.copy(base_image)

        result = merge.compute_scaling(image, base_image)
        self.assertTrue(np.isclose(result, 1))
Esempio n. 4
0
    def test_argument_check(self):
        """Test checking of function argument values."""
        base_image = _generate_image()
        image = base_image / 1.5

        merge.compute_scaling(image,
                              base_image,
                              mask_width=0.3,
                              target_gamma=1.0)

        with self.assertRaises(ValueError):
            merge.compute_scaling(image, base_image, mask_width=-0.01)
        with self.assertRaises(ValueError):
            merge.compute_scaling(image, base_image, mask_width=1.01)
        with self.assertRaises(ValueError):
            merge.compute_scaling(image, base_image, target_gamma=-1)
Esempio n. 5
0
    def test_same_image(self):
        """id(image) == id(base_image)."""
        image = _generate_image()

        result = merge.compute_scaling(image, image)
        self.assertTrue(np.isclose(result, 1))