From 50e5b0c3631cd9439e15c31395152651dd54f0ba Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 7 Sep 2021 17:11:19 +0200 Subject: [PATCH 1/4] Update Project.toml --- Project.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 06b327c..b97416c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "VisualRegressionTests" uuid = "34922c18-7c2a-561c-bac1-01e79b2c4c92" author = "Thomas Breloff" -version = "1.0.0" +version = "1.1.0" [deps] ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" @@ -13,14 +13,14 @@ QuartzImageIO = "dca85d43-d64c-5e67-8c65-017450d5d020" Requires = "ae029012-a4dd-5104-9daa-d747884805df" [compat] -ColorTypes = "0.7, 0.8, 0.9, 0.10" -ColorVectorSpace = "0.6, 0.7, 0.8" +ColorTypes = "0.7, 0.8, 0.9, 0.10, 0.11" +ColorVectorSpace = "0.6, 0.7, 0.8, 0.9" FileIO = "1" -ImageFiltering = "0.4, 0.5, 0.6" +ImageFiltering = "0.4, 0.5, 0.6, 0.7" ImageMagick = "0.7, 1" QuartzImageIO = "0.7" Requires = "1" -julia = "1.3" +julia = "1.6" [extras] Gtk = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44" From d473f879cb703577bc136af430986c1050ab5ff0 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Tue, 7 Sep 2021 17:34:10 +0200 Subject: [PATCH 2/4] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index b97416c..798c537 100644 --- a/Project.toml +++ b/Project.toml @@ -20,7 +20,7 @@ ImageFiltering = "0.4, 0.5, 0.6, 0.7" ImageMagick = "0.7, 1" QuartzImageIO = "0.7" Requires = "1" -julia = "1.6" +julia = "1.3" [extras] Gtk = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44" From 48392caa32aadc4797828513738148af38ea95c7 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 8 Sep 2021 10:25:41 +0200 Subject: [PATCH 3/4] fix for recent CVS --- Project.toml | 12 ++++++------ src/VisualRegressionTests.jl | 4 ++-- src/utils.jl | 30 ++++-------------------------- 3 files changed, 12 insertions(+), 34 deletions(-) diff --git a/Project.toml b/Project.toml index 798c537..30581d9 100644 --- a/Project.toml +++ b/Project.toml @@ -4,23 +4,23 @@ author = "Thomas Breloff" version = "1.1.0" [deps] -ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" -ColorVectorSpace = "c3611d14-8923-5661-9e6a-0046d554d3a4" FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" +ImageBase = "c817782e-172a-44cc-b673-b171935fbb9e" +ImageDistances = "51556ac3-7006-55f5-8cb3-34580c88182d" ImageFiltering = "6a3955dd-da59-5b1f-98d4-e7296123deb5" ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" QuartzImageIO = "dca85d43-d64c-5e67-8c65-017450d5d020" Requires = "ae029012-a4dd-5104-9daa-d747884805df" [compat] -ColorTypes = "0.7, 0.8, 0.9, 0.10, 0.11" -ColorVectorSpace = "0.6, 0.7, 0.8, 0.9" FileIO = "1" -ImageFiltering = "0.4, 0.5, 0.6, 0.7" +ImageBase = "^0" +ImageDistances = "^0" +ImageFiltering = "^0" ImageMagick = "0.7, 1" QuartzImageIO = "0.7" Requires = "1" -julia = "1.3" +julia = "1.5" [extras] Gtk = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44" diff --git a/src/VisualRegressionTests.jl b/src/VisualRegressionTests.jl index 57f8c81..a81851d 100644 --- a/src/VisualRegressionTests.jl +++ b/src/VisualRegressionTests.jl @@ -2,8 +2,8 @@ module VisualRegressionTests using Requires using FileIO -using ColorTypes -using ColorVectorSpace +using ImageBase +using ImageDistances using ImageFiltering # --------------------------------------------- diff --git a/src/utils.jl b/src/utils.jl index d2790d0..95e4904 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -1,5 +1,8 @@ # a few utility functions copied/adapted from Images.jl +# github.com/JuliaGraphics/ColorVectorSpace.jl#abs-and-abs2 +_abs(c::CT) where CT<:Color = mapreducec(v->abs(float(v)), +, zero(eltype(CT)), c) + "blur images `A` and `B` with `sigma` and then compute a difference" function blurdiff(A::AbstractArray, B::AbstractArray, sigma) # make sure arrays have the same size @@ -17,25 +20,12 @@ function blurdiff(A::AbstractArray, B::AbstractArray, sigma) Af = imfilter(A, kern, NA()) Bf = imfilter(B, kern, NA()) d = sad(Af, Bf) - diffscale = max(maxabsfinite(A), maxabsfinite(B)) + diffscale = max(_abs(maxabsfinite(A)), _abs(maxabsfinite(B))) diffpct = d / (length(Af) * diffscale) diffpct end -sad(A::AbstractArray, B::AbstractArray) = sumdiff(abs, A, B) - -function sumdiff(f, A::AbstractArray, B::AbstractArray) - axes(A) == axes(B) || throw(DimensionMismatch("A and B must have the same indices")) - T = promote_type(difftype(eltype(A)), difftype(eltype(B))) - s = zero(accum(eltype(T))) - for (a, b) in zip(A, B) - x = convert(T, a) - convert(T, b) - s += f(x) - end - s -end - difftype(::Type{T}) where {T<:Integer} = Int difftype(::Type{T}) where {T<:Real} = Float32 difftype(::Type{Float64}) = Float64 @@ -53,15 +43,3 @@ accum(::Type{T}) where {T<:Integer} = Int accum(::Type{Float32}) = Float32 accum(::Type{T}) where {T<:Real} = Float64 accum(::Type{C}) where {C<:Colorant} = base_colorant_type(C){accum(eltype(C))} - -"maximum absolute value in `A` ignoring `Inf` or `NaN`" -function maxabsfinite(A) - m = -Inf - for a in A - v = abs(a) - if isfinite(v) && v > m - m = v - end - end - m -end From 7eebabd9ec4d63153e5c03e0086da880dadc31f8 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Wed, 8 Sep 2021 12:36:08 +0200 Subject: [PATCH 4/4] remove dead code --- src/utils.jl | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index 95e4904..6660c8d 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -25,21 +25,3 @@ function blurdiff(A::AbstractArray, B::AbstractArray, sigma) diffpct end - -difftype(::Type{T}) where {T<:Integer} = Int -difftype(::Type{T}) where {T<:Real} = Float32 -difftype(::Type{Float64}) = Float64 -difftype(::Type{CV}) where {CV<:Colorant} = difftype(CV, eltype(CV)) -difftype(::Type{CV}, ::Type{T}) where {CV<:RGBA,T<:Real} = RGBA{Float32} -difftype(::Type{CV}, ::Type{Float64}) where {CV<:RGBA} = RGBA{Float64} -difftype(::Type{CV}, ::Type{T}) where {CV<:BGRA,T<:Real} = BGRA{Float32} -difftype(::Type{CV}, ::Type{Float64}) where {CV<:BGRA} = BGRA{Float64} -difftype(::Type{CV}, ::Type{T}) where {CV<:AbstractGray,T<:Real} = Gray{Float32} -difftype(::Type{CV}, ::Type{Float64}) where {CV<:AbstractGray} = Gray{Float64} -difftype(::Type{CV}, ::Type{T}) where {CV<:AbstractRGB,T<:Real} = RGB{Float32} -difftype(::Type{CV}, ::Type{Float64}) where {CV<:AbstractRGB} = RGB{Float64} - -accum(::Type{T}) where {T<:Integer} = Int -accum(::Type{Float32}) = Float32 -accum(::Type{T}) where {T<:Real} = Float64 -accum(::Type{C}) where {C<:Colorant} = base_colorant_type(C){accum(eltype(C))}