ampas / idt-calculator

ACES Input Device Transform Calculator Apps
Other
10 stars 3 forks source link

PR: Improve *CLF* generation consistency, fix incorrect white-balance computation and a few minor improvements. #76

Closed KelSolaar closed 7 months ago

KelSolaar commented 9 months ago

This PR improves CLF generation consistency and addresses #75.

Output for the P2013-001 Generator:

<?xml version="1.0" encoding="UTF-8"?>
<ProcessList compCLFversion="3" id="None" name="d21 to ACES2065-1">
  <InputDescriptor>d21</InputDescriptor>
  <OutputDescriptor>ACES2065-1</OutputDescriptor>
  <Info>
    <AcademyIDTCalculator>
      <Application>Academy Input Device Transform (IDT) Calculator - P-2013-001 - 0.1.0</Application>
      <Url>http://127.0.0.1:8050/apps/idt_calculator_p_2013_001</Url>
      <Date>Feb 27, 2024 07:44:29</Date>
      <ACEStransformID>None</ACEStransformID>
      <ACESuserName>None</ACESuserName>
      <CameraMake>arri</CameraMake>
      <CameraModel>d21</CameraModel>
      <ExposureNormalisationFactor>1</ExposureNormalisationFactor>
      <SensitivitiesData>{380: [ 0.0001882050,  0.0000859000,  0.0000958000], 385: [ 0.0004402220,  0.0001661180,  0.0002587340], 390: [ 0.0015615910,  0.0004632100,  0.0011814660], 395: [ 0.0062188580,  0.0013148640,  0.0068810150], 400: [ 0.0222467340,  0.0036962760,  0.0319377330], 405: [ 0.0491205110,  0.0080560900,  0.0879885150], 410: [ 0.1028129470,  0.0172416310,  0.2162103010], 415: [ 0.1054678010,  0.0219539910,  0.2769182360], 420: [ 0.1173526630,  0.0287314550,  0.3840082950], 425: [ 0.1084897740,  0.0364389010,  0.4983081080], 430: [ 0.0784943470,  0.0374733110,  0.4859330570], 435: [ 0.0654292700,  0.0477630090,  0.6184892350], 440: [ 0.0512666200,  0.0579896580,  0.6965586240], 445: [ 0.0383008540,  0.0632723910,  0.7117941570], 450: [ 0.0360883710,  0.0784519720,  0.8215406250], 455: [ 0.0380763060,  0.0997300240,  0.9182860660], 460: [ 0.0368943650,  0.1120977670,  0.8186156120], 465: [ 0.0443959440,  0.1560131740,  0.9071030550], 470: [ 0.0559186820,  0.2175013040,  1.0000000000], 475: [ 0.0603071760,  0.2384344930,  0.8648004700], 480: [ 0.0667790150,  0.2696707970,  0.8780827230], 485: [ 0.0745051070,  0.3001018120,  0.8743037690], 490: [ 0.0756297800,  0.2907372550,  0.7046740360], 495: [ 0.0857911030,  0.3283306420,  0.6281439970], 500: [ 0.1089432090,  0.4246660040,  0.5888167840], 505: [ 0.1380998670,  0.5231351730,  0.5130828550], 510: [ 0.1687363960,  0.5916978680,  0.4362529150], 515: [ 0.2206676590,  0.7425217190,  0.3922304220], 520: [ 0.2686621050,  0.8322071870,  0.3435403620], 525: [ 0.3215601630,  0.9121622970,  0.3126758610], 530: [ 0.3767168200,  0.9764930820,  0.3041092320], 535: [ 0.4107771940,  0.9735079730,  0.2922406580], 540: [ 0.4218784010,  1.0000000000,  0.2911649170], 545: [ 0.3889935080,  0.9312444610,  0.2695982080], 550: [ 0.3541546080,  0.8893566520,  0.2483121010], 555: [ 0.3428334400,  0.7626614730,  0.2132865790], 560: [ 0.3807257190,  0.6939213440,  0.1942952750], 565: [ 0.4698855630,  0.5991218000,  0.1705972480], 570: [ 0.5994078620,  0.5303155310,  0.1550558260], 575: [ 0.7138213260,  0.4180381910,  0.1317383000], 580: [ 0.8081331600,  0.3400432940,  0.1160478870], 585: [ 0.9399759540,  0.2767600700,  0.1049545780], 590: [ 1.0000000000,  0.2178678850,  0.0932580380], 595: [ 0.9560642450,  0.1550625720,  0.0765564660], 600: [ 0.8947040870,  0.1153798100,  0.0646415720], 605: [ 0.7677429020,  0.0891030080,  0.0536238860], 610: [ 0.7987771510,  0.0830041120,  0.0520992770], 615: [ 0.7631115090,  0.0759738250,  0.0490984200], 620: [ 0.6825579240,  0.0675510410,  0.0446773370], 625: [ 0.5611666300,  0.0565718320,  0.0382092000], 630: [ 0.4366807810,  0.0454376650,  0.0317137160], 635: [ 0.4147819370,  0.0424875080,  0.0307812110], 640: [ 0.3809634280,  0.0391227800,  0.0297866970], 645: [ 0.3054066390,  0.0323389650,  0.0263855780], 650: [ 0.2600127510,  0.0283427750,  0.0244832700], 655: [ 0.1910332960,  0.0220015420,  0.0206465690], 660: [ 0.1411719090,  0.0171519070,  0.0174806350], 665: [ 0.1223961060,  0.0152800500,  0.0158814820], 670: [ 0.1022997120,  0.0134439240,  0.0141446200], 675: [ 0.0785509600,  0.0113487930,  0.0119652070], 680: [ 0.0604741440,  0.0093998740,  0.0094742740], 685: [ 0.0416850470,  0.0071851440,  0.0069978070], 690: [ 0.0281235630,  0.0053516530,  0.0051829910], 695: [ 0.0220396100,  0.0044734240,  0.0041689450], 700: [ 0.0174821650,  0.0037642790,  0.0033875940], 705: [ 0.0123574130,  0.0028655980,  0.0025077490], 710: [ 0.0087219690,  0.0019994410,  0.0017147270], 715: [ 0.0064629050,  0.0014381070,  0.0012333060], 720: [ 0.0045470500,  0.0010494240,  0.0009185750], 725: [ 0.0029335790,  0.0006955830,  0.0005876960], 730: [ 0.0021189200,  0.0005334030,  0.0004364940], 735: [ 0.0014990020,  0.0003942150,  0.0003150970], 740: [ 0.0010226870,  0.0002930590,  0.0002384670], 745: [ 0.0006818530,  0.0002119260,  0.0001682690], 750: [ 0.0005616130,  0.0002025390,  0.0001706320], 755: [ 0.0003848390,  0.0001256870,  0.0000894000], 760: [ 0.0002865970,  0.0001047740,  0.0000692000], 765: [ 0.0002691690,  0.0001388870,  0.0001260570], 770: [ 0.0001630580,  0.0000647000,  0.0000457000], 775: [ 0.0001490650,  0.0000726000,  0.0000584000], 780: [ 0.0000371000,  0.0000000000,  0.0000027000]}</SensitivitiesData>
      <IlluminantName>Daylight</IlluminantName>
      <IlluminantData>{300: 0.024299999999999999, 305: 1.0479000000000001, 310: 2.0714999999999999, 315: 6.6477500000000012, 320: 11.224000000000002, 325: 15.935499999999998, 330: 20.646999999999998, 335: 22.265799999999999, 340: 23.884599999999995, 345: 25.850999999999996, 350: 27.817399999999992, 355: 29.219000000000001, 360: 30.6206, 365: 32.464400000000005, 370: 34.308199999999999, 375: 33.445849999999986, 380: 32.583499999999994, 385: 35.335449999999994, 390: 38.087399999999995, 395: 49.51809999999999, 400: 60.948799999999991, 405: 64.751149999999996, 410: 68.5535, 415: 70.065299999999979, 420: 71.577100000000002, 425: 69.745599999999996, 430: 67.914099999999991, 435: 76.759699999999995, 440: 85.6053, 445: 91.799000000000007, 450: 97.992699999999999, 455: 99.228049999999996, 460: 100.46339999999999, 465: 100.18835, 470: 99.913299999999992, 475: 101.32629999999999, 480: 102.73929999999999, 485: 100.40860000000001, 490: 98.077899999999985, 495: 99.378950000000003, 500: 100.67999999999999, 505: 100.68769999999999, 510: 100.69540000000001, 515: 100.34100000000001, 520: 99.986599999999996, 525: 102.09805, 530: 104.20949999999999, 535: 103.15575, 540: 102.102, 545: 102.53494999999999, 550: 102.9679, 555: 101.48395000000001, 560: 100.0, 565: 98.608199999999997, 570: 97.216400000000007, 575: 97.48245, 580: 97.748499999999993, 585: 94.590099999999993, 590: 91.431699999999992, 595: 92.925550000000001, 600: 94.419399999999996, 605: 94.779800000000009, 610: 95.140199999999993, 615: 94.680299999999988, 620: 94.220400000000012, 625: 92.334049999999991, 630: 90.447699999999998, 635: 91.388800000000003, 640: 92.329899999999995, 645: 90.592000000000013, 650: 88.854100000000003, 655: 89.585650000000001, 660: 90.3172, 665: 92.133399999999995, 670: 93.949600000000004, 675: 91.952999999999989, 680: 89.956400000000002, 685: 84.816499999999991, 690: 79.676600000000008, 695: 81.258150000000001, 700: 82.839699999999993, 705: 83.8416, 710: 84.843499999999992, 715: 77.539249999999996, 720: 70.234999999999999, 725: 74.76809999999999, 730: 79.301199999999994, 735: 82.147099999999995, 740: 84.992999999999995, 745: 78.436700000000002, 750: 71.880400000000009, 755: 62.3369, 760: 52.793399999999998, 765: 64.360100000000003, 770: 75.9268, 775: 73.872199999999992, 780: 71.817599999999999, 785: 72.376300000000001, 790: 72.935000000000002, 795: 70.141149999999996, 800: 67.34729999999999, 805: 63.036900000000003, 810: 58.726500000000001, 815: 61.8596, 820: 64.992699999999999, 825: 66.649349999999998, 830: 68.305999999999997}</IlluminantData>
      <RGBDisplayColourspace>sRGB</RGBDisplayColourspace>
      <TrainingData>Kodak - 190 Patches</TrainingData>
      <ChromaticAdaptationTransform>CAT02</ChromaticAdaptationTransform>
      <OptimisationSpace>Oklab</OptimisationSpace>
      <SensitivitiesInterpolator>Sprague (1880)</SensitivitiesInterpolator>
      <IlluminantInterpolator>Linear</IlluminantInterpolator>
    </AcademyIDTCalculator>
  </Info>
  <Matrix inBitDepth="32f" outBitDepth="32f">
    <Description>White balance multipliers *b*.</Description>
    <Array dim="3 3">
1.0236437669204403 0.0 0.0
0.0 1.0842161514912503 0.0
0.0 0.0 1.0</Array>
  </Matrix>
  <Range inBitDepth="32f" outBitDepth="32f">
    <maxInValue>1</maxInValue>
    <maxOutValue>1</maxOutValue>
  </Range>
  <Matrix inBitDepth="32f" outBitDepth="32f">
    <Description>Exposure factor *k* that results in a nominally "18% gray" object in the scene producing ACES values [0.18, 0.18, 0.18].</Description>
    <Array dim="3 3">
1
0
0
0
1
0
0
0
1</Array>
  </Matrix>
  <Matrix inBitDepth="32f" outBitDepth="32f">
    <Description>*Input Device Transform* (IDT) matrix *B*.</Description>
    <Array dim="3 3">
0.9078404547262984 -0.05881513891716161 0.15097468419086324
-0.001167339891442895 1.1427167151233908 -0.14154937523194788
-0.06637191579322219 -0.41301211827016837 1.4793840340633906</Array>
  </Matrix>
</ProcessList>

Output for the Prosumer Camera generator, note how the Range node is removed here:

<?xml version="1.0" encoding="UTF-8"?>
<ProcessList compCLFversion="3" id="None" name="None">
  <InputDescriptor>Synthetic colour-science</InputDescriptor>
  <OutputDescriptor>ACES2065-1</OutputDescriptor>
  <Info>
    <Archive>
      <CameraMake>Synthetic</CameraMake>
      <CameraModel>colour-science</CameraModel>
      <Iso>100.0</Iso>
      <Temperature>6500.0</Temperature>
      <AdditionalCameraSettings>None</AdditionalCameraSettings>
      <LightingSetupDescription>D65</LightingSetupDescription>
      <DebayeringPlatform>None</DebayeringPlatform>
      <DebayeringSettings>None</DebayeringSettings>
      <EncodingColourspace>None</EncodingColourspace>
      <AcesTransformId>None</AcesTransformId>
      <AcesUserName>None</AcesUserName>
    </Archive>
    <AcademyIDTCalculator>
      <Application>Academy Input Device Transform (IDT) Calculator - Prosumer Camera - 0.1.0</Application>
      <Url>http://127.0.0.1:8050/apps/idt_calculator_prosumer_camera</Url>
      <Date>Feb 27, 2024 07:39:47</Date>
      <RGBDisplayColourspace>sRGB</RGBDisplayColourspace>
      <IlluminantName>D60</IlluminantName>
      <IlluminantData>{300: 0.0293, 305: 1.2899, 310: 2.5505, 315: 9.0412499999999998, 320: 15.532, 325: 21.966749999999998, 330: 28.401499999999999, 335: 29.958349999999996, 340: 31.515199999999993, 345: 33.784249999999993, 350: 36.053299999999993, 355: 37.231000000000002, 360: 38.408700000000003, 365: 40.673299999999998, 370: 42.937899999999999, 375: 42.088699999999989, 380: 41.239499999999992, 385: 43.844649999999994, 390: 46.449799999999996, 395: 59.301949999999998, 400: 72.154099999999985, 405: 76.222049999999996, 410: 80.289999999999992, 415: 81.534099999999995, 420: 82.778199999999998, 425: 80.177449999999993, 430: 77.576700000000002, 435: 86.598399999999998, 440: 95.620100000000008, 445: 101.76224999999999, 450: 107.9044, 455: 108.71109999999999, 460: 109.51779999999999, 465: 108.62295, 470: 107.7281, 475: 108.69110000000001, 480: 109.6541, 485: 106.6692, 490: 103.68429999999999, 495: 104.4494, 500: 105.21449999999999, 505: 104.81489999999999, 510: 104.4153, 515: 103.46975, 520: 102.52420000000001, 525: 104.29085000000001, 530: 106.0575, 535: 104.68549999999999, 540: 103.31349999999999, 545: 103.42665, 550: 103.53980000000001, 555: 101.76989999999999, 560: 100.0, 565: 98.375900000000001, 570: 96.751799999999989, 575: 96.731899999999996, 580: 96.712000000000003, 585: 93.295199999999994, 590: 89.878399999999999, 595: 90.9071, 600: 91.9358, 605: 91.975850000000008, 610: 92.015900000000002, 615: 91.284099999999995, 620: 90.552300000000002, 625: 88.488850000000014, 630: 86.425399999999996, 635: 86.933099999999996, 640: 87.440799999999996, 645: 85.631, 650: 83.821200000000005, 655: 84.180300000000003, 660: 84.539400000000001, 665: 85.911799999999999, 670: 87.284199999999998, 675: 85.272999999999996, 680: 83.261799999999994, 685: 78.628749999999997, 690: 73.995699999999999, 695: 75.204800000000006, 700: 76.413899999999998, 705: 77.643449999999987, 710: 78.873000000000005, 715: 72.098499999999987, 720: 65.323999999999998, 725: 69.635199999999998, 730: 73.946400000000011, 735: 76.652699999999996, 740: 79.358999999999995, 745: 73.262649999999994, 750: 67.166299999999993, 755: 58.165050000000001, 760: 49.163800000000002, 765: 59.950200000000002, 770: 70.736599999999996, 775: 68.878900000000002, 780: 67.021200000000007, 785: 67.522600000000011, 790: 68.024000000000001, 795: 65.439549999999997, 800: 62.855099999999993, 805: 58.865049999999997, 810: 54.875, 815: 57.786200000000001, 820: 60.697400000000002, 825: 62.226949999999995, 830: 63.756500000000003}</IlluminantData>
      <ChromaticAdaptationTransform>CAT02</ChromaticAdaptationTransform>
      <OptimisationSpace>Oklab</OptimisationSpace>
      <IlluminantInterpolator>Linear</IlluminantInterpolator>
      <DecodingMethod>Median</DecodingMethod>
      <EVRange>-1 0 1</EVRange>
      <GreyCardReflectance>0.18 0.18 0.18</GreyCardReflectance>
      <LUTSize>1024</LUTSize>
      <LUTSmoothing>32</LUTSmoothing>
      <DeltaE>0.883817649765</DeltaE>
    </AcademyIDTCalculator>
  </Info>
  <LUT1D inBitDepth="32f" outBitDepth="32f" interpolation="linear">
    <Description>Linearisation *LUT1D*.</Description>
    <Array dim="1024 1">
-0.02050747417403873
-0.02029945816371605
[...]
59.774862130220114
60.29589377334592
60.819062230653024</Array>
  </LUT1D>
  <Matrix inBitDepth="32f" outBitDepth="32f">
    <Description>White balance multipliers *b*.</Description>
    <Array dim="3 3">
1.0055519023504624 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0166625747650604</Array>
  </Matrix>
  <Matrix inBitDepth="32f" outBitDepth="32f">
    <Description>Exposure factor *k* that results in a nominally "18% gray" object in the scene producing ACES values [0.18, 0.18, 0.18].</Description>
    <Array dim="3 3">
0.9274460737730231
0.0
0.0
0.0
0.9274460737730231
0.0
0.0
0.0
0.9274460737730231</Array>
  </Matrix>
  <Matrix inBitDepth="32f" outBitDepth="32f">
    <Description>*Input Device Transform* (IDT) matrix *B*.</Description>
    <Array dim="3 3">
0.7425274107219285 0.14657048398327693 0.1109021052947945
0.024858938643951726 1.0063652994152812 -0.03122423805923291
-0.10912822538712623 -0.0652427913810057 1.174371016768132</Array>
  </Matrix>
</ProcessList>

There are questions about whether the clamp nodes are required.

The white-balance computation has also been fixed, the main issue is that the multipliers weren't applied to the samples before computing the IDT, resulting in a correction "doubling".

I also changed the way the cache is working which should fix some issues if the archive passed has the same name.