-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with conversion testing #355
Comments
I think the values in "test_conversions.jld2" have much greater errors than By the way, is there any reason why "test_conversions.jld2" holds the |
Incidentally, although it does not matter in local environment, in the CI (i.e. Travis or AppVeyor), JLD2 (or CodecZlib) may lead to an increase of the build time. Is there any previous study on this? Edit: Edit2: Color3{Float64}[
RGB(0,0,0) RGB(1,0,0) RGB(0,1,0) RGB(0,0,1)
RGB(1,1,1) RGB(1,1,0) RGB(0,1,1) RGB(1,0,1)
XYZ(0.5,0.5,0.5) LMS(0.4,0.5,0.6) RGB(0.6,0.6,0.6) YIQ(0.5,0,0)
Lab(60,0,-20) Lab(50,-30,0) Lab(40,0,40) Lab(30,50,0)
Luv(25,-10,-10) Luv(75,60,60) YIQ(0.5,0.5,0) YCbCr(100,128,240)
] |
XYZ<-->(linear)sRGB transformation matrices can be calculated with the following method: function mat(wp::XYZ)
# Primaries in xyz (not XYZ)
prim_r = BigFloat[6400, 3300, 300] / 10000
prim_g = BigFloat[3000, 6000, 1000] / 10000
prim_b = BigFloat[1500, 600, 7900] / 10000
mat_prim = hcat(prim_r, prim_g, prim_b)
s = mat_prim^-1 * [wp.x, wp.y, wp.z]
mat_RGB2XYZ = mat_prim * Diagonal(s)
mat_XYZ2RGB = mat_RGB2XYZ^-1
(mat_RGB2XYZ, mat_XYZ2RGB)
end The sRGB's primaries are based on ITU-R Rec. BT.709. The original publication of sRGB (i.e. working draft of IEC 61966-2-1) uses the BT.709's D65 white point, which is defined (rounded) in xy space. However, IEC 61966-2-1 uses the D65 white point which is defined in XYZ space. The two white point definitions are slightly different. julia> wp_rec709 = convert(XYZ, xyY(BigFloat("0.3127"), BigFloat("0.3290"), 1));
julia> XYZ{Float64}(wp_rec709)
XYZ{Float64}(0.9504559270516717,1.0,1.0890577507598784)
julia> wp_d65 = XYZ{BigFloat}(BigFloat("0.95047"), 1, BigFloat("1.08883"));
julia> Colors.WP_D65
XYZ{Float64}(0.95047,1.0,1.08883)
julia> convert(xyY, Colors.WP_D65)
xyY{Float64}(0.3127266146810121,0.32902313032606195,1.0) Therefore, there are roughly two types of the transformation matrices. julia> rgb2xyz, xyz2rgb = mat(wp_rec709);
julia> show(IOContext(stdout, :compact=>false), "text/plain", Float64.(xyz2rgb))
3×3 Array{Float64,2}:
3.2409699419045213 -1.5373831775700935 -0.4986107602930033
-0.9692436362808798 1.8759675015077206 0.04155505740717561
0.05563007969699361 -0.20397695888897657 1.0569715142428786
julia> show(IOContext(stdout, :compact=>false), "text/plain", Float64.(rgb2xyz))
3×3 Array{Float64,2}:
0.4123907992659595 0.35758433938387796 0.1804807884018343
0.21263900587151036 0.7151686787677559 0.07219231536073371
0.01933081871559185 0.11919477979462599 0.9505321522496606 julia> rgb2xyz, xyz2rgb = mat(wp_d65);
julia> show(IOContext(stdout, :compact=>false), "text/plain", Float64.(xyz2rgb))
3×3 Array{Float64,2}:
3.2404541621141054 -1.5371385127977166 -0.4985314095560162
-0.9692660305051868 1.8760108454466942 0.04155601753034984
0.05564343095911469 -0.20402591351675387 1.0572251882231791
julia> show(IOContext(stdout, :compact=>false), "text/plain", Float64.(rgb2xyz))
3×3 Array{Float64,2}:
0.4124564390896921 0.357576077643909 0.18043748326639894
0.21267285140562248 0.715152155287818 0.07217499330655958
0.019333895582329317 0.119192025881303 0.9503040785363677 The conversion matrices in IEC 61966-2-1 are the truncated version of the latter. (To reduce errors, the truncation seems not so simple.) And now, let's see the Colors.jl's implementation. Lines 142 to 145 in 43d93ff
Lines 287 to 291 in 43d93ff
So, Colors.jl does not follow the IEC 61966-2-1's truncation. I think the digits come from |
I think that's correct. It's been so long I don't remember for sure, but I was able to find a comment here: #259 (comment). I would support transitioning to other strategies, I was just worried (partly because of the whole DIN* issue) that we could be wildly off base and wanted to make sure we were at least in the right ballpark. |
Remove duplicate test cases and Modify error evaluation methods (#355)
The two problems mentioned above were fixed. (Although Appveyor failed the build, it is not a coding mistake but a network problem.) |
The issue #368 took over this. |
While working on the issue #354, I reviewed the conversion tests and found two problems which are not essential in the discussion #354.
One is that there are duplicate test cases. For example,
@test typeof(c) == Cfrom{Tfrom}
is evaluated for eachCto{Tto}
.Colors.jl/test/conversion.jl
Lines 84 to 97 in d64fb1a
Unfortunately, the modification have almost no speedup effect. However, I think we should fix it because the number of duplicates is too large.
The other is that the accuracy tests are not fair.
Colors.jl/test/conversion.jl
Lines 232 to 238 in d64fb1a
For example, the
HSV
has three components: Hue in [0,360), Saturation in [0,1] and Value in [0,1].So, although the difference of weights between the components may be ignorable, the normalization with
mag
is unreasonable. Of course, the magnitude of the mantissa LSB depends on the magnitude of the value (i.e. exponent), but the tolerance1e-3
is enough larger forFloat64
.Then, I wrote new methods for the evaluation.:
(To my regret, they make the tests slightly slower.)
However, in some cases of the conversion to HSI or HSL, the tests failed where the tolerance is
1e-3
. (Needless to say, there is not any deep meaning in the number1e-3
)I suppose this is a problem with the transit (i.e. XYZ-->RGB), not HSL or HSI.
The text was updated successfully, but these errors were encountered: