Adding camera profile correction to dng_validate.exe

Using Lightroom I know how to apply a camera profile (*.dcp file) to my *.DNG image.

I would like to do the same in an application which I'm writing, so I guess a good

starting point would be to append this functionality to the dng_validate.exe

application.

So I started to add:

    #include "dng_camera_profile.h"

Then added:

    static dng_string gDumpDCP;

And add the following to the error print:

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

Then I added the function to read the dcp from cli:

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");

                }

            }

Then I load the profile from disk:

     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

So how do I now use the profile data to correct the render and write the corrected image?

Topics

DNG
View all replies

Views

363

Likes

Translate

Translate

Report

Report
More
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More

Adding camera profile correction to dng_validate.exe

Using Lightroom I know how to apply a camera profile (*.dcp file) to my *.DNG image.

I would like to do the same in an application which I'm writing, so I guess a good

starting point would be to append this functionality to the dng_validate.exe

application.

So I started to add:

    #include "dng_camera_profile.h"

Then added:

    static dng_string gDumpDCP;

And add the following to the error print:

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

Then I added the function to read the dcp from cli:

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");

                }

            }

Then I load the profile from disk:

     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

So how do I now use the profile data to correct the render and write the corrected image?

Topics

DNG
View all replies

Views

364

Likes

Translate

Translate

Report

Report
More
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More

So after playing around for a couple of days, I now found the solution. Actually the negative can have multiple camera profiles. So with negative->AddProfile(profile) you just add one. But this won't be used if it's not the first profile! So we first need to clean the profiles and than add one.

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!
}

Next thing to get the image correctly is to have correct white balance. This can be done in camera or afterwards. For my application with 4 different cameras, the result was the best when using afterward white balance correction. So I found 4 (Temperature,Tint) pairs using Lightroom.

The question was how to add these values in the dng_validate.exe program. I did it like this:

#include "dng_temperature.h"

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

The resulting images are slightly different from the Lightroom result, but close enough. Also the camera to camera differences are gone now!

2 Replies

Re: Adding camera profile correction to dng_validate.exe

Can't help yet, but I'm just starting up with the DNG SDK and will be using it extensively in weeks to come. Stay tuned. I'm lucky SOMEONE else is on this forum as recently as 5 days ago. This whole thing is a struggle and I will happily share whatever I find out to help you!

View all replies

Likes

Translate

Translate

Report

Report
More
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...

Re: Adding camera profile correction to dng_validate.exe

So after playing around for a couple of days, I now found the solution. Actually the negative can have multiple camera profiles. So with negative->AddProfile(profile) you just add one. But this won't be used if it's not the first profile! So we first need to clean the profiles and than add one.

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!
}

Next thing to get the image correctly is to have correct white balance. This can be done in camera or afterwards. For my application with 4 different cameras, the result was the best when using afterward white balance correction. So I found 4 (Temperature,Tint) pairs using Lightroom.

The question was how to add these values in the dng_validate.exe program. I did it like this:

#include "dng_temperature.h"

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

The resulting images are slightly different from the Lightroom result, but close enough. Also the camera to camera differences are gone now!

View all replies

Likes

Translate

Translate

Report

Report
More
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn More
Reply
Loading...