/* vim: set syntax=javascript: DO NOT EDIT THIS FILE! All changes made here will be lost on software update. If you want to add custom values or change existing ones, create a "camconst.json" file next to your personal "options" file. Its values will then override and/or complete the ones of this file. If you add values for your own camera, consider sharing them with the community for everyone's benefit. You can do so via our forum or GitHub page: - https://discuss.pixls.us/c/software/rawtherapee - https://github.com/Beep6581/RawTherapee/issues Value priority: 1. If you set the dcraw matrix in your user camconst.json file for a camera entry which already exists in RT's file (same camera, same model), your values will replace RT's ones. 2. If you set the black level values in your user camconst.json file for a camera entry which already exists in RT's file, your values will replace RT's ones, even if RT's ones are more complete and/or detailed. You might want to copy/paste RT's levels first (if provided) to your user's file and complete/modify them. 3. Same for the white levels, independent of the black levels. This file is in JSON format and contains camera constants which RawTherapee uses when parsing raw files. Raw files themselves unfortunately do not contain all information needed for making a raw conversion. Typically color response information and black/white levels are missing. That's why this file is needed. This file is read once during startup, so if the file is updated you need to restart RawTherapee in order for changes to take effect. The file is not intended for modification by the casual user, but advanced users can add missing camera information to this file. If you do so, please report using the links above so that we can incorporate your changes for everyone's benefit. RawTherapee uses dcraw as the raw format parser. dcraw contains hard-coded camera constants, but not for all cameras, and the values are not always accurate. For example dcraw only supports one white level, while some cameras have different white levels per channel and per ISO. If a camera is not listed in this file the constants from dcraw will be used. If listed here this information will override the constants in dcraw (if any). Partial information is supported. For example if the raw file itself contains a color matrix then there is no need to enter it here. A camera whose black level is measured on special pixels in the raw file should only have white levels here. And so forth. Examples: { // Make and model separated with single space, must match make and model as provided by dcraw (case-insensitive): "make_model": "ManufacturerA ModelB", // Some Panasonic and Canon DSLRs (of the lower category, such as Canon 550D) exist/ under alternate naming in // various marketplaces (EOS 550D, EOS Rebel T2i, EOS Kiss X4). // For new models that are still not supported by the dcraw version used in current RT, we have to fill all the // alternate names or else RT will not recognize the alternate model names. // For models supported by dcraw, filling the alternate names is simply desired (for better user info). // The format of multiple naming is to write all names in brackets i.e instead of // "make_model": "Canon EOS 550D", // type // "make_model": [ "Canon EOS 550D", "Canon EOS Rebel T2i", "Canon EOS Kiss X4" ], // ColorMatrix with CIE Standard Illuminant D65, in dcraw format: "dcraw_matrix": [ 7530, -1942, -255, -4318, 11390, 3362, -926, 1694, 7649 ], // Black level (or black offset if a base black is already extracted from Exif by dcraw, see Panasonic, // recent Nikon). For some rare cases where dcraw detects wrong black level we need to correct it with // absolute black i.e one that is not added up the detected. For this job we have to define "black" as // 65535+desired_black. For example to correct a wrongly detected black level of 9 instead of the correct // 600 we define "black": 66135, i.e. 65535+600, and white level same for all colors at all ISOs. "ranges": { "black": 10, "white": 1000 }, // Crop away masked sensor borders, 10 pixels left, 20 pixels top, resulting image width/height 4000x3000. // Instead of width/height you can write a negative number which specifies how much of right/bottom border // that should be removed but keep in mind that sometimes after converting to DNG the borders are already // cropped so the "negative number" way is not totally safe. "raw_crop": [ 10, 20, 4000, 3000 ], // Almost same as MaskedAreas DNG tag, used for black level measuring. Here up to two areas can be defined // by tetrads of numbers: "masked_areas": [ 51, 2, 3804, 156, 51, 5794, 3804, 5792 ], // Two tetrads define two areas. The difference vs "raw_crop" is the meaning of the numbers which here are // expressing the absolute distance (in pixels) of each side of each rectangular "masked area" from the top // and left side of the sensor // - the first number is the distance of the top edge from the sensor's top // - the second is the distance of the left side from the sensor's left // - the third is the distance of the bottom side from the sensor's top // - the fourth is the distance of the right side from the sensor's left // It is useful after detecting the masked areas, to not fully use these areas but leave a border of 2-4 pixels // instead, to take care of possible light leaks from the light sensing area to the optically black (masked) // area or sensor imperfections at the outer borders. // list of indices of the rows with on-sensor PDAF pixels, for cameras that have such features. The indices here form a pattern that is repeated for the whole height of the sensor. The values are relative to the "pdaf_offset" value (see below) "pdaf_pattern" : [ 0,12,36,54,72,90,114,126,144,162,180,204,216,240,252,270,294,306,324,342,366,384,396,414,432,450,474,492,504,522,540,564,576,594,606,630 ], // index of the first row of the PDAF pattern in the sensor (0 is the topmost row). Allowed to be negative for convenience (this means that the first repetition of the pattern doesn't start from the first row) "pdaf_offset" : 3 }, { "make_model": "ManufacturerA ModelB", "dcraw_matrix": [ 7530,-1942,-255,-4318,11390,3362,-926,1694,7649 ], // Black and white levels per ISO per channel. // In this example there are only two ISOs - normally the list should be more populated. // When RawTherapee asks for black/white levels for a specific ISO the closest match is picked. "ranges": { "black": [ { "iso": 100, "levels": 10 }, // here only one level, same level for all channels { "iso": 3200, "levels": [ 50, 60, 50 ] } // 3 levels, G2 same as G1 ], "white": [ { "iso": 100, "levels": [ 10000, 11000, 10000, 12000 ] }, // 4 levels, G1 and G2 different { "iso": 3200, "levels": [ 11000, 11000, 10000, 12000 ] } ] } } How to Measure White Levels: ---------------------------- dcraw provides the default values used by RawTherapee, but often provides too high white levels, and only provides a single value regardless of color channel, ISO or aperture. If you open an image with a large clipped area and that is rendered in a pink/magenta color rather than white it usually means that the white level constant is too high. You can fix this by adjusting white-point correction in the Raw tab > Raw White Points, or permanently fix it by measuring and providing a more exact white level in camconst.json so RawTherapee gets to know from start where the camera actually clips. Providing a complete and detailed white-level profile can be a quite large and complicated effort. As an alternative you can provide a simpler profile.We suggest one of the following alternatives in rising difficulty (and generally diminishing return): A) Provide a single white-level value measured on the native ISO (base ISO). For many cameras this will actually be complete information, those that don't vary on channel, ISO or aperture. B) Check through all ISOs and if there are differences in white level provide an array with white level per ISO. C) In addition to ISO, check for aperture scaling and add that. D) In addition to ISO and aperture scaling check for color channel differences and add that. Doing A is often better than nothing, as dcraw's default is often too high.B can also be worthwhile for some cameras (or else you'll get pink highlights for some ISOs), while C and D can generally be seen as fine-tuning. Here follows a guide how to measure white levels (clipping levels): Shoot with your camera into a bright light source, such as a lamp, and make sure the shutter speed is long enough to get overexposure (we want clipping!). Preferably overexpose lightly, say 1 or 2 stops if you can. The reason for this is that some cameras with fuzzy white levels may look less fuzzy than they actually are if over-exposure is heavy. Use f/5.6 or smaller aperture (=larger f-number) to avoid any raw scaling the camera might have for large apertures. Open the file in a raw analyzer such as RawDigger and check the pixel values for the clipped areas (if you are using RawDigger, make sure you have disabled"subtract black" in preferences or else sample values can be wrong). In this stage we always look at white level before black level subtraction! White levels can be different on color channel (R, G1, B, G2, note the two greens, most often both green channels have the same white level though) and vary depending on ISO setting, so if you want to provide a complete profile make one shoot for each ISO (even 1/3 steps, so yes it can be quite a lot of pictures to shoot and check). In addition, many cameras scale the raw values for large apertures. It's generally not that important to cover this, but if you want to extract most out of the camera you should cover this too. Then you need to shoot with a wide aperture lens (ideally the widest available from the manufacturer) and test each aperture (1/3 steps) from the widest (say f/1.2) until the camera stops scaling the raw values (usually f/2.8 or f/4.0). If the camera also have ISO scaling you need to shoot at these different ISOs to detect any differences in scaling, there can be a bit of variation. If you don't have access to the widest lens available for the system (say only an f/1.8 lens instead of an f/1.2) it can still be valuable to have the values down to what you can provide. Brands known to have models that have aperture scaling of white levels include Canon and Nikon. Note that if white levels are not scaled the camera may have raw scaling anyway (Sony for example), but as such scaling will not affect raw decoding we don't need to care about that. PROVIDE CONSERVATIVE VALUES. Most cameras have a little noise at the white level, and some can have a lot. In your raw analyzer, move around and look at the values in the clipped areas to get a sense of the variation, and/or look at the histogram. While it's common to with very little variation, say only +/-2 units, some can have +/-500 or more (some may have different variation depending on ISO). There can also be camera-to-camera variation. If the white level is set too high RawTherapee will not think the pixels are clipped and you can get discolored highlights (usually pink), this is what we want to avoid. If white level is set too low RawTherapee will clip early, ie you lose a little highlight detail, but the color is rendered correctly and highlight reconstruction can work properly, so this is not as bad. This is why we want conservative values. By conservative values we mean that if you see a white level of most often 15760 and occasionally 15759 (i.e. very small variation of white level which is a common case), you set the white level around 50-100 14-bit units below or 10-20 12-bit units. Say at 15700 in this example, or 4080 instead of 4095 for 12-bit raws. This way we get a little margin from noise and camera variation. Since sensor raw values are linear, you lose, for example, log2(1-50/15760) = -0.005 stops of detail, i.e. irrelevant. Thus it is better to provide RawTherapee with knowledge where the image clips rather than keeping that last 0.005 stop of highlight information and risking that clipping will not be detected properly. It is very usual for white level to be a bell distribution instead of a candle when the camera applies long exposure noise reduction (LENR) by subtracting a black frame and/or when the system is destabilized due to temperature. Some models have always a bell distribution at WL. If you have a fuzzy white level look at the linear histogram; you will probably see a normal/Gaussian distribution (bell shape) noise peak at clipping and probably also a peak at a hard raw data clip level usually at or close to a power of two - 1, such as 4095 or 16383. Then you pick a value just before the bell shape rises, i.e. to the left of the bell meaning that you cut away the whole fuzzy noise peak. If a little of the starting edge of the noise will be included it's not harmful, but 99% of it should be above. This would mean that it's better to measure white level on long exposure/high temp raws but since this if difficult and time consuming we choose to measure on normal raws and cover the abnormalities with the conservative WL values. A more detailed approach when we only have non-LENR measures is to subtract a value according to per ISO read noise. We can find data regarding read noise (stdev of Gaussian distribution) at http://www.photonstophotos.net/Charts/RN_ADU.htm . We find the per ISO tead_noise and subtract from the measured value 6*read_noise. This gives confidence that 99.5% of the bell is clipped out. If you have used Adobe's DNG Converter and analyzed it's output you may have noticed that it's very conservative regarding white levels, i.e. it cuts away quite a lot from the top. While we also recommend to be conservative, you can generally be a little bit less so than Adobe's DNG Converter. RawTherapee is meant to max out what you can get from your camera, and the white levels should mirror that, within reason. The aperture scaling feature is meant to raise the white level to not miss out on highlight detail when the camera has scaled the raw values (and thus raised white levels). Many cameras do this, but not all, and can only do it for lenses that report aperture to the camera (i.e. you see it in the Exif data). Providing proper aperture scaling values is a bit more advanced task, so if you are unsure we recommend to skip that part. Beware that the raw format may have a ceiling so that it clips scaled values, for example the Canon 5D mark II maxes out at 16383 which happens at f/1.8 for ISOs with the white level at 15750, but for ISO160 when the white level is 12800 it does not max out. If there is such a raw limit it must also be provided ("ranges":"white_max"). Usually you will not need a margin on white_max as it clips there as a result of an in-camera math operation. Note that aperture scaling can be quite small, for the 5D mark II it's only 0.2 stop down to f/1.2 and then it can be discussed if it's worthwhile to care. The "worst" cameras scale about 0.6 stops though, and then it's more valuable to compensate. If you skip aperture scaling RawTherapee will clip the files a little bit too early and you miss that last fraction of highlight detail, but you get no processing problems. Setting un-conservative scale factors can on the other hand cause a too high white level and break highlight processing, so be careful. Scaling can vary slightly depending on ISO (if white levels vary) so make sure to provide conservative scalings so regardless of ISO you don't get a too high white level. We recommend to keep a small margin here also white levels, i.e. 0.5% lower or so. For example if base (not conservative!) white level is 15750 and the scaled is 16221 we have a scaling factor of 16221/15750=1.0299 i.e. +2.9% we set the factor to 1.025 to keep a margin. The abnormal cases are already covered by setting conservative per ISO White levels. The scale factor you provide here is applied on the white level before black level subtraction (if any), i.e. directly on the white level value you provide in the camconst.json file. Black level (if provided) is not scaled. Please report to us if you come across a camera which scales black levels, then we can add that as an option. Usually the camera applies an offset to shift back the black level to the standard level after scaling. If RawTherapee doesn't find an entry for the aperture used in the image, it will pick the closest above, i.e. if the apertures 1.0 and 2.0 is in the table and the image has aperture 1.2, it will pick scaling for 2.0, even if 1.0 is the closer aperture. The reason for always checking the closest above is that we rather get a bit too low white level than too high, as discussed before. Some cameras have different white levels on different color channels. When this is the case the difference is often so small so you can just provide a single value instead, i.e. a conservative value based on the lowest clipping. What we know at the time of writing about different brands/models (not complete info): - Canon CR2: typically same clipping per channel, but significant variations on ISO and aperture. Maxes out at 16383, black level measured on masked black pixels, i.e. don't provide that. - Nikon NEF: sometimes different clipping per color (most often negligible though). Will do aperture and ISO scaling, but often to a lesser extent than Canon files, i.e. not as much to gain. - Sony ARW2: no scaling. Generally black level around 512, and white level 16350 and to be conservative say 16300. Note that some raw formats may go through a certain amount of pre-processing based on meta data, such as curve and levels adjustments and various calibrations. The Phase One IIQ is one example, and this means that if you look at the data in a raw analyzer such as RawDigger it may perform a different type of preprocessing than RawTherapee's loader does, and you may end up providing incompatible black/white levels. You can use RawTherapee for analysis too, it's safer as you are using it's own raw decoder but it's not as user-friendly: enable verbose mode in options so you get output on the console. When you load a file you will see a message of current black and white levels and if they came from dcraw or camconst.json. If you're adjusting an existing camconst.json value you can just read what it is in the file and not need to enable verbose output. Reset exposure sliders to neutral, and zoom in on a large clipped highlight. Move around the mouse pointer within, it should show stable 100% on R G B. If so, the white level is not too high, it could however be too low. To test that, go to the raw tab and adjust the "white point linear correction factor", reduce it until one of the channels is no longer 100%, and then increase in steps of 0.01 until all are 100 again. Usually you play around in the range 0.90 to 0.99, i.e. a very small adjustment. When you've found this factor you should apply it on the old white level to find a new larger one. As RT's "white point linear correction factor" work after black level subtraction and camconst.json want values without it we need to do some math: BL = black level (typically something near 0, 256, 512, 1024 or 2048 find it in the verbose output or if available in camconst.json) F = white point linear correction factor you just found out (typically in the range 0.90 to 0.99 if you need to increase white level, 1.01 to 1.10 if decrease) oldWL = old white level, found in verbose output or in camconst.json if available. newWL = BL + (oldWL - BL) / F Note that if black level is 0 which it is for many cameras, the formula simplifies to: new white level = oldWL / F. Here's an example from a Canon 1000D: black level is 256, old white level is 3651, white point correction factor becomes 0.90, then new white level is 256 + (3651 - 256) / 0.9 = 4028. If your camera have different black levels per channel use the one which yields the smallest white level (can be the largest or smallest, test!). This new white level you then enter in your camconst.json file. The same procedure can be used if the white level is too high, i.e. if you see pink highlights, then increase the correction factor above 1.0 until you just start seeing stable 100% on all channels, you use the same formula to calculate the new smaller white level. About black levels: ------------------- Unlike for white levels it's much more common that black levels can be derived from the format. Either it's simply 0 (typical for old Nikon cameras, newer Nikons (year 2013-14) have a BL at around 150 12-bit or 600/768 14-bit ), or it can be derived from masked pixels (typical for Canon cameras) or otherwise be extracted from some tag. Some formats have built-in subtraction information and are pre-processed by dcraw to end up at a black level of zero (Phase One's IIQ). For Panasonic cameras, the black level defined in camconst.json is the black level offset, which comes from BlackLevel3 + BlackLevel2. RawTherapee then reads the base black levels from Exif data (0x001c BlackLevelRed, 0x001d BlackLevelGreen and 0x001e BlackLevelBlue) and adds them to the offset. In all, you typically should not care about the black level in camconst.json, any information that can be derived from the raw file itself should not be specified in camconst.json! Sony's ARW2 is one of the few exceptions (with a single black level around 512, or 800 for RX10/100 models), but dcraw generally has good constants for these already. Currently we have chosen not to provide any guide how to measure black levels as we don't think it will be a common task (it's also more difficult to do than measure white levels). If you experience a black level issue it's more likely due to a format parsing bug which should be fixed in dcraw and/or RawTherapee's raw format parser. How does a black level issue look? If the image has a color cast and is possibly duller than normal it's likely that black levels are off. The color cast is typically stronger in darker colors but it can be hard to see, it's more often experienced as a cast over the whole image. Camera constants: ----------------- When adding camera constants please set a quality level so we know the status for future updates Quality A: complete information, no need to add more, to the best of our knowledge Quality B: not complete, but very little to gain from adding more Quality C: complementing with additional information would provide significant gain Quality X: unknown, i.e. we know too little about the camera properties to know if we have enough info. */ {"camera_constants": [ { // Quality C, corrections for frame size, black and white levels not declared properly "make_model": "Sigma SD9", "dcraw_matrix": [ 14996,-3468,-1425,5576,3642,972,1761,3773,3720 ], // experimental calculated from sun0.icc data "ranges": { "black": 0, "white": 16383 }, // black is already subtracted by dcraw, white copied from x3dump data "raw_crop": [ 20, 8, -18, -12 ] }, { // Quality C, corrections for frame size, black level not declared properly "make_model": "Sigma SD10", "dcraw_matrix": [ 12555,-1865,-1125,5093,4120,867,1929,3810,3507 ], // experimental calculated from .icc data "ranges": { "black": 0, "white": 16383 }, // black is already subtracted by dcraw, white copied from x3dump data //"raw_crop": [ 0, 0, -0, -0 ] "raw_crop": [ 20, 8, -18, -12 ] }, { // Quality C, corrections for frame size, black and white levels not declared properly "make_model": "Sigma SD14", "dcraw_matrix": [ 16411,-4764,-2383,8110,2603,-645,3135,3878,1984 ], // experimental inverted icc wp12 - build with BL=15 //"dcraw_matrix": [ 13804,-4156,-1896,6917,1909,-431,2768,2989,1741 ], // experimental inverted icc wp10 - build with BL=15 "ranges": { "black": 15, "white": 7000 }, "raw_crop": [ 18, 12, 2652, 1768 ] }, { // Quality C, correction for frame width "make_model": "Sigma SD1", "dcraw_matrix": [ 5270,42,-814,3737,5506,124,1112,9714,4510 ], // experimental from icm 1.04477,-0.74838,1.01617, -0.54028,2.52690,-3.83257, 0.54869,-0.69556,3.73746 "ranges": { "black": 16, "white": 4070 }, // BL is 16 or 31, should be measured at the horizontal black stripe at the top "raw_crop": [ 12, 52, -110, -8 ] }, { // Quality C, correction for frame width, color matrix investigated .. "make_model": "Sigma SD1 Merrill", "dcraw_matrix": [ 7211,-1577,-769,4996,3428,440,2717,7117,4699 ], // experimental inverted icc cloudy8140 d65 //"dcraw_matrix": [ 5666,139,-892,3780,5428,270,1366,9757,4526 ], // experimental inverted icc sunny8161 //"dcraw_matrix": [ 10288,-2449,-1718,8976,1868,-1608,7011,5039,-249 ], // experimental inverted icc tungsten8130 wp11 //"dcraw_matrix": [ 5864,679,-1491,2963,7635,-919,-640,13738,2790 ], // experimental inverted icc sunny8160 //"dcraw_matrix": [ 14032,-2231,-1016,-5263,14816,170,-112,183,9113 ], // hardcoded "ranges": { "black": 16, "white": 4070 }, // BL is 16 or 31, should be measured at the horizontal black stripe at the top "raw_crop": [ 12, 52, -110, -8 ] // for small size all numbers/2 }, { // Quality C, correction for frame width, color matrix measured on a DP1 sample .. "make_model": [ "Sigma DP1 Merrill", "Sigma DP2 Merrill", "Sigma DP3 Merrill" ], //"dcraw_matrix": [ 2149,1003,-530,-494,6073,344,-3935,10665,3608 ], // experimental, inverted icc DP1_Merrill_dpreview_daylight WP1.2 "dcraw_matrix": [ 2517,1175,-621,-587,7080,404,-4677,12402,4231 ], // experimental, inverted icc DP1_Merrill_dpreview_daylight WP1.4 "ranges": { "black": 16, "white": 4070 }, // BL is 16 or 31, should be measured at the horizontal black stripe at the bottom "raw_crop": [ 12, 0, -110, -62 ] // for small size all numbers/2 }, { // Quality C, only raw crop for now - see #3858 "make_model": "Sigma sd Quattro", "raw_crop": [ 200, 74, 5632, 3698 ] }