New project: camera color profile calculation - page 2 - RAW Shooting and Processing - CHDK Forum

New project: camera color profile calculation

  • 480 Replies
  • 236461 Views
*

Offline ArtDen

  • ***
  • 175
    • dng4ps2
Re: New project: camera color profile calculation
« Reply #10 on: 27 / January / 2008, 02:10:25 »
Advertisements
ArtDen, it will be interesting if/when you share your program because then people could create RAW profiles that would perfectly emulate their favorite settings on their cameras
I will, but only after I complete it. For example now the program can't calculate gamma of camera jpeg image so I do it manually for each file.

Re: New project: camera color profile calculation
« Reply #11 on: 27 / January / 2008, 02:47:34 »
I have to say this is really weird. Color gamut of LCD monitors is not as wide as the cameras gamut. Not to mention all the issues involved in photographing computer displays...

Could this program be useful in comparing photos of the actual XRite/Gretag-Macbeth color targets?


*

Offline ArtDen

  • ***
  • 175
    • dng4ps2
Re: New project: camera color profile calculation
« Reply #12 on: 27 / January / 2008, 03:38:39 »
I have to say this is really weird. Color gamut of LCD monitors is not as wide as the cameras gamut. Not to mention all the issues involved in photographing computer displays...
The program just compares images. It is enough simple photos for it, but it makes best results for monotone areas of colors.

Could this program be useful in comparing photos of the actual XRite/Gretag-Macbeth color targets?
Yes :)
« Last Edit: 27 / January / 2008, 03:47:26 by ArtDen »

*

Offline vit40

  • ****
  • 276
Re: New project: camera color profile calculation
« Reply #13 on: 27 / January / 2008, 09:44:47 »
ArtDen, congratulations for this project



Code: [Select]
1,307006 -0,490421 -0,194771
-0,271197 1,444538 0,037449
-0,119053 0,286961 0,455555

It produces little brighter images then Jpeg but seems colors are correct.


As I explained in DngSetmatrix readme, brightness of image made from dng depends on BaselineExposure tag value. So here is "DngSetExposure.dpr" (correct line marked "exposure value here" up or down if needed; value in header files is +50/100)

Code: [Select]
program Delphi;
{$APPTYPE CONSOLE}
uses
  Windows, SysUtils;


function BufScanBytes(const A, Pattern: array of Byte; PatternLength, StartOffset, EndOffset: Integer): Integer;
// search for byte pattern "Pattern" in byte array "A"; Returns offset, or -1 if not found
var
  i, j: Integer;
  diff: Boolean;
begin
  for i := StartOffset to EndOffset - PatternLength do begin
    diff := False;
    for j := 0 to PatternLength - 1 do
      if A[i+j] <> Pattern[j] then begin
        diff := True;
        Break;
      end;
    if not diff then begin
      Result := i;
      Exit;
    end;
  end;
  Result := -1;
end;


var
  FileSize: Integer;
  f: File;
  Buf: array[0..20000000] of Byte;
  Pattern: array[0..100] of Byte;
  WPattern: array[0..50] of Word absolute Pattern;
  ValueOffset: Integer;
  p, e, n: Integer;


begin
  if ParamCount <> 1 then begin
    WriteLn('Usage: DngResetBaseline  <DNG FileName>');
    WriteLn;
    Sleep(2000);
    Halt;
  end;

  // read file

  AssignFile(f, ParamStr(1));
  Reset(f, 1);
  BlockRead(f, Buf, SizeOf(Buf), FileSize);
  Close(f);

  if FileSize > 1024 then
    WriteLn('File read OK')
  else begin
    WriteLn(ParamStr(1), ' - File read error');
    Sleep(2000);
    Halt;
  end;

  // reset BaselineExposure

  WPattern[0] := $C62A;  // tag
  WPattern[1] := $000A;  // type
  WPattern[2] := $0001;  // count
  p := BufScanBytes(Buf, Pattern, 3 * SizeOf(Word), 0, FileSize);
  if p > 0 then begin
    Move(Buf[p+8], ValueOffset, 4);
    p := ValueOffset;
    n := 0;                  // <----  exposure value here
    Move(n, Buf[p], 4);
    Inc(p, 4);
    n := 100;
    Move(n, Buf[p], 4);
    WriteLn('Baseline exposure set to 0/100');
  end else
    WriteLn('Can''t find Baseline exposure');

  // write file

  AssignFile(f, ParamStr(1));
  Reset(f, 1);
  BlockWrite(f, Buf, FileSize);
  Close(f);

  e := IOResult;
  if e = 0 then
    WriteLn('File write OK')
  else
    WriteLn(ParamStr(1), ' - File write error #', e);
end.

« Last Edit: 27 / January / 2008, 09:48:04 by vit40 »


*

Offline jeff666

  • ****
  • 181
  • A720IS
Re: New project: camera color profile calculation
« Reply #14 on: 27 / January / 2008, 11:51:08 »

*

Offline ArtDen

  • ***
  • 175
    • dng4ps2
Re: New project: camera color profile calculation
« Reply #15 on: 27 / January / 2008, 13:13:35 »
As I explained in DngSetmatrix readme, brightness of image made from dng depends on BaselineExposure tag value
I set BaselineExposure to 0 when testing new calculated matrix. I think differences in brightness happens because of difference of tone mapping which possibly is made for Jpeg.

*

Offline ArtDen

  • ***
  • 175
    • dng4ps2
Re: New project: camera color profile calculation
« Reply #16 on: 27 / January / 2008, 13:14:28 »
Here's another A720: http://www.zshare.net/download/692551053568a6/
Thanks. I will publish results after I download your file

*

Offline ArtDen

  • ***
  • 175
    • dng4ps2
Re: New project: camera color profile calculation
« Reply #17 on: 27 / January / 2008, 14:58:11 »
Here's another A720: http://www.zshare.net/download/692551053568a6/
Matrix for your image is
Code: [Select]
0.815000, -0.265224, -0.126610,
-0.198011, 0.933790, 0.071668,
-0.036675, 0.197160, 0.248759
It is better then previous one. But there is some problem with red color (you can see it in attached images. IMG_7020_orig.jpg - original, CRW_7020.jpg - made by Adobe Lightroom). And I don't know how to fix it. Possible it can be fixed only by calculating full camera profile (not only color matrix) with special calibration target and special software.

« Last Edit: 27 / January / 2008, 15:19:01 by ArtDen »


Re: New project: camera color profile calculation
« Reply #18 on: 27 / January / 2008, 16:13:08 »
My second attempt
rommel_a720is.zip

*

Offline vit40

  • ****
  • 276
Re: New project: camera color profile calculation
« Reply #19 on: 27 / January / 2008, 16:45:59 »
ArtDen

I took a quick look into this matrix in CIE xy color space, and positions of primaries are
(hope I didn't make some typing mistake writing DngSetmatrix parameters)

Red:    0.84,  0.18
Green:  0.46,  2.25
Blue:   0.13, -0.04

Generally, there's no much difference between profiles for different sensors in CIE xy space,
just sensors with smaller pixels are less sensitive to color, so primaries should be
slightly further from white point. Biggest difference is intensity of each primary color,
affecting white balance

If we look to daylight ACR profile for G9 (similar pixel size), positions of primaries are

Red:    0.65,  0.26
Green:  0.26,  0.98
Blue:   0.03, -0.22

As you can see, in your profile, green primary is obviously way too far from white point. Red is also too far (although not as much as green) and slightly too low. On the other side, blue is too close to WB

 

Related Topics