Skip to content

Commit feb7a00

Browse files
authored
🧹 code organization and dead code elimination (#971)
2 parents 9796acc + 972d810 commit feb7a00

18 files changed

+593
-1206
lines changed

‎.github/workflows/UnitTest.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
julia-version: ['1.0', '1', 'nightly']
17+
julia-version: ['1.3', '1', 'nightly']
1818
os: [ubuntu-latest]
1919
arch: [x64]
2020
include:

‎Project.toml‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ uuid = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
33
version = "0.24.1"
44

55
[deps]
6-
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
76
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
87
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
98
Graphics = "a2bd30eb-e257-5431-a919-1863eab51364"
109
ImageAxes = "2803e5a7-5153-5ecf-9a86-9b4c37f5f5ac"
10+
ImageBase = "c817782e-172a-44cc-b673-b171935fbb9e"
1111
ImageContrastAdjustment = "f332f351-ec65-5f6a-b3d1-319c6670881a"
1212
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
1313
ImageDistances = "51556ac3-7006-55f5-8cb3-34580c88182d"
@@ -20,7 +20,7 @@ ImageQualityIndexes = "2996bd0c-7a13-11e9-2da2-2f5ce47296a9"
2020
ImageShow = "4e3cecfd-b093-5904-9786-8bbb286a6a31"
2121
ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795"
2222
IndirectArrays = "9b13fd28-a010-5f03-acff-a1bbcff69959"
23-
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
23+
IntegralArrays = "1d092043-8f09-5a30-832f-7509e371ab51"
2424
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2525
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
2626
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
@@ -30,29 +30,29 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
3030
TiledIteration = "06e1c1a7-607b-532d-9fad-de7d9aa2abac"
3131

3232
[compat]
33-
AxisArrays = "0.3, 0.4"
3433
FileIO = "1"
3534
Graphics = "0.4, 1.0"
36-
ImageAxes = "0.6"
35+
ImageAxes = "0.6.9"
36+
ImageBase = "0.1.5"
3737
ImageContrastAdjustment = "0.3.3"
38-
ImageCore = "0.9"
38+
ImageCore = "0.9.3"
3939
ImageDistances = "0.2.5"
40-
ImageFiltering = "0.6.3"
41-
ImageIO = "0.0.1, 0.3, 0.4, 0.5"
42-
ImageMagick = "0.7.5, 1"
43-
ImageMetadata = "0.6, 0.7, 0.8, 0.9"
44-
ImageMorphology = "0.2.7"
45-
ImageQualityIndexes = "0.1.3, 0.2"
46-
ImageShow = "0.1, 0.2, 0.3"
47-
ImageTransformations = "0.4, 0.5, 0.6, 0.7, 0.8"
48-
IndirectArrays = "0.5"
49-
OffsetArrays = "0.8, 0.9, 0.10, 0.11, 1.0.1"
50-
Reexport = "0.2, 1.0"
40+
ImageFiltering = "0.7.1"
41+
ImageIO = "0.3, 0.4, 0.5"
42+
ImageMagick = "1"
43+
ImageMetadata = "0.9.7"
44+
ImageMorphology = "0.3"
45+
ImageQualityIndexes = "0.3"
46+
ImageShow = "0.3"
47+
ImageTransformations = "0.9"
48+
IndirectArrays = "0.5, 1"
49+
IntegralArrays = "0.1"
50+
Reexport = "1.1"
5151
StaticArrays = "0.8, 0.9, 0.10, 0.11, 0.12, 1.0"
5252
StatsBase = "0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.30, 0.31, 0.32, 0.33"
5353
Suppressor = "0.2"
5454
TiledIteration = "0.2, 0.3"
55-
julia = "1"
55+
julia = "1.3"
5656

5757
[extras]
5858
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"

‎src/Images.jl‎

Lines changed: 20 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,21 @@
11
module Images
22

3-
import Base.Iterators.take
4-
import Base: +, -, *
5-
import Base: abs, atan, clamp, convert, copy, copy!, delete!,
6-
eltype, get, getindex, haskey, hypot,
7-
imag, length, map, map!, maximum,
8-
minimum, ndims, one, parent, permutedims, real, reinterpret,
9-
reshape, resize!,
10-
setindex!, show, similar, size, sqrt,
11-
strides, sum, write, zero
12-
13-
export float32, float64
143
export HomogeneousPoint
154

16-
using Base: depwarn
17-
using Base.Order: Ordering, ForwardOrdering, ReverseOrdering
18-
195
using StaticArrays
20-
using Base64: Base64EncodePipe
21-
22-
# CHECKME: use this or follow deprecation and substitute?
23-
using SparseArrays: findnz
24-
25-
# "deprecated imports" are below
266

277
using Reexport
288
@reexport using ImageCore
29-
if isdefined(ImageCore, :permuteddimsview)
30-
export permuteddimsview
31-
end
9+
using ImageCore: NumberLike
10+
using ImageCore.OffsetArrays
11+
@reexport using ImageBase
3212

33-
using FileIO
34-
export load, save
35-
import .Colors: Fractional
36-
import Graphics
37-
import Graphics: width, height, Point
38-
using StatsBase # TODO: eliminate this dependency
13+
@reexport using FileIO: load, save
14+
import Graphics # TODO: eliminate this direct dependency
15+
import StatsBase # TODO: eliminate this dependency
3916
using IndirectArrays, ImageCore.MappedArrays
4017

41-
# TODO: can we get rid of these definitions?
42-
const NumberLike = Union{Number,AbstractGray}
43-
const RealLike = Union{Real,AbstractGray}
44-
45-
const is_little_endian = ENDIAN_BOM == 0x04030201
18+
const is_little_endian = ENDIAN_BOM == 0x04030201 # CHECKME(johnnychen94): is this still used?
4619

4720
@reexport using ImageTransformations
4821
@reexport using ImageAxes
@@ -52,104 +25,43 @@ const is_little_endian = ENDIAN_BOM == 0x04030201
5225
@reexport using ImageDistances
5326
@reexport using ImageContrastAdjustment
5427
@reexport using ImageQualityIndexes
28+
@reexport using IntegralArrays
29+
@reexport using IntegralArrays.IntervalSets.EllipsisNotation
5530

56-
if isdefined(ImageQualityIndexes, :assess_psnr)
57-
# deprecated since ImageQualityIndexes v0.1.4
58-
Base.@deprecate_binding psnr assess_psnr
59-
Base.@deprecate_binding ssim assess_ssim
60-
else
61-
const psnr = ImageQualityIndexes.psnr
62-
export psnr
63-
end
64-
65-
# Both ImageMetadata v0.9.0 and ImageAxes v0.6.0 deprecate the symbol data and
66-
# this causes a name conflict
67-
if isdefined(ImageMetadata, :arraydata)
68-
Base.@deprecate_binding data arraydata
69-
end
70-
# ImageMetadata < v0.9.0 compatibility
71-
if !hasmethod(arraydata, (ImageMeta, ) )
72-
ImageAxes.arraydata(img::ImageMeta) = ImageMetadata.data(img)
73-
end
74-
75-
# Non-exported symbol bindings to ImageShow
76-
import ImageShow
77-
if isdefined(ImageShow, :play)
78-
@doc (@doc ImageShow.play)
79-
const play = ImageShow.play
80-
else
81-
play(args...; kwargs...) = error("The `Images.play` function requires ImageShow at least 0.3.0.")
82-
end
83-
if isdefined(ImageShow, :explore)
84-
@doc (@doc ImageShow.explore)
85-
const explore = ImageShow.explore
86-
else
87-
explore(args...; kwargs...) = error("The `Images.explore` function requires ImageShow at least 0.3.0.")
88-
end
89-
if isdefined(ImageShow, :gif)
90-
@doc (@doc ImageShow.gif)
91-
const gif = ImageShow.gif
92-
else
93-
gif(args...; kwargs...) = error("The `Images.gif` function requires ImageShow at least 0.3.0.")
94-
end
31+
# Non-exported symbol bindings to ImageShow so that we can use, e.g., `Images.gif`
32+
import ImageShow: play, explore, gif
9533

9634
# While we are bridging the old API and the new API in ImageContrastAdjustment
9735
# we need to import these functions because we make new definitions for them
9836
# in deprecations.jl
9937
import ImageContrastAdjustment: build_histogram, adjust_histogram, adjust_histogram!
10038

101-
using ImageMetadata: ImageMetaAxis
102-
import ImageMorphology: dilate, erode
103-
import ImageTransformations: restrict
10439
using TiledIteration: EdgeIterator
10540

41+
# TODO(johnnychen94): (v1.0.0) remove these entry points
42+
# Entry points that isn't used by JuliaImages at all (except for deprecations)
43+
# They used to be accessible by, e.g., `Images.metadata`
44+
import .Colors: Fractional
45+
import FileIO: metadata
46+
import Graphics: Point
47+
10648
include("compat.jl")
10749
include("misc.jl")
10850
include("labeledarrays.jl")
10951
include("algorithms.jl")
110-
include("exposure.jl")
11152
include("deprecations.jl")
11253
include("corner.jl")
11354
include("edge.jl")
11455

11556
export
11657
# types
117-
BlobLoG,
11858
ColorizedArray,
11959
Percentile,
12060

12161
# macros
12262
@test_approx_eq_sigma_eps,
12363

124-
# core functions
125-
assert_timedim_last,
126-
colordim,
127-
coords_spatial,
128-
copyproperties,
129-
data,
130-
height,
131-
maxabsfinite,
132-
maxfinite,
133-
minfinite,
134-
nimages,
135-
pixelspacing,
136-
properties,
137-
restrict,
138-
sdims,
139-
size_spatial,
140-
shareproperties,
141-
spacedirections,
142-
spatialorder,
143-
spatialproperties,
144-
timedim,
145-
width,
146-
widthheight,
147-
14864
# algorithms
149-
backdiffx,
150-
backdiffy,
151-
forwarddiffx,
152-
forwarddiffy,
15365
imcorner,
15466
imcorner_subpixel,
15567
corner2subpixel,
@@ -160,17 +72,11 @@ export
16072
meancovs,
16173
gammacovs,
16274
imedge, # TODO: deprecate?
163-
blob_LoG,
164-
findlocalmaxima,
165-
findlocalminima,
16675
imgaussiannoise,
167-
imlineardiffusion,
168-
imROF,
16976
otsu_threshold,
17077
yen_threshold,
17178

17279
#Exposure
173-
complement,
17480
imhist,
17581
histeq,
17682
adjust_gamma,
@@ -182,27 +88,18 @@ export
18288

18389
magnitude,
18490
magnitude_phase,
185-
meanfinite,
186-
entropy,
18791
orientation,
188-
padarray,
18992
phase,
19093
thin_edges,
19194
thin_edges_subpix,
19295
thin_edges_nonmaxsup,
19396
thin_edges_nonmaxsup_subpix,
19497
canny,
195-
integral_image,
196-
boxdiff,
197-
bilinear_interpolation,
19898
gaussian_pyramid,
19999

200100
# phantoms
201101
shepp_logan
202102

203-
_length(A::AbstractArray) = length(eachindex(A))
204-
_length(A) = length(A)
205-
206103
"""
207104
Constructors, conversions, and traits:
208105
@@ -216,18 +113,17 @@ Contrast/coloration:
216113
217114
Algorithms:
218115
219-
- Reductions: `maxfinite`, `maxabsfinite`, `minfinite`, `meanfinite`, `integral_image`, `boxdiff`, `gaussian_pyramid`
116+
- Reductions: `maxfinite`, `maxabsfinite`, `minfinite`, `meanfinite`, `IntegralArray`, `gaussian_pyramid`
220117
- Resizing: `restrict`, `imresize` (not yet exported)
221118
- Filtering: `imfilter`, `imfilter!`, `mapwindow`, `imROF`, `padarray`
222-
- Filtering kernels: `Kernel.` or `KernelFactors.`, followed by `ando[345]`, `guassian2d`, `imaverage`, `imdog`, `imlaplacian`, `prewitt`, `sobel`
119+
- Filtering kernels: `Kernel.` or `KernelFactors.`, followed by `ando[345]`, `guassian`, `Laplacian', `DoG`, `prewitt`, `sobel`, etc.
223120
- Exposure : `imhist`, `histeq`, `adjust_gamma`, `histmatch`, `imadjustintensity`, `imstretch`, `imcomplement`, `clahe`, `cliphist`
224121
- Gradients: `backdiffx`, `backdiffy`, `forwarddiffx`, `forwarddiffy`, `imgradients`
225122
- Edge detection: `imedge`, `imgradients`, `thin_edges`, `magnitude`, `phase`, `magnitudephase`, `orientation`, `canny`
226123
- Corner detection: `imcorner`,`imcorner_subpixel`, `harris`, `shi_tomasi`, `kitchen_rosenfeld`, `meancovs`, `gammacovs`, `fastcorners`
227124
- Blob detection: `blob_LoG`, `findlocalmaxima`, `findlocalminima`
228125
- Morphological operations: `dilate`, `erode`, `closing`, `opening`, `tophat`, `bothat`, `morphogradient`, `morpholaplace`, `feature_transform`, `distance_transform`, `convexhull`
229126
- Connected components: `label_components`, `component_boxes`, `component_lengths`, `component_indices`, `component_subscripts`, `component_centroids`
230-
- Interpolation: `bilinear_interpolation`
231127
232128
Test images and phantoms (see also TestImages.jl):
233129

0 commit comments

Comments
 (0)