Skip to content

Commit

Permalink
WIP: replace Images with specific packages
Browse files Browse the repository at this point in the history
Currently the  bottleneck is `gaussian_pyramid` which is still in
Images.jl
  • Loading branch information
timholy committed Jul 22, 2023
1 parent 2153078 commit 5ebdae8
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 24 deletions.
12 changes: 8 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ version = "0.5.0"

[deps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
ImageBase = "c817782e-172a-44cc-b673-b171935fbb9e"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
ImageCorners = "89d5987c-236e-4e32-acd0-25bd6bd87b70"
ImageFiltering = "6a3955dd-da59-5b1f-98d4-e7296123deb5"
ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
Distributions = "0.16, 0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25"
Images = "0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25"
ImageCore = "0.10"
julia = "1.6"

[extras]
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990"

[targets]
test = ["ImageMagick", "LinearAlgebra", "Test", "TestImages"]
test = ["ImageIO", "LinearAlgebra", "Test", "TestImages"]
2 changes: 0 additions & 2 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
ImageDraw = "4381153b-2b60-58ae-a1ba-fd683676385f"
ImageFeatures = "92ff4b2b-8094-53d3-b29d-97f740f06cef"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc"
TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990"

Expand Down
8 changes: 7 additions & 1 deletion src/ImageFeatures.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
module ImageFeatures

# package code goes here
using Images, Distributions
using ImageCore
using ImageCore: NumberLike
using ImageBase
using ImageTransformations # imresize
using ImageCorners
using ImageFiltering
using Distributions
using SparseArrays
import Random.seed!
using Images.ImageTransformations.Interpolations
Expand Down
6 changes: 3 additions & 3 deletions src/hog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function HOG(; orientations::Int = 9, cell_size::Int = 8, block_size::Int = 2, b
HOG(orientations, cell_size, block_size, block_stride, norm_method)
end

function create_descriptor(img::AbstractArray{CT, 2}, params::HOG) where CT<:Images.NumberLike
function create_descriptor(img::AbstractArray{CT, 2}, params::HOG) where CT<:NumberLike
#compute gradient
gx = imfilter(img, centered([-1 0 1]))
gy = imfilter(img, centered([-1 0 1]'))
Expand All @@ -34,7 +34,7 @@ function create_descriptor(img::AbstractArray{CT, 2}, params::HOG) where CT<:Ima
create_hog_descriptor(mag, phase, params)
end

function create_descriptor(img::AbstractArray{CT, 2}, params::HOG) where CT<:Images.Color{T, N} where T where N
function create_descriptor(img::AbstractArray{CT, 2}, params::HOG) where CT<:Color{T, N} where T where N
#for color images, compute seperate gradient for each color channel and take one with largest norm as pixel's gradient vector
rows, cols = size(img)
gx = channelview(imfilter(img, centered([-1 0 1])))
Expand All @@ -56,7 +56,7 @@ function create_descriptor(img::AbstractArray{CT, 2}, params::HOG) where CT<:Ima
create_hog_descriptor(max_mag, max_phase, params)
end

function create_hog_descriptor(mag::AbstractArray{T, 2}, phase::AbstractArray{T, 2}, params::HOG) where T<:Images.NumberLike
function create_hog_descriptor(mag::AbstractArray{T, 2}, phase::AbstractArray{T, 2}, params::HOG) where T<:NumberLike
orientations = params.orientations
cell_size = params.cell_size
block_size = params.block_size
Expand Down
2 changes: 0 additions & 2 deletions src/houghtransform.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Images

"""
```
lines = hough_transform_standard(
Expand Down
2 changes: 1 addition & 1 deletion src/lbp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,6 @@ function create_descriptor(img::AbstractArray{Gray{T}, 2}, yblocks::Integer = 4,
y_padded = ceil(Int, h / (yblocks)) * yblocks
x_padded = ceil(Int, w / (xblocks)) * xblocks

img_padded = Images.imresize(img, (y_padded, x_padded))
img_padded = imresize(img, (y_padded, x_padded))
_create_descriptor(img_padded, yblocks, xblocks, lbp_type, args...)
end
2 changes: 1 addition & 1 deletion test/brief.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Test, ImageFeatures, Images, TestImages, Distributions
using Test, ImageFeatures, ImageCore, TestImages, Distributions

@testset "Generating brief params" begin
brief_params = BRIEF(size = 8, window = 3, seed = 123)
Expand Down
2 changes: 1 addition & 1 deletion test/brisk.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Test, ImageFeatures, Images, TestImages, Distributions
using Test, ImageFeatures, ImageCore, TestImages, Distributions

@testset "Testing brisk params" begin
brisk_params = BRISK(pattern_scale = 2.0)
Expand Down
2 changes: 1 addition & 1 deletion test/core.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Test, ImageFeatures, Images
using Test, ImageFeatures, ImageCore

@testset "Types" begin
img = zeros(10, 10)
Expand Down
2 changes: 1 addition & 1 deletion test/corner.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Test, ImageFeatures, Images
using Test, ImageFeatures, ImageCore

@testset "Orientations" begin
img = zeros(20, 20)
Expand Down
2 changes: 1 addition & 1 deletion test/freak.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Test, ImageFeatures, Images, TestImages, Distributions
using Test, ImageFeatures, ImageCore, TestImages, Distributions

@testset "Test freak params" begin
freak_params = FREAK(pattern_scale = 20.0)
Expand Down
2 changes: 1 addition & 1 deletion test/glcm.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Test, ImageFeatures, Images
using Test, ImageFeatures, ImageCore, ImageBase

@testset "GLCM" begin
img = [ 0 0 1 1
Expand Down
2 changes: 1 addition & 1 deletion test/hog.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Test, ImageFeatures, Images
using Test, ImageFeatures, ImageCore
import ImageFeatures.trilinear_interpolate!

@testset "HOG Feature" begin
Expand Down
4 changes: 2 additions & 2 deletions test/lbp.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Test, ImageFeatures, Images
using Test, ImageFeatures, ImageCore

@testset "circular_offsets" begin
img = [ 0x4c 0x19 0xac 0x2e 0x8c 0xcc 0x96 0x4c 0xdb 0x4f
Expand All @@ -13,7 +13,7 @@ using Test, ImageFeatures, Images
0x1a 0xe0 0x52 0x5a 0x6a 0x03 0xe8 0xcb 0x95 0xfc
]

global img_gray = map(i -> Images.Gray(reinterpret(N0f8, i)), img)
global img_gray = map(i -> Gray(reinterpret(N0f8, i)), img)
end

@test ImageFeatures.circular_offsets(8, 1) == [ (-0.0,1.0), (-0.70711,0.70711), (-1.0,0.0), (-0.70711,-0.70711), (-0.0,-1.0), (0.70711,-0.70711), (1.0,-0.0), (0.70711,0.70711)]
Expand Down
2 changes: 1 addition & 1 deletion test/orb.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Test, ImageFeatures, Images, TestImages, Distributions
using Test, ImageFeatures, ImageCore, TestImages, Distributions

@testset "Testing ORB params" begin
orb_params = ORB(num_keypoints = 1000, threshold = 0.2)
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module ImageFeatureTests

using ImageFeatures, Images, TestImages, Distributions
using ImageFeatures, ImageCore, ImageCorners, ImageFiltering, TestImages, Distributions
using Test
using LinearAlgebra
import Random.seed!
Expand Down

0 comments on commit 5ebdae8

Please sign in to comment.