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

Different data structures for load in mac-os and linux #693

Closed
kirnap opened this issue Dec 25, 2017 · 4 comments
Closed

Different data structures for load in mac-os and linux #693

kirnap opened this issue Dec 25, 2017 · 4 comments

Comments

@kirnap
Copy link

kirnap commented Dec 25, 2017

When I load an image from the same source I got different data types in mac and linux, Namely,
Mac version:

julia> arr = load(img);
julia> typeof(arr)
Array{ColorTypes.RGB4{FixedPointNumbers.Normed{UInt8,8}},2}

Linux version:

julia> arr = load(img);
julia> typeof(arr)
Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}

That difference creates a problem in permutedims function. Here is an example:

julia> typeof(c1)
ImageCore.ChannelView{FixedPointNumbers.Normed{UInt8,8},3,Array{ColorTypes.RGB4{FixedPointNumbers.Normed{UInt8,8}},2}}
julia> permutedims(c1, (3,2,1))
ERROR: DimensionMismatch("new array has 224 color channels, must have 3")
Stacktrace:
 [1] check_ncolorchan(::Array{ColorTypes.RGB4{FixedPointNumbers.Normed{UInt8,8}},2}, ::Tuple{Int64,Int64,Int64}) at /Users/omer/.julia/v0.6/ImageCore/src/colorchannels.jl:356
 [2] similar(::ImageCore.ChannelView{FixedPointNumbers.Normed{UInt8,8},3,Array{ColorTypes.RGB4{FixedPointNumbers.Normed{UInt8,8}},2}}, ::Type{FixedPointNumbers.Normed{UInt8,8}}, ::Tuple{Int64,Int64,Int64}) at /Users/omer/.julia/v0.6/ImageCore/src/colorchannels.jl:117
 [3] permutedims(::ImageCore.ChannelView{FixedPointNumbers.Normed{UInt8,8},3,Array{ColorTypes.RGB4{FixedPointNumbers.Normed{UInt8,8}},2}}, ::Tuple{Int64,Int64,Int64}) at ./permuteddimsarray.jl:116

here is my ad-hoc solution...

macfix = convert(Array{FixedPointNumbers.Normed{UInt8,8},3},  c1);
julia> permutedims(macfix, (3,2,1)); # works perfectly fine
@timholy
Copy link
Member

timholy commented Dec 26, 2017

The different structures are a consequence of what the underlying C libraries return.

The issue about permutedims is definitely "our" problem, and it's a really awful bug. Same as JuliaImages/ImageCore.jl#48. I have a rewrite for 0.7 here that should fix this, and if you're brave you could test it.

Fixing this on 0.6 is unfortunately a breaking change, and consequently I'm inclined to leave it like it is and do all my breaking with the upgrade to julia 0.7.

@rsrock
Copy link
Collaborator

rsrock commented Dec 26, 2017

Ugh, RGB4 vs RGB again. Will #52 affect QuartzImageIO when it lands? I should make note of that.

@timholy
Copy link
Member

timholy commented Dec 27, 2017

I posted a much longer explanation of what's happening in JuliaImages/ImageCore.jl#52. The bottom line is that if you were formerly using reinterpret, you're likely to have to change it to reinterpretc. If you were using colorview, then I'd guess there will be no code changes required.

If your tests explicitly tested the type of object returned from load operations, you'll likely have to change those. That was actually the most annoying part of JuliaImages/ImageCore.jl#52, I had written a lot of such tests that I later came to regret. I switched most of them to just checking the eltype and dimensions.

@johnnychen94
Copy link
Member

johnnychen94 commented Jan 1, 2020

I haven't observed any similar issues since Julia v1.0, so I guess this issue is already fixed and thus become outdated?

@timholy timholy closed this as completed Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants