簡體   English   中英

將相機配置文件校正添加到dng_validate.exe [Adobe DNG SDK]

[英]Adding camera profile correction to dng_validate.exe [Adobe DNG SDK]

使用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

那么,現在如何使用配置文件數據校正渲染並寫入校正后的圖像?

您需要使用negative->AddProfile(profile);將配置文件添加到您的底片中negative->AddProfile(profile);

我的項目raw2dng可以執行此操作(以及更多操作),如果您想查看示例,可以在源代碼中找到它。 配置文件已添加到此處

因此,在玩了幾天之后,我現在找到了解決方案。 底片實際上可以具有多個相機配置文件。 因此,使用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結果略有不同,但是足夠接近。 相機之間的差異也消失了! :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM