0

使用 Lightroom,我知道如何将相机配置文件(*.dcp 文件)应用到我的 *.DNG 图像。

我想在我正在编写的应用程序中做同样的事情,所以我想一个好的起点是将此功能附加到 dng_validate.exe 应用程序。

于是我开始补充:

#include "dng_camera_profile.h"

然后补充说:

static dng_string gDumpDCP; 

并将以下内容添加到错误打印中:

"-dcp <file>   Load camera profile from <file>.dcp\"\n"

然后我添加了从 cli 读取 dcp 的函数:

else if (option.Matches("dcp", true))
{
   gDumpDCP.Clear();
   if (index + 1 < argc)
   {
      gDumpDCP.Set(argv[++index]);
   }

   if (gDumpDCP.IsEmpty() || gDumpDCP.StartsWith("-"))
   {
      fprintf(stderr, "*** Missing file name after -dcp\n");
      return 1;
   }

   if (!gDumpDCP.EndsWith(".dcp"))
   {
      gDumpDCP.Append(".dcp");
   }

}

然后我从磁盘加载配置文件 [第 421 行]:

if (gDumpTIF.NotEmpty ())
{
   dng_camera_profile profile;
   if (gDumpDCP.NotEmpty())
   {
      dng_file_stream inStream(gDumpDCP.Get());
      profile.ParseExtended(inStream);
   }
   // Render final image.
   .... rest of code as it was

那么我现在如何使用配置文件数据来校正渲染并写入校正后的图像?

4

2 回答 2

1

您需要使用 将配置文件添加到您的否定中negative->AddProfile(profile);

我的项目raw2dng做到了这一点(以及更多),如果你想看一个例子,可以在源代码中找到。配置文件在此处添加。

于 2017-06-04T17:51:50.137 回答
1

所以在玩了几天之后,我现在找到了解决方案。实际上,底片可以有多个相机配置文件。因此,negative->AddProfile(profile)只需添加一个即可。但如果它不是第一个配置文件,则不会使用它!所以我们首先需要清理配置文件,然后添加一个。

AutoPtr<dng_camera_profile> profile(new dng_camera_profile);
if (gDumpDCP.NotEmpty())
{
    negative->ClearProfiles();
    dng_file_stream inStream(gDumpDCP.Get());
    profile->ParseExtended(inStream);

    profile->SetWasReadFromDNG();
    negative->AddProfile(profile);

    printf("Profile count: \"%d\"\n", negative->ProfileCount()); // will be 1 now!
}

正确获取图像的下一件事是具有正确的白平衡。这可以在相机中或之后完成。对于我使用 4 个不同相机的应用程序,使用后期白平衡校正时效果最好。所以我使用 Lightroom 找到了 4 个(温度、色调)对。

问题是如何在 dng_validate.exe 程序中添加这些值。我是这样做的:

#include "dng_temperature.h"

if (gTemp != NULL && gTint != NULL)
{
    dng_temperature temperature(gTemp, gTint);
    render.SetWhiteXY(temperature.Get_xy_coord());
}

生成的图像与 Lightroom 结果略有不同,但足够接近。现在相机与相机之间的差异也消失了!:)

于 2017-06-08T10:17:24.593 回答