Skip to content

Commit da9350e

Browse files
CompatHelper: bump compat for "ImageCore" to "0.9" (#213)
* CompatHelper: bump compat for "ImageCore" to "0.9" * upgrade to ImageCore 0.9 and remove direct dependency to ColorVectorSpace Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Johnny Chen <[email protected]>
1 parent 26cb4b8 commit da9350e

File tree

7 files changed

+30
-15
lines changed

7 files changed

+30
-15
lines changed

Project.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ version = "0.6.21"
55

66
[deps]
77
CatIndices = "aafaddc9-749c-510e-ac4f-586e18779b91"
8-
ColorVectorSpace = "c3611d14-8923-5661-9e6a-0046d554d3a4"
98
ComputationalResources = "ed09eef8-17a6-5b46-8889-db040fac31e3"
109
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
1110
FFTViews = "4f61f5a4-77b1-5117-aa51-3ab5ef4ef0cd"
@@ -21,12 +20,11 @@ TiledIteration = "06e1c1a7-607b-532d-9fad-de7d9aa2abac"
2120

2221
[compat]
2322
CatIndices = "0.2"
24-
ColorVectorSpace = "0.6, 0.7, 0.8, 0.9"
2523
ComputationalResources = "0.3"
2624
DataStructures = "0.17.7, 0.18"
2725
FFTViews = "0.3"
2826
FFTW = "0.3, 1"
29-
ImageCore = "0.8.1"
27+
ImageCore = "0.9"
3028
ImageMetadata = "0.9"
3129
OffsetArrays = "1.1"
3230
Requires = "0.5, 1.0"

src/ImageFiltering.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ using ImageCore, FFTViews, OffsetArrays, StaticArrays, ComputationalResources, T
66
# using FixedPointNumbers: Normed, N0f8 # reexported by ImageCore
77
using ImageCore.MappedArrays
88
using Statistics, LinearAlgebra
9-
using ColorVectorSpace # for filtering RGB arrays
109
using Base: Indices, tail, fill_to_length, @pure, depwarn, @propagate_inbounds
1110
using OffsetArrays: IdentityUnitRange # using the one in OffsetArrays makes this work with multiple Julia versions
1211
using Requires

test/2d.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using ImageFiltering, ImageCore, OffsetArrays, FFTViews, ColorVectorSpace, ComputationalResources
1+
using ImageFiltering, ImageCore, OffsetArrays, FFTViews, ComputationalResources
22
using LinearAlgebra
33
using Test
44
using ImageFiltering: IdentityUnitRange

test/compat.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# patch for ColorVectorSpace 0.9
2+
# for CVS < 0.9, we can just use the fallback solution in Distances
3+
if isdefined(ImageCore.ColorVectorSpace, :)
4+
# Because how abs2 calculated in color vector space is ambiguious, abs2(::RGB) is un-defined
5+
# since ColorVectorSpace 0.9
6+
# https://github.com/JuliaGraphics/ColorVectorSpace.jl/pull/131
7+
_abs2(c::Colorant) = mapreducec(abs2, +, 0, c)
8+
_abs2(x::Number) = abs2(x)
9+
10+
_abs(c::Colorant) = mapreducec(abs, +, 0, c)
11+
_abs(x::Number) = abs(x)
12+
else
13+
_abs2(c::Union{Colorant, Number}) = abs2(c)
14+
_abs(x::Number) = abs(x)
15+
end

test/gradient.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using ImageFiltering, ImageCore, ColorVectorSpace
1+
using ImageFiltering, ImageCore
22
using Test
33

44
@testset "gradient" begin
@@ -15,10 +15,10 @@ using Test
1515
Kernel.ando4, Kernel.ando5, Kernel.scharr, Kernel.bickley)
1616
gy, gx = @inferred(imgradients(img, kernelfunc, Inner()))
1717
for val in gy
18-
@test abs(val - ey) < 1e-4
18+
@test _abs(val - ey) < 1e-4
1919
end
2020
for val in gx
21-
@test abs(val - ex) < 1e-4
21+
@test _abs(val - ex) < 1e-4
2222
end
2323
gy, gx = imgradients(img, kernelfunc, Pad(:replicate))
2424
@test axes(gy) == axes(gx) == axes(img)
@@ -39,10 +39,10 @@ using Test
3939
ky, kx = fk()
4040
gy, gx = imfilter(img, ky, Inner()), imfilter(img, kx, Inner())
4141
for val in gy
42-
@test abs(val - ey) < 1e-4
42+
@test _abs(val - ey) < 1e-4
4343
end
4444
for val in gx
45-
@test abs(val - ex) < 1e-4
45+
@test _abs(val - ex) < 1e-4
4646
end
4747
end
4848
end
@@ -57,13 +57,13 @@ using Test
5757
Kernel.scharr, Kernel.bickley)
5858
gy, gx, gz = @inferred(imgradients(img, kernelfunc, Inner()))
5959
for val in gy
60-
@test abs(val - ey) < 1e-4
60+
@test _abs(val - ey) < 1e-4
6161
end
6262
for val in gx
63-
@test abs(val - ex) < 1e-4
63+
@test _abs(val - ex) < 1e-4
6464
end
6565
for val in gz
66-
@test abs(val - ez) < 1e-4
66+
@test _abs(val - ez) < 1e-4
6767
end
6868
end
6969
end

test/runtests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using ImageFiltering, Test
1+
using ImageFiltering, ImageCore
2+
using Test
23
import StaticArrays
34
using Random
45

@@ -18,6 +19,7 @@ function typestring(::Type{T}) where T # from https://github.com/JuliaImages/I
1819
String(take!(buf))
1920
end
2021

22+
include("compat.jl")
2123
include("border.jl")
2224
include("nd.jl")
2325
include("2d.jl")

test/triggs.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ using Test
4949
x = -2:2
5050
y = (-3:3)'
5151
kernel = KernelFactors.IIRGaussian((σ, σ))
52+
5253
for img in (imgf, imgg, imgc)
5354
imgcmp = img[3,4] .* exp.(-(x.^2 .+ y.^2)/(2*σ^2))/^2*2*pi)
5455
border = Fill(zero(eltype(img)))
5556
img0 = copy(img)
5657
imgfilt = @inferred(imfilter(img, kernel, border))
57-
@test sum(abs2, imgcmp - imgfilt) < 0.2^2*sum(abs2, imgcmp)
58+
@test sum(_abs2, imgcmp - imgfilt) < 0.2^2*sum(_abs2, imgcmp)
5859
@test img == img0
5960
@test imgfilt != img
6061
end

0 commit comments

Comments
 (0)