diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-09-23 21:57:45 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-09-23 21:57:45 +0200 |
| commit | 4154609e5de76bc8858d3f86e0af09ba2700c488 (patch) | |
| tree | 853583f99e97895a51db57d0e66672672d20c2f9 /src/util | |
| parent | Fix conversion of Y value (diff) | |
| download | blind-4154609e5de76bc8858d3f86e0af09ba2700c488.tar.gz blind-4154609e5de76bc8858d3f86e0af09ba2700c488.tar.bz2 blind-4154609e5de76bc8858d3f86e0af09ba2700c488.tar.xz | |
Fix colour distortion
This matrices are not convert to or from the proper YUV colour space both
rather the ones used in videos. srgb_to_yuv was created by converting the
image [sRGB(100%, 0, 0); sRGB(0, 100%, 0); sRGB(0, 0, 100%)] to YUV with
FFmpeg and transposing the matrix. yuv_to_srgb is the inversion of that
matrix, the values in the first column should all be 1 but are not due to
rounding/truncation error.
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/colour.h | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/src/util/colour.h b/src/util/colour.h index 5d1a249..f332c00 100644 --- a/src/util/colour.h +++ b/src/util/colour.h @@ -57,24 +57,26 @@ SRGB_DECODE(float, _f, f) MATRIX_MULTIPLY_FUNCTION(FUNCTION_BASE##_f, float, __VA_ARGS__) MATRIX_MULTIPLY_FUNCTIONS(yuv_to_srgb, - 1, - 0.00028328010485821202317155420580263580632163211703, - 1.14070449590558520291949662350816652178764343261719, - 1, - -0.39630886669497211727275498560629785060882568359375, - -0.58107364288228224857846271333983168005943298339844, - 1, - 2.03990003507541306504435851820744574069976806640625, - 0.00017179031692307700847528739718228507626918144524) + 0.99983946058747896756813133833929896354675292968750, + -0.00111314629257774910797706979792565107345581054688, + 1.59561960249794831945280293439282104372978210449219, + 0.99983946058762285247212275862693786621093750000000, + -0.39124374513994553126394748687744140625000000000000, + -0.81304201036561862814266987697919830679893493652344, + 0.99983946058757433572594663928612135350704193115234, + 2.01741786772377817982260239659808576107025146484375, + 0.00115819721926166407932612401054939255118370056152) MATRIX_MULTIPLY_FUNCTIONS(srgb_to_yuv, - 0.299, 0.587, 0.114, - -0.14662756598240470062854967636667424812912940979004, - -0.28771586836102963635752871596196200698614120483398, - 0.43434343434343436474165400795754976570606231689453, - 0.61456892577224520035628074765554629266262054443359, - -0.51452282157676354490405401520547457039356231689453, - -0.10004610419548178035231700278018251992762088775635) + 0.29906158567044888174635275390755850821733474731445, + 0.58707985442089483107963587826816365122795104980469, + 0.11401912509812317519930502385250292718410491943359, + -0.14846813725490196067546833091910229995846748352051, + -0.29074754901960786490633381617954000830650329589844, + 0.43921568627450979782622653146972879767417907714844, + 0.43921568627450979782622653146972879767417907714844, + -0.36807598039215688734415721228288020938634872436523, + -0.07113970588235293823764493481576209887862205505371) MATRIX_MULTIPLY_FUNCTIONS(ciexyz_to_srgb, 3.240446254647737500675930277794, @@ -99,26 +101,26 @@ MATRIX_MULTIPLY_FUNCTIONS(srgb_to_ciexyz, 0.950302838552371742508739771438) MATRIX_MULTIPLY_FUNCTIONS(scaled_yuv_to_ciexyz, - 0.00001450325106667098632156481796684488472237717360 / 0.8552986953536278, - 0.00000345586790639342739093228633329157872822179343, - 0.00000400923398630552893485111398685916128670214675, - 0.00001525902189669641837040624243737596543724066578 / 0.8552986953536278, - -0.00000207722814409390653614547427030512238843584782, - -0.00000263898607692305410302407824019166326934282552, - 0.00001661446153041708825425643025752719950105529279 / 0.8552986953536278, - 0.00002885925752619118069149627137104374696718878113, - -0.00000071781086875769179526501342566979779746816348) + 0.00001450092272326647052454150210731853576362482272 / 0.8552986953536278, + 0.00000341281577174185336742326911385614351956974133, + 0.00000560936853511406815494611324823814868523186306, + 0.00001525657222228693664302541510569000138275441714 / 0.8552986953536278, + -0.00000205124661398017884712786061685019234346327721, + -0.00000369297336083484072815404791745308443751127925, + 0.00001661179425452522781048517175328527173405745998 / 0.8552986953536278, + 0.00002854205077959434113873959937279778387164697051, + -0.00000099119265445913120730111588868593841539222922) MATRIX_MULTIPLY_FUNCTIONS(ciexyz_to_scaled_yuv, - 26625.38231027395886485464870929718017578125 * 0.8552986953536278, - 40524.0090949436053051613271236419677734375 * 0.8552986953536278, - -271.5313105642117079696618020534515380859375 * 0.8552986953536278, - -11278.3751445417292416095733642578125, - -26409.91773157499847002327442169189453125, - 34100.5706543184860493056476116180419921875, - 162829.60100012840121053159236907958984375, - -123829.313212639070115983486175537109375, - -28411.65702312920984695665538311004638671875) + 26633.45812403910895227454602718353271484375 * 0.8552986953536278, + 40527.367131481194519437849521636962890625 * 0.8552986953536278, + -272.0008243176007454167120158672332763671875 * 0.8552986953536278, + -11458.90154486896426533348858356475830078125, + -26662.3801805758339469321072101593017578125, + 34490.0235254608633113093674182891845703125, + 116394.099928013441967777907848358154296875, + -88546.58492295184987597167491912841796875, + -20281.0410136536011123098433017730712890625) #undef MATRIX_MULTIPLY_FUNCTIONS #undef MATRIX_MULTIPLY_FUNCTION |
