Skip to content

Commit

Permalink
test: add tests for get_final
Browse files Browse the repository at this point in the history
  • Loading branch information
cpaniaguam committed Nov 19, 2024
1 parent a8a5789 commit 90b3177
Show file tree
Hide file tree
Showing 3 changed files with 4,106 additions and 25 deletions.
71 changes: 46 additions & 25 deletions test/test-regularize-final.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
using IceFloeTracker: get_tiles, regularize_fill_holes, regularize_sharpening, _regularize
using IceFloeTracker:
get_tiles,
regularize_fill_holes,
regularize_sharpening,
_regularize,
se_disk2,
get_final
using DelimitedFiles: readdlm

se = collect(IceFloeTracker.MorphSE.strel_diamond((3, 3)))
Expand All @@ -16,27 +22,42 @@ expected_regularized_sharpened = readdlm(
joinpath(test_files_dir, "reg_sharpened.csv"), ',', Int
)

@testset "regularize_fill_holes/sharpening" begin
reg_holes_filled = regularize_fill_holes(
morph_residue, local_maxima_mask, segment_mask, L0mask, 0.3
)

reg_sharpened = regularize_sharpening(
reg_holes_filled, L0mask, local_maxima_mask, segment_mask, se, 10, 2, 0.5
)

reg = _regularize(
morph_residue,
local_maxima_mask,
segment_mask,
L0mask,
se;
factor=(0.3, 0.5),
radius=10,
amount=2,
)

@test expected_regularized_holes_filled == reg_holes_filled
@test expected_regularized_sharpened == reg_sharpened
@test expected_regularized_sharpened == reg
end
get_final_input = readdlm(joinpath(test_files_dir, "get_final.csv"), ',', Bool)
se_erosion = se
se_dilation = se_disk2()
get_final_expected = readdlm(joinpath(test_files_dir, "get_final_expected.csv"), ',', Bool)

@testset "regularize/get_final" begin
@testset "regularize_fill_holes/sharpening" begin
reg_holes_filled = regularize_fill_holes(
morph_residue, local_maxima_mask, segment_mask, L0mask, 0.3
)

reg_sharpened = regularize_sharpening(
reg_holes_filled, L0mask, local_maxima_mask, segment_mask, se, 10, 2, 0.5
)

reg = _regularize(
morph_residue,
local_maxima_mask,
segment_mask,
L0mask,
se;
factor=(0.3, 0.5),
radius=10,
amount=2,
)

@test expected_regularized_holes_filled == reg_holes_filled
@test expected_regularized_sharpened == reg_sharpened
@test expected_regularized_sharpened == reg
end

@testset "get_final" begin
get_final_output = get_final(
get_final_input, segment_mask, se_erosion, se_dilation, true
)

@test get_final_output == get_final_expected
end
end
Loading

0 comments on commit 90b3177

Please sign in to comment.