Skip to content

More generic restrict support on various arrays with offsets #12

Description

@johnnychen94

https://github.com/JuliaImages/ImageBase.jl/pull/4/files#r691967154

Ideally, we should not dispatch on array type OffsetArray in

function restrict(A::OffsetArray{T,N}, dim::Integer) where {T,N}
indsA = axes(A)
newinds = map(UnitRange, ntuple(i->i==dim ? restrict_indices(indsA[dim]) : indsA[i], Val(N)))
# By shifting it back to normal array, the internal for loop becomes faster because
# it requires less indexing computation
OffsetArray(restrict(A.parent, dim), newinds)
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions