Skip to content

Commit 503411d

Browse files
committed
🧹 Move complement to ColorVectorSpace
`complement` is such a basic operation that we moved to lower-level package ColorVectorSpace in PR JuliaGraphics/ColorVectorSpace.jl#144 This requires ColorVectorSpace v0.9.2. Since we indirectly get CVS via ImageCore, we need to set a compatible ImageCore version that requires CVS >= v0.9.2. For this reason, this commit sets ImageCore compatibility to v0.9.3 so that we get CVS at least v0.9.7
1 parent 9796acc commit 503411d

File tree

9 files changed

+43
-32
lines changed

9 files changed

+43
-32
lines changed

‎Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ FileIO = "1"
3535
Graphics = "0.4, 1.0"
3636
ImageAxes = "0.6"
3737
ImageContrastAdjustment = "0.3.3"
38-
ImageCore = "0.9"
38+
ImageCore = "0.9.3"
3939
ImageDistances = "0.2.5"
4040
ImageFiltering = "0.6.3"
4141
ImageIO = "0.0.1, 0.3, 0.4, 0.5"

‎src/Images.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ include("compat.jl")
107107
include("misc.jl")
108108
include("labeledarrays.jl")
109109
include("algorithms.jl")
110-
include("exposure.jl")
111110
include("deprecations.jl")
112111
include("corner.jl")
113112
include("edge.jl")
@@ -170,7 +169,6 @@ export
170169
yen_threshold,
171170

172171
#Exposure
173-
complement,
174172
imhist,
175173
histeq,
176174
adjust_gamma,

‎src/deprecations.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,3 +1068,11 @@ function shepp_logan(M,N; highContrast=true)
10681068
end
10691069

10701070
shepp_logan(N;highContrast=true) = shepp_logan(N,N;highContrast=highContrast)
1071+
1072+
# `complement` is now moved to ColorVectorSpace but we still want to keep backward compatibility
1073+
# until Images 1.0
1074+
function ColorVectorSpace.complement(x::AbstractArray)
1075+
Base.depwarn("`complement(img)` is deprecated, please use the broadcasting version `complement.(img)`", :complement)
1076+
complement.(x)
1077+
end
1078+

‎src/exposure.jl

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎test/algorithms.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ using Test, Suppressor
6767

6868
Random.seed!(1234)
6969

70-
@testset "Complement" begin
71-
@test complement.([Gray(0.2)]) == [Gray(0.8)]
72-
@test complement.([Gray{N0f8}(0.2)]) == [Gray{N0f8}(0.8)]
73-
@test complement.([RGB(0,0.3,1)]) == [RGB(1,0.7,0)]
74-
@test complement.([RGBA(0,0.3,1,0.7)]) == [RGBA(1.0,0.7,0.0,0.7)]
75-
@test complement.([RGBA{N0f8}(0,0.6,1,0.7)]) == [RGBA{N0f8}(1.0,0.4,0.0,0.7)]
76-
end
77-
7870
@testset "Entropy" begin
7971
img = rand(1:10,10,10)
8072
img2 = rand(1:2,10,10)

‎test/deprecated.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# When we deprecate old APIs, we copy the old tests here to make sure they still work
2+
3+
@testset "deprecations" begin
4+
5+
@testset "Complement" begin
6+
# deprecated (#690)
7+
img = Gray{N0f16}.([0.01164 0.01118; 0.01036 0.01187])
8+
@test all(complement(img) .== 1 .- img)
9+
end
10+
11+
end

‎test/exposure.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -514,13 +514,6 @@ eye(m,n) = Matrix{Float64}(I,m,n)
514514
@test imadjustintensity(img,[0.0103761, 0.0252166])[2,1] == 0.0
515515
@test eltype(imadjustintensity(img)) == Gray{N0f16}
516516

517-
img = Gray{N0f16}.([0.01164 0.01118; 0.01036 0.01187])
518-
@test complement(Gray(0.5)) == Gray(0.5)
519-
@test complement(Gray(0.2)) == Gray(0.8)
520-
@test all(complement.(img) .== 1 .- img)
521-
# deprecated (#690)
522-
@test all(complement.(img) .== 1 .- img)
523-
524517
hist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
525518

526519
clipped_hist = cliphist(hist, 2)

‎test/legacy.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# These tests once lived in other files, but related functions are declared legacy or moved to
2+
# other packages. For regression test purpose, we still keep them here.
3+
4+
@testset "legacy" begin
5+
6+
# Moved to ColorVectorSpace
7+
@testset "Complement" begin
8+
img = Gray{N0f16}.([0.01164 0.01118; 0.01036 0.01187])
9+
@test complement(Gray(0.5)) == Gray(0.5)
10+
@test complement(Gray(0.2)) == Gray(0.8)
11+
@test all(complement.(img) .== 1 .- img)
12+
13+
@test complement.([Gray(0.2)]) == [Gray(0.8)]
14+
@test complement.([Gray{N0f8}(0.2)]) == [Gray{N0f8}(0.8)]
15+
@test complement.([RGB(0,0.3,1)]) == [RGB(1,0.7,0)]
16+
@test complement.([RGBA(0,0.3,1,0.7)]) == [RGBA(1.0,0.7,0.0,0.7)]
17+
@test complement.([RGBA{N0f8}(0,0.6,1,0.7)]) == [RGBA{N0f8}(1.0,0.4,0.0,0.7)]
18+
end
19+
20+
end

‎test/runtests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ include("algorithms.jl")
88
include("edge.jl")
99
include("corner.jl")
1010
include("writemime.jl")
11-
# include("deprecated.jl")
11+
12+
@suppress_err include("legacy.jl")
13+
@suppress_err include("deprecated.jl")
1214

1315
end

0 commit comments

Comments
 (0)