Skip to content

Commit 9ce17bd

Browse files
authored
use OffsetArrays.centered (#214)
1 parent 8f2ad22 commit 9ce17bd

File tree

3 files changed

+6
-30
lines changed

3 files changed

+6
-30
lines changed

Project.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
1212
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
1313
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1414
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
15-
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
15+
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1616
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1717
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1818
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
@@ -25,9 +25,8 @@ DataStructures = "0.17.7, 0.18"
2525
FFTViews = "0.3"
2626
FFTW = "0.3, 1"
2727
ImageCore = "0.9"
28-
ImageMetadata = "0.9"
29-
OffsetArrays = "1.1"
30-
Requires = "0.5, 1.0"
28+
OffsetArrays = "1.9"
29+
Reexport = "1.1"
3130
StaticArrays = "0.10, 0.11, 0.12, 1.0"
3231
TiledIteration = "0.2, 0.3"
3332
julia = "1"

src/ImageFiltering.jl

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ using ImageCore.MappedArrays
88
using Statistics, LinearAlgebra
99
using Base: Indices, tail, fill_to_length, @pure, depwarn, @propagate_inbounds
1010
using OffsetArrays: IdentityUnitRange # using the one in OffsetArrays makes this work with multiple Julia versions
11-
using Requires
1211
using SparseArrays # only needed to fix an ambiguity in borderarray
12+
using Reexport
13+
14+
@reexport using OffsetArrays: centered # this method once lived here
1315

1416
export Kernel, KernelFactors,
1517
Pad, Fill, Inner, NA, NoPad,
@@ -97,13 +99,6 @@ function __init__()
9799
# @eval using DummyAF
98100
# end
99101
pop!(LOAD_PATH)
100-
@require AxisArrays="39de3d68-74b9-583c-8d2d-e117c070f3a9" begin
101-
centered(ax::AxisArrays.Axis{name}) where name = AxisArrays.Axis{name}(centered(ax.val))
102-
centered(a::AxisArrays.AxisArray) = AxisArrays.AxisArray(centered(a.data), centered.(AxisArrays.axes(a)))
103-
end
104-
@require ImageMetadata="bc367c6b-8a6b-528e-b4bd-a4b897500b49" begin
105-
centered(a::ImageMetadata.ImageMeta) = ImageMetadata.ImageMeta(centered(ImageMetadata.arraydata(a)), ImageMetadata.properties(a))
106-
end
107102
end
108103

109104
if Base.VERSION >= v"1.4.2"

src/utils.jl

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
"""
2-
shiftedkernel = centered(kernel)
3-
4-
Shift the origin-of-coordinates to the center of `kernel`.
5-
The center-element of `kernel` will be accessed by `shiftedkernel[0, 0, ...]`.
6-
7-
This function makes it easy to supply kernels using regular Arrays,
8-
and provides compatibility with other languages that do not support
9-
arbitrary axes.
10-
11-
See also: [`imfilter`](@ref).
12-
"""
13-
function centered(A::AbstractArray)
14-
offsetted = first.(axes(A)) .- 1
15-
total_offsets = .-((size(A) .+ 1 ) 2)
16-
OffsetArray(A, total_offsets .- offsetted)
17-
end
18-
191
"""
202
kernfft = freqkernel([T::Type], kern, sz=size(kern); rfft=false)
213

0 commit comments

Comments
 (0)