Skip to content

Commit

Permalink
Add fallback permutedims method to handle AbstractArrays
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Apr 6, 2016
1 parent 01801c6 commit 856a94c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,8 @@ end

permutedims{S<:AbstractString}(img::AbstractImage, pstr::Union{Vector{S}, Tuple{Vararg{S}}}, spatialprops::Vector = spatialproperties(img)) = permutedims(img, dimindexes(img, pstr...), spatialprops)

permutedims(A::AbstractArray, p) = permutedims(convert(Array, A), p)

function permutation_canonical(img)
assert2d(img)
p = spatialpermutation(spatialorder(Matrix), img)
Expand Down
9 changes: 9 additions & 0 deletions test/overlays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,13 @@ facts("Overlay") do
@fact isa(ovr, Images.Image) --> true
@fact abs(ovr[1, 2] - RGB{Float32}(a[1, 2], b[1, 2], a[1, 2])) --> roughly(0, atol=1e-5)
end

context("permutation") do
L1 = convert(Image{Gray}, rand(Float32, 10,10))
L2 = convert(Image{Gray}, rand(Float32, 10,10))
L3 = convert(Image{Gray}, rand(Float32, 10,10))
overlay = OverlayImage((L1, L2, L3), (colorant"red", colorant"blue", colorant"green"), ((0,1),(0,1),(0,1)))
permutedims(overlay, [2,1])
permutedims(data(overlay), [2,1])
end
end

0 comments on commit 856a94c

Please sign in to comment.