Skip to content
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 creating 10bit version of YCbCr #10

Closed
vchuravy opened this issue Sep 15, 2015 · 13 comments
Closed

Problems with creating 10bit version of YCbCr #10

vchuravy opened this issue Sep 15, 2015 · 13 comments
Labels
downstream Colors.jl, ColorVectorSpace.jl, etc.

Comments

@vchuravy
Copy link

A few of the types are only defined as

  YIQ{T<:FloatingPoint} <: Color{T,3
  YCbCr{T<:FloatingPoint} <: Color{T,3}

Would it be appropriate to change these type bounds to Fractional instead?

The idea is coming from #9 to define:

typealias YCbCr10 YCbCr{Ufixed10}
typealias Gray10 Gray{Ufixed10}

I can create a PR for doing this, but I don't know for which formats this would be appropriate and how to fix the tests.

julia> Pkg.test("ColorTypes")
INFO: Testing ColorTypes
ERROR: LoadError: test failed: ColorTypes.YCbCr{T<:AbstractFloat} == ColorTypes.YCbCr{T<:Union{AbstractFloat,FixedPointNumbers.FixedPoint}}
 in expression: color_type(A) == C
 in default_handler at ./test.jl:30
 in do_test at ./test.jl:53
 [inlined code] from /home/wallnuss/.julia/v0.4/ColorTypes/test/runtests.jl:109
 in anonymous at ./no file:0
while loading /home/wallnuss/.julia/v0.4/ColorTypes/test/runtests.jl, in expression starting on line 106
@timholy
Copy link
Member

timholy commented Sep 15, 2015

For anything where the "gamut" (the allowed space of values) fit in the proposed element type, it would definitely be good to broaden the bounds. I didn't take the time to figure out the proper gamut for all the color types; I did look into XYZ, and a few colors can generate XYZ values bigger than 1, so I left it FloatingPoint.

@timholy
Copy link
Member

timholy commented Sep 15, 2015

In general ColorTypes hasn't been exporting typealiases thus far, since they are easy to recreate in packages. But we could change that.

@vchuravy
Copy link
Author

I think we don't need a lot of different typealiases, what we might need though is something along the way of AbstractYCrCb to allow compact storage formats.

@vchuravy
Copy link
Author

So I think adding Fractional makes only sense for YIQ and YCbCr the other have different ranges for their components

@vchuravy
Copy link
Author

Other problems I am currently running into is that the correct_gamut and cnvt function in Colors are expecting 8bit values.

@timholy
Copy link
Member

timholy commented Sep 15, 2015

Clearly that will have to fixed. Feel free to try whatever fix works for your more general case.

@vchuravy
Copy link
Author

Is there currently any encoding of the range of a colour? Currently it seems that those values are hard-coded for conversion.

@timholy
Copy link
Member

timholy commented Sep 15, 2015

Yeah, the YIQ and YCbCr types are not "first class," they are just tacked on because I didn't want to completely ditch old methods like rgb2ntsc methods in Images. But I doubt anyone is using them for anything. Feel free to make whatever changes are necessary.

@vchuravy
Copy link
Author

Y'CrCb to RGB is a mess: http://www.fourcc.org/fccyvrgb.php

I would propose to only implement conversion for 8, 10 and 12 bit Y'CrCb as defined in [1] and [2]

[1] https://en.wikipedia.org/wiki/Rec._709
[2] https://en.wikipedia.org/wiki/Rec._2020

@timholy
Copy link
Member

timholy commented Sep 15, 2015

This might get easier when switching to FixedPoint because then magic numbers like 16 and 128 will presumably assume a more universal FixedPoint values like T(0.0625) and T(0.5), where T <: Fixed.

@timholy
Copy link
Member

timholy commented Sep 15, 2015

(After all, that's what those numbers really mean. Integer intensities definitely stink.)

In other words, I give my approval to change YCbCr so that rather than effectively being 8-bit like it is now, we use "normalized" YCbCr. I think that will make your life much easier.

@vchuravy
Copy link
Author

For further reference here are the actual parameters from the standards.

https://www.itu.int/rec/R-REC-BT.709-6-201506-I
https://www.itu.int/rec/R-REC-BT.2020-1-201406-I

@kimikage
Copy link
Collaborator

xref: JuliaGraphics/Colors.jl#453

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
downstream Colors.jl, ColorVectorSpace.jl, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants