-
Notifications
You must be signed in to change notification settings - Fork 50
Adds support for specifying kernels using StaticArrays #254
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -997,6 +997,25 @@ expand(inds::Indices, kernel) = expand(inds, calculate_padding(kernel)) | |
expand(inds::Indices, pad::Indices) = firsttype(map_copytail(expand, inds, pad)) | ||
expand(ind::AbstractUnitRange, pad::AbstractUnitRange) = typeof(ind)(first(ind)+first(pad):last(ind)+last(pad)) | ||
expand(ind::Base.OneTo, pad::AbstractUnitRange) = expand(UnitRange(ind), pad) | ||
expand(ind::SOneTo{T₁}, pad::AbstractUnitRange) where {T₁} = represent_unit_range_with_SOneTo(ind, pad) | ||
expand(ind::OffsetArrays.IdOffsetRange{T₁, SOneTo{T₂}}, pad::AbstractUnitRange) where {T₁, T₂} = determine_offset_with_SOneTo(ind, pad) | ||
|
||
function represent_unit_range_with_SOneTo(ind::SOneTo{T₁}, pad::AbstractUnitRange) where {T₁} | ||
lo = first(ind)+first(pad) | ||
hi = last(ind)+last(pad) | ||
interval = 1:length(lo:hi) | ||
T = typeof(T₁) | ||
I = typeof(SOneTo(length(interval))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unfortunately a type-unstable patch: IIUC, unless the image itself is also a SMatrix, we can't get a static The solution to support static array inputs might be converting it back to normal array and unit ranges. |
||
return OffsetArrays.IdOffsetRange{T, I}(interval, lo - 1) | ||
end | ||
|
||
function determine_offset_with_SOneTo(ind::OffsetArrays.IdOffsetRange{T₁, SOneTo{T₂}}, pad::AbstractUnitRange) where {T₁, T₂} | ||
lo = first(ind)+first(pad) | ||
hi = last(ind)+last(pad) | ||
interval = 1:length(lo:hi) | ||
I = typeof(SOneTo(length(interval))) | ||
return OffsetArrays.IdOffsetRange{T₁, I}(interval, lo - 1) | ||
end | ||
|
||
""" | ||
shrink(inds::Indices, kernel) | ||
|
Uh oh!
There was an error while loading. Please reload this page.