I’m using Julia for a image processing program and I had to use the channelview command to acess the channels. But I’m wondering if there is any chance I can undo the command. What I want is J to be back to type Matrix{RGB{N0f8}}.
J = channelview(img)
 
             
            
              
            
           
          
            
              
                mkitti  
              
                  
                    January 21, 2024,  5:12pm
                   
                  2 
               
             
            
              Do you want Base.parent
julia> using ImageCore
julia> img = rand(RGB, 2,2)
2×2 Array{RGB{Float64},2} with eltype RGB{Float64}:
 RGB{Float64}(0.482138,0.987989,0.187547)  …  RGB{Float64}(0.670861,0.998297,0.294064)
 RGB{Float64}(0.238936,0.226647,0.553525)     RGB{Float64}(0.0945124,0.77229,0.942222)
julia> cv = channelview(img)
3×2×2 reinterpret(reshape, Float64, ::Array{RGB{Float64},2}) with eltype Float64:
[:, :, 1] =
 0.482138  0.238936
 0.987989  0.226647
 0.187547  0.553525
[:, :, 2] =
 0.670861  0.0945124
 0.998297  0.77229
 0.294064  0.942222
julia> parent(cv)
2×2 Array{RGB{Float64},2} with eltype RGB{Float64}:
 RGB{Float64}(0.482138,0.987989,0.187547)  …  RGB{Float64}(0.670861,0.998297,0.294064)
 RGB{Float64}(0.238936,0.226647,0.553525)     RGB{Float64}(0.0945124,0.77229,0.942222)
 
            
              
            
           
          
            
            
              The answer is colorview
(Sorry for replying to such an old thread, but I think that parent is a bit of a hack, so it shouldn’t be left as the only answer.)
             
            
              2 Likes