Skip to content

Commit da8cffa

Browse files
authored
Merge pull request #179 from WilhelmusLab/feat-seg-d-e-cleanup
fix: correct input files and update tests
2 parents be61142 + be151ef commit da8cffa

File tree

4 files changed

+22
-35
lines changed

4 files changed

+22
-35
lines changed

src/segmentation_d_e.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@ function watershed_ice_floes(intermediate_segmentation_image::BitMatrix)::BitMat
1919
return borders
2020
end
2121

22-
## function alias segmentation_D is watershed on the `not_ice_mask` from segmentation_B
22+
## function alias segmentation_D is watershed on the `segmented_c` from segmentation_C
2323
const segmentation_D = watershed_ice_floes
24-
## function alias segmentation_E is watershed on the `segmented_c` from segmentation_C
24+
## function alias segmentation_E is watershed on the `not_ice_mask` from segmentation_B
2525
const segmentation_E = watershed_ice_floes
2626

2727
"""
28-
segmentation_D_E(watershed_B, watershed_C;)
28+
segmentation_D_E(watershed_D, watershed_E;)
2929
3030
Intersects the outputs of watershed segmentation on intermediate files from segmentation B and C, indicating potential sparse boundaries of ice floes.
3131
3232
# Arguments
33-
- `watershed_B`: binary segmentation mask from `segmentation_D`
34-
- `watershed_C`: binary segmentation mask from `segmentation_E`
33+
- `watershed_D`: binary segmentation mask from `segmentation_D`
34+
- `watershed_E`: binary segmentation mask from `segmentation_E`
3535
3636
"""
37-
function segmentation_D_E(watershed_B::BitMatrix, watershed_C::BitMatrix;)::BitMatrix
37+
function segmentation_D_E(watershed_D::BitMatrix, watershed_E::BitMatrix;)::BitMatrix
3838

3939
## Intersect the two watershed files
40-
watershed_intersect = watershed_B .* watershed_C
40+
watershed_intersect = watershed_D .* watershed_E
4141
return watershed_intersect
4242
end

test/test-segmentation-d-e.jl

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,32 @@
22
println("------------------------------------------------")
33
println("------------ Create Segmentation-D,E Test --------------")
44

5-
matlab_segmented_D = load("$(test_data_dir)/matlab_not_ice_mask.png") .> 0.5
6-
7-
matlab_segmented_E = convert(BitMatrix, load("$(test_data_dir)/matlab_segmented_c.png"))
8-
matlab_watershed_D = convert(BitMatrix, load("$(test_data_dir)/matlab_watershed_B.png"))
9-
matlab_watershed_E = convert(BitMatrix, load("$(test_data_dir)/matlab_watershed_C.png"))
5+
matlab_segmented_B = load("$(test_data_dir)/matlab_not_ice_mask.png") .<= 1
6+
matlab_segmented_C = convert(BitMatrix, load("$(test_data_dir)/matlab_segmented_c.png"))
7+
matlab_watershed_D = convert(BitMatrix, load("$(test_data_dir)/matlab_watershed_D.png"))
8+
matlab_watershed_E = convert(BitMatrix, load("$(test_data_dir)/matlab_watershed_E.png"))
109
matlab_watershed_intersect = convert(
1110
BitMatrix, load("$(test_data_dir)/matlab_watershed_intersect.png")
1211
)
1312

1413
## Run function with Matlab inputs
15-
@time watershed_D_borders = IceFloeTracker.segmentation_D(matlab_segmented_D) #Matlab_not_ice_mask
16-
@time watershed_E_borders = IceFloeTracker.segmentation_E(matlab_segmented_E) #matlab_segmented_c
14+
@time watershed_D_borders = IceFloeTracker.segmentation_D(matlab_segmented_C) #Matlab_segmented_c
15+
@time watershed_E_borders = IceFloeTracker.segmentation_E(matlab_segmented_B) #Matlab_not_ice_mask
1716
@time watershed_intersect = IceFloeTracker.segmentation_D_E(
1817
watershed_D_borders, watershed_E_borders
1918
)
2019

21-
watershed_D_filename =
22-
"$(test_output_dir)/watershed_d_" *
23-
Dates.format(Dates.now(), "yyyy-mm-dd-HHMMSS") *
24-
".png"
25-
IceFloeTracker.@persist watershed_D_borders watershed_D_filename
26-
27-
watershed_E_filename =
28-
"$(test_output_dir)/watershed_e_" *
29-
Dates.format(Dates.now(), "yyyy-mm-dd-HHMMSS") *
30-
".png"
31-
IceFloeTracker.@persist watershed_E_borders watershed_E_filename
20+
IceFloeTracker.@persist watershed_D_borders "./test_outputs/watershed_d.png" true
21+
22+
IceFloeTracker.@persist watershed_D_borders "./test_outputs/watershed_e.png" true
3223

33-
watershed_intersect_filename =
34-
"$(test_output_dir)/watershed_intersect_" *
35-
Dates.format(Dates.now(), "yyyy-mm-dd-HHMMSS") *
36-
".png"
37-
IceFloeTracker.@persist watershed_intersect watershed_intersect_filename
24+
IceFloeTracker.@persist watershed_D_borders "./test_outputs/watershed_intersect.png" true
3825

3926
## Tests with Matlab inputs
40-
@test typeof(watershed_E_borders) == typeof(matlab_watershed_D)
41-
@test typeof(watershed_D_borders) == typeof(matlab_watershed_E)
27+
@test typeof(watershed_E_borders) == typeof(matlab_watershed_E)
28+
@test typeof(watershed_D_borders) == typeof(matlab_watershed_D)
4229
@test typeof(watershed_intersect) == typeof(matlab_watershed_intersect)
43-
@test test_similarity(matlab_watershed_D, watershed_D_borders, 0.064)
44-
@test test_similarity(matlab_watershed_E, watershed_E_borders, 0.08)
45-
@test test_similarity(matlab_watershed_intersect, watershed_intersect, 0.017)
30+
@test test_similarity(matlab_watershed_D, watershed_D_borders, 0.078)
31+
@test test_similarity(matlab_watershed_E, watershed_E_borders, 0.024)
32+
@test test_similarity(matlab_watershed_intersect, watershed_intersect, 0.0028)
4633
end
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)