Skip to content

Commit

Permalink
Merge pull request #497 from WilhelmusLab/496-imcomplement
Browse files Browse the repository at this point in the history
feat: imcomplement
  • Loading branch information
cpaniaguam authored Nov 8, 2024
2 parents fd8c4a3 + d86d8d2 commit 3e74b31
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/IceFloeTracker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ include("branch.jl")
include("special_strels.jl")
include("tilingutils.jl")
include("histogram_equalization.jl")
include("imcomplement.jl")


const sk_measure = PyNULL()
Expand Down
7 changes: 7 additions & 0 deletions src/imcomplement.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function imcomplement(img::Matrix{T}) where {T<:Union{Unsigned,Int}}
return 255 .- img
end

function imcomplement(img::Matrix{Gray{Float64}})
return 1 .- img
end
9 changes: 9 additions & 0 deletions test/test-imcomplement.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using IceFloeTracker: imcomplement

@testset "imcomplement" begin
img = rand(0:255, 10, 10)
@test imcomplement(img) == 255 .- img

img = Gray.(img ./ 255)
@test imcomplement(img) == 1 .- img
end

0 comments on commit 3e74b31

Please sign in to comment.