Beispiel #1
0
    def test_highlights_recovery_blend(self):
        """
        Tests :func:`colour_hdri.recovery.highlights.highlights_recovery_blend`
        definition.
        """

        multipliers = np.array([2.42089718, 1.00000000, 1.54687415])
        multipliers /= np.max(multipliers)

        reference_raw_file = RAW_IMAGES[1]
        test_raw_file = os.path.join(self._temporary_directory,
                                     os.path.basename(reference_raw_file))
        shutil.copyfile(reference_raw_file, test_raw_file)
        command = [RAW_CONVERTER] + shlex.split(
            RAW_D_CONVERSION_ARGUMENTS.format(test_raw_file),
            posix=not _IS_WINDOWS_PLATFORM)

        subprocess.call(command)  # nosec

        test_tiff_file = read_image(
            str(re.sub('\\.CR2$', '.tiff', test_raw_file)))[::10, ::10, :]

        test_tiff_file *= multipliers
        test_tiff_file = highlights_recovery_blend(test_tiff_file, multipliers)
        test_tiff_file = camera_space_to_sRGB(test_tiff_file,
                                              XYZ_TO_CAMERA_SPACE_MATRIX)
        reference_exr_path = os.path.join(
            RECOVERY_DIRECTORY,
            os.path.basename(re.sub('\\.CR2$', '_Blend.exr', test_raw_file)))
        reference_exr_file = read_image(str(reference_exr_path))

        np.testing.assert_allclose(test_tiff_file,
                                   reference_exr_file,
                                   rtol=0.0001,
                                   atol=0.0001)
    def test_camera_space_to_sRGB(self):
        """
        Tests :func:`colour_hdri.models.rgb.camera_space_to_sRGB` definition.
        """

        np.testing.assert_almost_equal(
            camera_space_to_sRGB(
                np.array([0.80660, 0.81638, 0.65885]),
                np.array([[0.47160000, 0.06030000, -0.08300000],
                          [-0.77980000, 1.54740000, 0.24800000],
                          [-0.14960000, 0.19370000, 0.66510000]])),
            np.array([0.75643502, 0.86831555, 0.60447061]),
            decimal=7)
Beispiel #3
0
    def test_camera_space_to_sRGB(self):
        """
        Tests :func:`colour_hdri.models.rgb.camera_space_to_sRGB` definition.
        """

        np.testing.assert_almost_equal(
            camera_space_to_sRGB(
                np.array([0.80660, 0.81638, 0.65885]),
                np.array(
                    [[0.47160000, 0.06030000, -0.08300000],
                     [-0.77980000, 1.54740000, 0.24800000],
                     [-0.14960000, 0.19370000, 0.66510000]])),
            np.array([0.75643502, 0.86831555, 0.60447061]),
            decimal=7)  # yapf: disable
    def test_highlights_recovery_blend(self):
        """
        Tests :func:`colour_hdri.recovery.highlights.highlights_recovery_blend`
        definition.
        """

        multipliers = np.array([2.42089718, 1.00000000, 1.54687415])
        multipliers /= np.max(multipliers)

        XYZ_to_camera_matrix = np.array([
            [0.47160000, 0.06030000, -0.08300000],
            [-0.77980000, 1.54740000, 0.24800000],
            [-0.14960000, 0.19370000, 0.66510000]])

        reference_raw_file = RAW_IMAGES[1]
        test_raw_file = os.path.join(
            self.__temporary_directory, os.path.basename(reference_raw_file))
        shutil.copyfile(reference_raw_file, test_raw_file)
        command = [RAW_CONVERTER] + shlex.split(
            RAW_D_CONVERSION_ARGUMENTS.format(test_raw_file),
            posix=(False
                   if platform.system() in ("Windows", "Microsoft") else
                   True))

        subprocess.call(command)

        test_tiff_file = read_image(
            str(re.sub('\.CR2$', '.tiff', test_raw_file)))

        test_tiff_file *= multipliers
        test_tiff_file = highlights_recovery_blend(
            test_tiff_file, multipliers)
        test_tiff_file = camera_space_to_sRGB(
            test_tiff_file, XYZ_to_camera_matrix)

        reference_tiff_file = read_image(str(os.path.join(
            RECOVERY_DIRECTORY,
            os.path.basename(re.sub('\.CR2$', '.exr', test_raw_file)))))

        np.testing.assert_almost_equal(
            test_tiff_file[::10, ::10, :],
            reference_tiff_file,
            decimal=7)