Skip to content

Commit 77c3b48

Browse files
committed
Adds deprecations for adjust_histogram(img, LinearStretching()) variants
1 parent 42795dd commit 77c3b48

File tree

3 files changed

+58
-6
lines changed

3 files changed

+58
-6
lines changed

src/ImageContrastAdjustment.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ include("algorithms/gamma_correction.jl")
2727
include("algorithms/matching.jl")
2828
include("algorithms/midway_equalization.jl")
2929
include("compat.jl")
30+
include("deprecations.jl")
3031

3132
export
3233
# main types and functions

src/algorithms/linear_stretching.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
"""
33
```
4-
LinearStretching <: AbstractHistogramAdjustmentAlgorithm
4+
LinearStretching <: AbstractIntensityAdjustmentAlgorithm
55
LinearStretching(; [src_minval], [src_maxval],
66
dst_minval=0, dst_maxval=1,
77
no_clamp=false)
@@ -10,8 +10,8 @@
1010
LinearStretching((src_minval, src_maxval) => nothing)
1111
LinearStretching(nothing => (dst_minval, dst_maxval))
1212
13-
adjust_histogram([T,] img, f::LinearStretching)
14-
adjust_histogram!([out,] img, f::LinearStretching)
13+
adjust_intensity([T,] img, f::LinearStretching)
14+
adjust_intensity!([out,] img, f::LinearStretching)
1515
```
1616
1717
Returns an image where the range of the intensities spans the interval [`dst_minval`, `dst_maxval`].
@@ -31,7 +31,7 @@ f(x) = (x-A) \\frac{b-a}{B-A} + a.
3131
3232
# Options
3333
34-
Various options for the parameters of the `adjust_histogram` and
34+
Various options for the parameters of the `adjust_intensity` and
3535
`LinearStretching` type are described in more detail below.
3636
3737
## Choices for `img`
@@ -70,7 +70,7 @@ using ImageContrastAdjustment, TestImages
7070
7171
img = testimage("mandril_gray")
7272
# Stretches the contrast in `img` so that it spans the unit interval.
73-
imgo = adjust_histogram(img, LinearStretching(dst_minval = 0, dst_maxval = 1))
73+
imgo = adjust_intensity(img, LinearStretching(dst_minval = 0, dst_maxval = 1))
7474
```
7575
7676
For convenience, Constructing a `LinearStretching` object using `Pair` is also supported
@@ -91,7 +91,7 @@ LinearStretching((0.1, 0.9) => nothing)
9191
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)
9292
9393
"""
94-
@with_kw struct LinearStretching{T} <: AbstractHistogramAdjustmentAlgorithm
94+
@with_kw struct LinearStretching{T} <: AbstractIntensityAdjustmentAlgorithm
9595
src_minval::T = nothing
9696
src_maxval::T = nothing
9797
dst_minval::T = 0.0f0

src/deprecations.jl

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using Base: depwarn
2+
3+
function adjust_histogram(img::Union{GenericGrayImage, AbstractArray{<:Color3}},
4+
f::LinearStretching,
5+
args...; kwargs...)
6+
7+
depwarn("adjust_histogram(img, LinearStretching()) is deprecated, use adjust_intensity(img, LinearStretching()) instead", :adjust_histogram)
8+
return adjust_intensity(img, f, args...;kwargs...)
9+
end
10+
11+
function adjust_histogram(type::Type{T},
12+
img,
13+
f::LinearStretching,
14+
args...; kwargs...) where T
15+
16+
depwarn("adjust_histogram(::Type{T}, img, LinearStretching()) is deprecated, use adjust_intensity(::Type{T}, img, LinearStretching()) instead", :adjust_histogram)
17+
return adjust_intensity(type, img, f, args...;kwargs...)
18+
end
19+
20+
function adjust_histogram(img::AbstractArray{T},
21+
f::LinearStretching,
22+
args...; kwargs...) where T <: Colorant
23+
depwarn("adjust_histogram!(img, LinearStretching()) is deprecated, use adjust_intensity(img, LinearStretching()) instead", :adjust_histogram)
24+
return adjust_intensity(img, f, args...; kwargs...)
25+
end
26+
27+
function adjust_histogram(type::Type{T},
28+
img_sequence::Vector{<:AbstractArray},
29+
f::LinearStretching,
30+
args...; kwargs...) where T
31+
32+
depwarn("adjust_histogram!(::Type{T}, img_sequence, LinearStretching()) is deprecated, use adjust_intensity(::Type{T}, img_sequence, LinearStretching()) instead", :adjust_histogram)
33+
return adjust_histogram!(type, img_sequence, f, args...; kwargs...)
34+
end
35+
36+
function adjust_histogram!(img::Union{GenericGrayImage, AbstractArray{<:Color3}},
37+
f::LinearStretching,
38+
args...; kwargs...)
39+
40+
depwarn("adjust_histogram!(img, LinearStretching()) is deprecated, use adjust_intensity!(img, LinearStretching()) instead", :adjust_histogram!)
41+
return adjust_intensity!(img, f, args...; kwargs...)
42+
end
43+
44+
function adjust_histogram!(out_sequence::Vector{T},
45+
img_sequence,
46+
f::LinearStretching,
47+
args...; kwargs...) where T <: Union{GenericGrayImage, AbstractArray{<:Color3}}
48+
49+
depwarn("adjust_histogram!(out_sequence, img_sequence, LinearStretching()) is deprecated, use adjust_intensity!(out_sequence, img_sequence, LinearStretching()) instead", :adjust_histogram!)
50+
return adjust_intensity(out_sequence, img_sequence, f, args...; kwargs...)
51+
end

0 commit comments

Comments
 (0)