Skip to content

Commit 8e1541e

Browse files
authored
Merge pull request #37 from JuliaImages/fbot/deps
Fix deprecations
2 parents 701df29 + 29da487 commit 8e1541e

File tree

9 files changed

+248
-264
lines changed

9 files changed

+248
-264
lines changed

src/ImageFiltering.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ using Base: Indices, tail, fill_to_length, @pure, depwarn
99

1010
export Kernel, KernelFactors, Pad, Fill, Inner, NA, NoPad, Algorithm, imfilter, imfilter!, mapwindow, imgradients, padarray, centered, kernelfactors, reflect
1111

12-
@compat FixedColorant{T<:Normed} = Colorant{T}
13-
@compat StaticOffsetArray{T,N,A<:StaticArray} = OffsetArray{T,N,A}
14-
@compat OffsetVector{T} = OffsetArray{T,1}
12+
FixedColorant{T<:Normed} = Colorant{T}
13+
StaticOffsetArray{T,N,A<:StaticArray} = OffsetArray{T,N,A}
14+
OffsetVector{T} = OffsetArray{T,1}
1515

1616
# Needed for type-stability
17-
function Base.transpose{T}(A::StaticOffsetArray{T,2})
17+
function Base.transpose(A::StaticOffsetArray{T,2}) where T
1818
inds1, inds2 = indices(A)
1919
OffsetArray(transpose(parent(A)), inds2, inds1)
2020
end
@@ -23,41 +23,41 @@ module Algorithm
2323
# deliberately don't export these, but it's expected that they
2424
# will be used as Algorithm.FFT(), etc.
2525
using Compat
26-
@compat abstract type Alg end
27-
"Filter using the Fast Fourier Transform" immutable FFT <: Alg end
28-
"Filter using a direct algorithm" immutable FIR <: Alg end
29-
"Cache-efficient filtering using tiles" immutable FIRTiled{N} <: Alg
26+
abstract type Alg end
27+
"Filter using the Fast Fourier Transform" struct FFT <: Alg end
28+
"Filter using a direct algorithm" struct FIR <: Alg end
29+
"Cache-efficient filtering using tiles" struct FIRTiled{N} <: Alg
3030
tilesize::Dims{N}
3131
end
32-
"Filter with an Infinite Impulse Response filter" immutable IIR <: Alg end
33-
"Filter with a cascade of mixed types (IIR, FIR)" immutable Mixed <: Alg end
32+
"Filter with an Infinite Impulse Response filter" struct IIR <: Alg end
33+
"Filter with a cascade of mixed types (IIR, FIR)" struct Mixed <: Alg end
3434

3535
FIRTiled() = FIRTiled(())
3636
end
3737
using .Algorithm: Alg, FFT, FIR, FIRTiled, IIR, Mixed
3838

39-
Alg{A<:Alg}(r::AbstractResource{A}) = r.settings
39+
Alg(r::AbstractResource{A}) where {A<:Alg} = r.settings
4040

4141
include("utils.jl")
4242
include("kernelfactors.jl")
4343
using .KernelFactors: TriggsSdika, IIRFilter, ReshapedOneD, iterdims, kernelfactors
4444

45-
@compat ReshapedVector{T,N,Npre,V<:AbstractVector} = ReshapedOneD{T,N,Npre,V}
46-
@compat ArrayType{T} = Union{AbstractArray{T}, ReshapedVector{T}}
47-
@compat ReshapedIIR{T,N,Npre,V<:IIRFilter} = ReshapedOneD{T,N,Npre,V}
48-
@compat AnyIIR{T} = Union{IIRFilter{T}, ReshapedIIR{T}}
49-
@compat ArrayLike{T} = Union{ArrayType{T}, AnyIIR{T}}
45+
ReshapedVector{T,N,Npre,V<:AbstractVector} = ReshapedOneD{T,N,Npre,V}
46+
ArrayType{T} = Union{AbstractArray{T}, ReshapedVector{T}}
47+
ReshapedIIR{T,N,Npre,V<:IIRFilter} = ReshapedOneD{T,N,Npre,V}
48+
AnyIIR{T} = Union{IIRFilter{T}, ReshapedIIR{T}}
49+
ArrayLike{T} = Union{ArrayType{T}, AnyIIR{T}}
5050

5151
include("kernel.jl")
5252
using .Kernel
5353
using .Kernel: Laplacian, reflect
5454

55-
@compat NDimKernel{N,K} = Union{AbstractArray{K,N},ReshapedOneD{K,N},Laplacian{N}}
55+
NDimKernel{N,K} = Union{AbstractArray{K,N},ReshapedOneD{K,N},Laplacian{N}}
5656

5757
include("border.jl")
5858

59-
@compat BorderSpec{T} = Union{Pad{0}, Fill{T,0}, Inner{0}}
60-
@compat BorderSpecNoNa{T} = Union{Pad{0}, Fill{T,0}, Inner{0}}
59+
BorderSpec{T} = Union{Pad{0}, Fill{T,0}, Inner{0}}
60+
BorderSpecNoNa{T} = Union{Pad{0}, Fill{T,0}, Inner{0}}
6161
const BorderSpecAny = Union{BorderSpec,NA,NoPad}
6262

6363
const ProcessedKernel = Tuple

src/border.jl

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
using OffsetArrays, CatIndices
44

5-
@compat abstract type AbstractBorder end
5+
abstract type AbstractBorder end
66

7-
immutable NoPad{T} <: AbstractBorder
7+
struct NoPad{T} <: AbstractBorder
88
border::T
99
end
1010
NoPad() = NoPad(nothing)
@@ -47,13 +47,13 @@ rather than
4747
4848
imfilter(img, kernel, Pad(:replicate))
4949
"""
50-
immutable Pad{N} <: AbstractBorder
50+
struct Pad{N} <: AbstractBorder
5151
style::Symbol
5252
lo::Dims{N} # number to extend by on the lower edge for each dimension
5353
hi::Dims{N} # number to extend by on the upper edge for each dimension
5454
end
5555

56-
(::Type{Pad{N}}){N}(style, lo::AbstractVector, hi::AbstractVector) =
56+
Pad{N}(style, lo::AbstractVector, hi::AbstractVector) where {N} =
5757
Pad{N}(style, (lo...), (hi...))
5858

5959
const valid_borders = ("replicate", "circular", "reflect", "symmetric")
@@ -92,8 +92,8 @@ Pad the input image by `lo` pixels at the lower edge, and `hi` pixels at the upp
9292
"""
9393
Pad(lo::Dims, hi::Dims) = Pad(:replicate, lo, hi)
9494
Pad(style::Symbol, lo::Tuple{}, hi::Tuple{}) = Pad{0}(style, lo, hi)
95-
Pad{N}(style::Symbol, lo::Dims{N}, hi::Tuple{}) = Pad(style, lo, ntuple(d->0,Val{N}))
96-
Pad{N}(style::Symbol, lo::Tuple{}, hi::Dims{N}) = Pad(style, ntuple(d->0,Val{N}), hi)
95+
Pad(style::Symbol, lo::Dims{N}, hi::Tuple{}) where {N} = Pad(style, lo, ntuple(d->0,Val{N}))
96+
Pad(style::Symbol, lo::Tuple{}, hi::Dims{N}) where {N} = Pad(style, ntuple(d->0,Val{N}), hi)
9797
Pad(style::Symbol, lo::AbstractVector{Int}, hi::AbstractVector{Int}) = Pad(style, (lo...,), (hi...,))
9898

9999
Pad(style::Symbol, inds::Indices) = Pad(style, map(lo,inds), map(hi,inds))
@@ -118,13 +118,13 @@ function padfft(indk::AbstractUnitRange, l::Integer)
118118
range(first(indk), nextprod([2,3], l+lk)-l+1)
119119
end
120120

121-
function padindices{_,N}(img::AbstractArray{_,N}, border::Pad)
121+
function padindices(img::AbstractArray{_,N}, border::Pad) where {_,N}
122122
throw(ArgumentError("$border lacks the proper padding sizes for an array with $(ndims(img)) dimensions"))
123123
end
124-
function padindices{_,N}(img::AbstractArray{_,N}, border::Pad{N})
124+
function padindices(img::AbstractArray{_,N}, border::Pad{N}) where {_,N}
125125
_padindices(border, border.lo, indices(img), border.hi)
126126
end
127-
function padindices{P<:Pad}(img::AbstractArray, ::Type{P})
127+
function padindices(img::AbstractArray, ::Type{P}) where P<:Pad
128128
throw(ArgumentError("must supply padding sizes to $P"))
129129
end
130130

@@ -144,15 +144,15 @@ add. `border` can be a `Pad`, `Fill`, or `Inner` object.
144144
Optionally provide the element type `T` of `imgpadded`.
145145
"""
146146
padarray(img::AbstractArray, border::Pad) = padarray(eltype(img), img, border)
147-
function padarray{T}(::Type{T}, img::AbstractArray, border::Pad)
147+
function padarray(::Type{T}, img::AbstractArray, border::Pad) where T
148148
inds = padindices(img, border)
149149
# like img[inds...] except that we can control the element type
150150
newinds = map(Base.indices1, inds)
151151
dest = similar(img, T, newinds)
152152
copydata!(dest, img, inds)
153153
end
154154

155-
padarray{P}(img, ::Type{P}) = img[padindices(img, P)...] # just to throw the nice error
155+
padarray(img, ::Type{P}) where {P} = img[padindices(img, P)...] # just to throw the nice error
156156

157157
function copydata!(dest, img, inds)
158158
isempty(inds) && return dest
@@ -175,7 +175,7 @@ function copydata!(dest::OffsetArray, img, inds::Tuple{Vararg{OffsetArray}})
175175
dest
176176
end
177177

178-
Base.ndims{N}(::Pad{N}) = N
178+
Base.ndims(::Pad{N}) where {N} = N
179179

180180
# Make these separate types because the dispatch almost surely needs to be different
181181
"""
@@ -188,7 +188,7 @@ Indicate that edges are to be discarded in filtering, only the interior of the r
188188
189189
imfilter(img, kernel, Inner())
190190
"""
191-
immutable Inner{N} <: AbstractBorder
191+
struct Inner{N} <: AbstractBorder
192192
lo::Dims{N}
193193
hi::Dims{N}
194194
end
@@ -210,20 +210,20 @@ As a consequence, filtering has the same behavior as
210210
`nanmean`. Indeed, invalid pixels in `img` can be marked as `NaN` and
211211
then they are effectively omitted from the filtered result.
212212
"""
213-
immutable NA{N} <: AbstractBorder
213+
struct NA{N} <: AbstractBorder
214214
lo::Dims{N}
215215
hi::Dims{N}
216216
end
217217

218218
for T in (:Inner, :NA)
219219
@eval begin
220220
(::Type{$T})(both::Int...) = $T(both, both)
221-
(::Type{$T}){N}(both::Dims{N}) = $T(both, both)
221+
(::Type{$T})(both::Dims{N}) where {N} = $T(both, both)
222222
(::Type{$T})(lo::Tuple{}, hi::Tuple{}) = $T{0}(lo, hi)
223-
(::Type{$T}){N}(lo::Dims{N}, hi::Tuple{}) = $T{N}(lo, ntuple(d->0,Val{N}))
224-
(::Type{$T}){N}(lo::Tuple{}, hi::Dims{N}) = $T{N}(ntuple(d->0,Val{N}), hi)
225-
(::Type{$T}){N}(inds::Indices{N}) = $T{N}(map(lo,inds), map(hi,inds))
226-
(::Type{$T{N}}){N}(lo::AbstractVector, hi::AbstractVector) = $T{N}((lo...,), (hi...,))
223+
(::Type{$T})(lo::Dims{N}, hi::Tuple{}) where {N} = $T{N}(lo, ntuple(d->0,Val{N}))
224+
(::Type{$T})(lo::Tuple{}, hi::Dims{N}) where {N} = $T{N}(ntuple(d->0,Val{N}), hi)
225+
(::Type{$T})(inds::Indices{N}) where {N} = $T{N}(map(lo,inds), map(hi,inds))
226+
(::Type{$T{N}})(lo::AbstractVector, hi::AbstractVector) where {N} = $T{N}((lo...,), (hi...,))
227227
(::Type{$T})(lo::AbstractVector, hi::AbstractVector) = $T((lo...,), (hi...,)) # not inferrable
228228

229229
(p::$T{0})(kernel, img, ::Alg) = p(kernel)
@@ -232,8 +232,8 @@ for T in (:Inner, :NA)
232232
end
233233

234234
padarray(img, border::Inner) = padarray(eltype(img), img, border)
235-
padarray{T}(::Type{T}, img::AbstractArray{T}, border::Inner) = copy(img)
236-
padarray{T}(::Type{T}, img::AbstractArray, border::Inner) = copy!(similar(Array{T}, indices(img)), img)
235+
padarray(::Type{T}, img::AbstractArray{T}, border::Inner) where {T} = copy(img)
236+
padarray(::Type{T}, img::AbstractArray, border::Inner) where {T} = copy!(similar(Array{T}, indices(img)), img)
237237

238238
"""
239239
Fill(val)
@@ -247,20 +247,20 @@ Optionally supply the extent of the padding, see `Pad`.
247247
248248
imfilter(img, kernel, Fill(zero(eltype(img))))
249249
"""
250-
immutable Fill{T,N} <: AbstractBorder
250+
struct Fill{T,N} <: AbstractBorder
251251
value::T
252252
lo::Dims{N}
253253
hi::Dims{N}
254254

255-
(::Type{Fill{T,N}}){T,N}(value::T) = new{T,N}(value)
256-
(::Type{Fill{T,N}}){T,N}(value::T, lo::Dims{N}, hi::Dims{N}) = new{T,N}(value, lo, hi)
255+
Fill{T,N}(value::T) where {T,N} = new{T,N}(value)
256+
Fill{T,N}(value::T, lo::Dims{N}, hi::Dims{N}) where {T,N} = new{T,N}(value, lo, hi)
257257
end
258258

259-
Fill{T}(value::T) = Fill{T,0}(value)
260-
Fill{T,N}(value::T, lo::Dims{N}, hi::Dims{N}) = Fill{T,N}(value, lo, hi)
261-
Fill{T,N}(value::T, both::Dims{N}) = Fill{T,N}(value, both, both)
259+
Fill(value::T) where {T} = Fill{T,0}(value)
260+
Fill(value::T, lo::Dims{N}, hi::Dims{N}) where {T,N} = Fill{T,N}(value, lo, hi)
261+
Fill(value::T, both::Dims{N}) where {T,N} = Fill{T,N}(value, both, both)
262262
Fill(value, lo::AbstractVector, hi::AbstractVector) = Fill(value, (lo...,), (hi...,))
263-
Fill{T,N}(value::T, inds::Base.Indices{N}) = Fill{T,N}(value, map(lo,inds), map(hi,inds))
263+
Fill(value::T, inds::Base.Indices{N}) where {T,N} = Fill{T,N}(value, map(lo,inds), map(hi,inds))
264264
Fill(value, kernel) = Fill(value, calculate_padding(kernel))
265265

266266
(p::Fill)(kernel) = Fill(p.value, kernel)
@@ -271,10 +271,10 @@ function (p::Fill)(kernel, img, ::FFT)
271271
Fill(p.value, newinds)
272272
end
273273

274-
function padarray{T}(::Type{T}, img::AbstractArray, border::Fill)
274+
function padarray(::Type{T}, img::AbstractArray, border::Fill) where T
275275
throw(ArgumentError("$border lacks the proper padding sizes for an array with $(ndims(img)) dimensions"))
276276
end
277-
function padarray{T,S,_,N}(::Type{T}, img::AbstractArray{S,N}, f::Fill{_,N})
277+
function padarray(::Type{T}, img::AbstractArray{S,N}, f::Fill{_,N}) where {T,S,_,N}
278278
A = similar(arraytype(img, T), map((l,r,h)->first(r)-l:last(r)+h, f.lo, indices(img), f.hi))
279279
try
280280
fill!(A, f.value)
@@ -365,12 +365,12 @@ accumulate_padding(inds::Indices) = inds
365365
modrange(x, r::AbstractUnitRange) = mod(x-first(r), length(r))+first(r)
366366
modrange(A::AbstractArray, r::AbstractUnitRange) = map(x->modrange(x, r), A)
367367

368-
arraytype{T}(A::AbstractArray, ::Type{T}) = Array{T} # fallback
368+
arraytype(A::AbstractArray, ::Type{T}) where {T} = Array{T} # fallback
369369
arraytype(A::BitArray, ::Type{Bool}) = BitArray
370370

371371
interior(A, kernel) = _interior(indices(A), indices(kernel))
372372
interior(A, factkernel::Tuple) = _interior(indices(A), accumulate_padding(indices(factkernel[1]), tail(factkernel)...))
373-
function _interior{N}(indsA::NTuple{N}, indsk)
373+
function _interior(indsA::NTuple{N}, indsk) where N
374374
indskN = fill_to_length(indsk, 0:0, Val{N})
375375
map(intersect, indsA, shrink(indsA, indsk))
376376
end
@@ -404,8 +404,8 @@ shrink(inds::Indices, pad::Indices) = firsttype(map_copytail(shrink, inds, pad))
404404
shrink(ind::AbstractUnitRange, pad::AbstractUnitRange) = oftype(ind, first(ind)-first(pad):last(ind)-last(pad))
405405
shrink(ind::Base.OneTo, pad::AbstractUnitRange) = shrink(UnitRange(ind), pad)
406406

407-
allocate_output{T}(::Type{T}, img, kernel, border) = similar(img, T)
408-
function allocate_output{T}(::Type{T}, img, kernel, ::Inner{0})
407+
allocate_output(::Type{T}, img, kernel, border) where {T} = similar(img, T)
408+
function allocate_output(::Type{T}, img, kernel, ::Inner{0}) where T
409409
inds = interior(img, kernel)
410410
similar(img, T, inds)
411411
end

0 commit comments

Comments
 (0)