AcademySoftwareFoundation / rawtoaces

RAW to ACES Utility
141 stars 47 forks source link

Added Sigma SD1 Spectral Dataset #73

Closed agentirons closed 7 years ago

agentirons commented 7 years ago

Created a new .json file for the Sigma SD1 using the data from https://spectralestimation.wordpress.com/data.

The original data was of the shape 400, 680, 10, so I used a simple average to interpolate numbers for the 5nm increments and extrapolated the rates of decrease for the increments past the end of either side of the dataset.

I'm confident that the numbers are reasonably correct since all three channels drop to nearly zero at 400 and 680 anyway, but found that the rawtoaces software is unable to correctly convert this camera's Foveon Merrill sensor data. It does produce an image, just with psychedelic colors.

Adobe doesn't offer any support for this camera, so current processor choices seem to be Sigma Photo Pro, Iridient Developer, and possibly https://github.com/Kalpanika/x3f. Might be worth looking into Kalpanika's source to add support to rawtoaces.

Test images are available here: http://www.imaging-resource.com/PRODS/SD1/SD1THMB.HTM

KelSolaar commented 7 years ago

@agentirons : There are very specific recommendations on how to interpolate/extrapolate spectral data by CIE and ASTM. Let me get back to you with a few things and a procedure to perform interpolation accordingly.

KelSolaar commented 7 years ago

What follows are recommendations from CIE 167:2005:

Interpolation

Uniformly Spaced Independent Variable

image

Non-Uniformly Spaced Independent Variable

image

Extrapolation

image

Implementation

Colour implements the necessary algorithms for that and we actually also ship the Sigma SD1 data you have given. As a result, performing the necessary shape alignement is done as follows (Sprague (1880) interpolation + constant extrapolation here):

import numpy as np
from pprint import pprint

import colour

np.set_printoptions(formatter={'float': '{:0.13f}'.format})

s = colour.CAMERAS_RGB_SPECTRAL_SENSITIVITIES['Sigma SDMerill (NPL)'].clone()
s.align(colour.SpectralShape(380, 780, 5))

pprint(list(s.__iter__()))

Which yields the following output:

[(380.0, array([0.0056210744061, 0.0063280975126, 0.1621594241331])),
 (385.0, array([0.0056210744061, 0.0063280975126, 0.1621594241331])),
 (390.0, array([0.0056210744061, 0.0063280975126, 0.1621594241331])),
 (395.0, array([0.0056210744061, 0.0063280975126, 0.1621594241331])),
 (400.0, array([0.0056210744061, 0.0063280975126, 0.1621594241331])),
 (405.0, array([-0.0032700368303, 0.0078442533301, 0.2250353173349])),
 (410.0, array([0.0065033562451, 0.0097618045959, 0.2854983780463])),
 (415.0, array([0.0442283819610, 0.0131806655017, 0.3420658516161])),
 (420.0, array([0.0740791128914, 0.0252717700826, 0.3969043106090])),
 (425.0, array([0.0648965887945, 0.0511196177435, 0.4523066568906])),
 (430.0, array([0.0430229594629, 0.0837511858531, 0.5083102431718])),
 (435.0, array([0.0365119103882, 0.1177841176125, 0.5660109443506])),
 (440.0, array([0.0345095256225, 0.1437038197436, 0.6221184724695])),
 (445.0, array([0.0277755773805, 0.1499994509449, 0.6705963584656])),
 (450.0, array([0.0188915672343, 0.1836116893088, 0.7374213624577])),
 (455.0, array([0.0087091842944, 0.2908959273186, 0.8487572445276])),
 (460.0, array([0.0073110769968, 0.4090947800995, 0.9453803667014])),
 (465.0, array([0.0255319264136, 0.4749186195486, 0.9681955435635])),
 (470.0, array([0.0454991512310, 0.5159556408618, 0.9644149477028])),
 (475.0, array([0.0482549214709, 0.5601470746419, 0.9825808584722])),
 (480.0, array([0.0567675292111, 0.6012066466271, 1.0000000000000])),
 (485.0, array([0.0939903669557, 0.6358346290067, 0.9958859733900])),
 (490.0, array([0.1341959206592, 0.6703167998014, 0.9859802118845])),
 (495.0, array([0.1525425415604, 0.7092286996166, 0.9839327960640])),
 (500.0, array([0.1647526899784, 0.7525874715348, 0.9834026635753])),
 (505.0, array([0.1854871971303, 0.7997156914408, 0.9782595610813])),
 (510.0, array([0.2171264197864, 0.8438138436894, 0.9696921956707])),
 (515.0, array([0.2633216096660, 0.8785396570588, 0.9589265516683])),
 (520.0, array([0.3064834383582, 0.9015172455881, 0.9428081740208])),
 (525.0, array([0.3271741563823, 0.9102517532524, 0.9184303066263])),
 (530.0, array([0.3498457961489, 0.9197503066877, 0.8966427991807])),
 (535.0, array([0.3997744611751, 0.9456251404787, 0.8879120041536])),
 (540.0, array([0.4437425813326, 0.9679942905216, 0.8844459022004])),
 (545.0, array([0.4493050712078, 0.9672868230961, 0.8785909874648])),
 (550.0, array([0.4448886052813, 0.9572523106404, 0.8679189907160])),
 (555.0, array([0.4592810217596, 0.9510358717196, 0.8493389158543])),
 (560.0, array([0.4789757567470, 0.9520479186005, 0.8337567958491])),
 (565.0, array([0.4909632258899, 0.9644813612734, 0.8326564021678])),
 (570.0, array([0.5095029148107, 0.9762801445840, 0.8320414024057])),
 (575.0, array([0.5467826345353, 0.9738631672683, 0.8175566893965])),
 (580.0, array([0.5926290937853, 0.9725862438896, 0.8005495638478])),
 (585.0, array([0.6382726163130, 0.9881375121443, 0.7919209358203])),
 (590.0, array([0.6738332756070, 1.0000000000000, 0.7828951247465])),
 (595.0, array([0.6878419872290, 0.9881898311277, 0.7656981723603])),
 (600.0, array([0.7140377148811, 0.9694845275778, 0.7394695300719])),
 (605.0, array([0.7874464018679, 0.9607253897964, 0.7037118594951])),
 (610.0, array([0.8600076131150, 0.9544131912485, 0.6671864017499])),
 (615.0, array([0.8823124202958, 0.9431240656721, 0.6382091164523])),
 (620.0, array([0.8981030284957, 0.9333543589092, 0.6204362780682])),
 (625.0, array([0.9501811624820, 0.9299677091611, 0.6167230389669])),
 (630.0, array([1.0000000000000, 0.9257140683364, 0.6111608787696])),
 (635.0, array([1.0034835332372, 0.9081891683204, 0.5840987018028])),
 (640.0, array([0.9949421331125, 0.8848643954150, 0.5517355619571])),
 (645.0, array([1.0177594613772, 0.8716170685359, 0.5357897232403])),
 (650.0, array([0.9208512773614, 0.7616518474162, 0.4653883174452])),
 (655.0, array([0.5598719814695, 0.4526713639944, 0.2726189404614])),
 (660.0, array([0.1814331163143, 0.1405243705715, 0.0796190783672])),
 (665.0, array([0.0238842174801, 0.0145743920235, 0.0039086825328])),
 (670.0, array([0.0063097879537, 0.0041436721582, 0.0005924444611])),
 (675.0, array([0.0048726008643, 0.0034135547051, 0.0030414341659])),
 (680.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (685.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (690.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (695.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (700.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (705.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (710.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (715.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (720.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (725.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (730.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (735.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (740.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (745.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (750.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (755.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (760.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (765.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (770.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (775.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048])),
 (780.0, array([0.0052887438317, 0.0018319895817, 0.0046856368048]))]

Retrieving the values should be even simpler, by calling colour.TriSpectralPowerDistribution.items method but I noticed it is broken (and not even unit tested) so you need latest develop branch.

References

KelSolaar commented 7 years ago

@aforsythe, @miaoqi : I think we should document how to generate the spectral dataset, i.e. make a writeup of the above ^

agentirons commented 7 years ago

Thanks for the useful information, @KelSolaar! I revised the dataset using the list you gave and tested with the latest ampas version of rawtoaces. It still results in bizarre colors, presumably because of the Foveon sensor.

@aforsythe You could merge in the .json file now that it has correct data, or I can close the pull request until the unusual sensor is accounted for.

aforsythe commented 7 years ago

@agentirons I'd prefer not to merge if the spec sens is giving strange results. Do you have examples? I just want to make sure that it's not another bug that we are just attributing to the foveon.

agentirons commented 7 years ago
screen shot 2017-06-27 at 14 03 08

Sample was pulled from the RAW files on this page: https://www.dpreview.com/reviews/sigmasd1/14

aforsythe commented 7 years ago

The spec sens looks pretty weird. It might be due to the measurement methodology or to the physics of the foveon sensor. Either way, it's not working when we try to calculate the IDT matrix.

alex@Alexs-MacBook-Pro-Retina:~/Source/rawtoaces/build (sigma)$ rawtoaces -v -v /Users/alex/Downloads/SDIM0045.X3F 

Starting rawtoaces ...
Processing /Users/alex/Downloads/SDIM0045.X3F ...
The camera has been identified as a Sigma SD1 ...
White Balance method is 0 - Using white balance factors from file metadata ...
IDT matrix calculation method is 0 - Calculating IDT matrix using camera spec sens ...
Regressing IDT matrix coefficients ...
Ceres Solver Report: Iterations: 14, Initial cost: 1.098822e+05, Final cost: 2.052954e+04, Termination: CONVERGENCE
The IDT matrix is ...
   1.949722 -3.498626 2.548903
   -0.943338 0.974112 0.969225
   3.264764 -11.956353 9.691590
Applying IDT Matrix ...
The final white balance coefficients are ...
   1.000000   1.000000   1.000000
Writing ACES file to /Users/alex/Downloads/SDIM0045_aces.exr ...
Finished

sd1_spec_sens

I would have expected --mat-method 2 to possibly work, but that seems pretty broken as well.

rawtoaces --mat-method 2 -v -v /Users/alex/Downloads/SDIM0045.X3F 

Starting rawtoaces ...
Processing /Users/alex/Downloads/SDIM0045.X3F ...
The camera has been identified as a Sigma SD1 ...
White Balance method is 0 - Using white balance factors from file metadata ...
IDT matrix calculation method is 2 - Calculating IDT matrix using adobe coeffs included in libraw ...
The IDT matrix is ...
   0.501001, -0.198205, -0.043080
   0.482498, 0.066853, 0.018251
   0.378752, 0.305971, 0.339542
The final white balance coefficients are ...
   1.000000   1.000000   1.000000
Writing ACES file to /Users/alex/Downloads/SDIM0045_aces.exr ...
Finished

I'm not sure if it's worth tracking down.

agentirons commented 7 years ago

I doubt it would be worth it until the project is farther along since it's such a niche camera, but the above info about proper extrapolation is certainly useful. I'll close the pull request.

KelSolaar commented 7 years ago

@aforsythe : I can add the interpolation/extrapolation information to the Wiki.

aforsythe commented 7 years ago

@KelSolaar That would be awesome ... it's still pretty stubby ... I started to move things from the README but got distracted before I was able to finish.