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

More generic restrict support on various arrays with offsets #12

Open
johnnychen94 opened this issue Aug 19, 2021 · 0 comments
Open

More generic restrict support on various arrays with offsets #12

johnnychen94 opened this issue Aug 19, 2021 · 0 comments

Comments

@johnnychen94
Copy link
Member

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

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

1 participant