From 9842a5eaed30d75609c0edfe4dd86686c92cbca6 Mon Sep 17 00:00:00 2001 From: Zygmunt Szpak Date: Sun, 12 Sep 2021 14:09:36 +0930 Subject: [PATCH] Adds deprecations for adjust_histogram(img, GammaCorrection()) variants --- src/algorithms/gamma_correction.jl | 12 +++++----- src/deprecations.jl | 35 +++++++++++++++--------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/algorithms/gamma_correction.jl b/src/algorithms/gamma_correction.jl index daaa50f..d57013e 100644 --- a/src/algorithms/gamma_correction.jl +++ b/src/algorithms/gamma_correction.jl @@ -1,11 +1,11 @@ """ ``` - GammaCorrection <: AbstractHistogramAdjustmentAlgorithm + GammaCorrection <: AbstractIntensityAdjustmentAlgorithm GammaCorrection(; gamma = 1) - adjust_histogram([T,] img, f::GammaCorrection) - adjust_histogram!([out,] img, f::GammaCorrection) + adjust_intensity([T,] img, f::GammaCorrection) + adjust_intensity!([out,] img, f::GammaCorrection) ``` Returns a gamma corrected image. @@ -36,7 +36,7 @@ tool. # Options -Various options for the parameters of the `adjust_histogram` function and the +Various options for the parameters of the `adjust_intensity` function and the `Gamma` type are described in more detail below. ## Choices for `img` @@ -65,7 +65,7 @@ intensities = 0.0:(1.0/n):1.0 img = repeat(intensities, inner=(20,20))' # Brighten the dark tones. -imgadj = adjust_histogram( img, GammaCorrection(gamma = 1/2)) +imgadj = adjust_intensity( img, GammaCorrection(gamma = 1/2)) # Display the original and adjusted image. imshow(img) @@ -75,7 +75,7 @@ imshow(imgadj) # References 1. W. Burger and M. J. Burge. *Digital Image Processing*. Texts in Computer Science, 2016. [doi:10.1007/978-1-4471-6684-9](https://doi.org/10.1007/978-1-4471-6684-9) """ -@with_kw struct GammaCorrection{T <: Real} <: AbstractHistogramAdjustmentAlgorithm +@with_kw struct GammaCorrection{T <: Real} <: AbstractIntensityAdjustmentAlgorithm gamma::T = 1.0 end diff --git a/src/deprecations.jl b/src/deprecations.jl index d56ec84..d41fee2 100644 --- a/src/deprecations.jl +++ b/src/deprecations.jl @@ -1,51 +1,52 @@ using Base: depwarn function adjust_histogram(img::Union{GenericGrayImage, AbstractArray{<:Color3}}, - f::LinearStretching, + f::Union{LinearStretching, GammaCorrection}, args...; kwargs...) - - depwarn("adjust_histogram(img, LinearStretching()) is deprecated, use adjust_intensity(img, LinearStretching()) instead", :adjust_histogram) + algo = typeof(f) + depwarn("adjust_histogram(img, $algo) is deprecated, use adjust_intensity(img, $algo) instead", :adjust_histogram) return adjust_intensity(img, f, args...;kwargs...) end function adjust_histogram(type::Type{T}, img, - f::LinearStretching, + f::Union{LinearStretching, GammaCorrection}, args...; kwargs...) where T - - depwarn("adjust_histogram(::Type{T}, img, LinearStretching()) is deprecated, use adjust_intensity(::Type{T}, img, LinearStretching()) instead", :adjust_histogram) + algo = typeof(f) + depwarn("adjust_histogram(::Type{T}, img, $algo) is deprecated, use adjust_intensity(::Type{T}, img, $algo) instead", :adjust_histogram) return adjust_intensity(type, img, f, args...;kwargs...) end function adjust_histogram(img::AbstractArray{T}, - f::LinearStretching, + f::Union{LinearStretching, GammaCorrection}, args...; kwargs...) where T <: Colorant - depwarn("adjust_histogram!(img, LinearStretching()) is deprecated, use adjust_intensity(img, LinearStretching()) instead", :adjust_histogram) + algo = typeof(f) + depwarn("adjust_histogram!(img, $algo) is deprecated, use adjust_intensity(img, $algo) instead", :adjust_histogram) return adjust_intensity(img, f, args...; kwargs...) end function adjust_histogram(type::Type{T}, img_sequence::Vector{<:AbstractArray}, - f::LinearStretching, + f::Union{LinearStretching, GammaCorrection}, args...; kwargs...) where T - - depwarn("adjust_histogram!(::Type{T}, img_sequence, LinearStretching()) is deprecated, use adjust_intensity(::Type{T}, img_sequence, LinearStretching()) instead", :adjust_histogram) + algo = typeof(f) + depwarn("adjust_histogram!(::Type{T}, img_sequence, $algo) is deprecated, use adjust_intensity(::Type{T}, img_sequence, $algo) instead", :adjust_histogram) return adjust_histogram!(type, img_sequence, f, args...; kwargs...) end function adjust_histogram!(img::Union{GenericGrayImage, AbstractArray{<:Color3}}, - f::LinearStretching, + f::Union{LinearStretching, GammaCorrection}, args...; kwargs...) - - depwarn("adjust_histogram!(img, LinearStretching()) is deprecated, use adjust_intensity!(img, LinearStretching()) instead", :adjust_histogram!) + algo = typeof(f) + depwarn("adjust_histogram!(img, $algo) is deprecated, use adjust_intensity!(img, $algo) instead", :adjust_histogram!) return adjust_intensity!(img, f, args...; kwargs...) end function adjust_histogram!(out_sequence::Vector{T}, img_sequence, - f::LinearStretching, + f::Union{LinearStretching, GammaCorrection}, args...; kwargs...) where T <: Union{GenericGrayImage, AbstractArray{<:Color3}} - - depwarn("adjust_histogram!(out_sequence, img_sequence, LinearStretching()) is deprecated, use adjust_intensity!(out_sequence, img_sequence, LinearStretching()) instead", :adjust_histogram!) + algo = typeof(f) + depwarn("adjust_histogram!(out_sequence, img_sequence, $algo) is deprecated, use adjust_intensity!(out_sequence, img_sequence, $algo) instead", :adjust_histogram!) return adjust_intensity(out_sequence, img_sequence, f, args...; kwargs...) end \ No newline at end of file