Skip to content

Commit 4504343

Browse files
committed
function updates
1 parent 50e0f7b commit 4504343

File tree

4 files changed

+14
-27
lines changed

4 files changed

+14
-27
lines changed

src/segmentation_f.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ function segmentation_F(
4343
ice_mask_watershed_applied; min_area=lower_min_area_opening, connectivity=2
4444
)
4545
#leads
46-
ice_leads = ifelse.(.!ice_mask_watershed_opened .== 0, 0.0, 1)
46+
ice_leads = .!ice_mask_watershed_opened
4747
#Iobrd2
4848
not_ice_dilated = IceFloeTracker.MorphSE.dilate(
4949
segmentation_B_not_ice_mask; dims=IceFloeTracker.MorphSE.strel_diamond((5, 5))
5050
)
5151
#Iobrcbr2
52-
not_ice_reconstructed = MorphSE.opening(
53-
complement.(not_ice_dilated); dims=complement.(segmentation_B_not_ice_mask)
52+
not_ice_reconstructed = IceFloeTracker.MorphSE.mreconstruct(IceFloeTracker.MorphSE.dilate,
53+
complement.(not_ice_dilated), complement.(segmentation_B_not_ice_mask)
5454
)
5555
#Z(he)
5656
reconstructed_leads = float64.(not_ice_reconstructed .* ice_leads) .+ (60 / 255)
@@ -85,13 +85,13 @@ function segmentation_F(
8585
leads_bothat_opened = IceFloeTracker.prune(leads_bothat_opened)
8686
#BW2
8787
leads_bothat_filled = .!ImageMorphology.imfill(.!leads_bothat_opened, 0:160)
88-
#leads_bothat_filled = .!IceFloeTracker.bwareamaxfilt(.!leads_bothat_opened)
88+
leads_bothat_filled = .!IceFloeTracker.bwareamaxfilt(.!leads_bothat_opened)
8989
#BW2
9090
leads_bothat_masked = leads_bothat_filled .* cloudmask
9191
leads_bothat_masked = IceFloeTracker.prune(leads_bothat_masked)
9292
#BW3
9393
leads_cloudmasked_filled = .!ImageMorphology.imfill(.!leads_bothat_masked, 0:300)
94-
#leads_cloudmasked_filled = .!IceFloeTracker.bwareamaxfilt(.!leads_bothat_masked)
94+
leads_cloudmasked_filled = .!IceFloeTracker.bwareamaxfilt(.!leads_bothat_masked)
9595
#BW4
9696
leads_masked_branched = IceFloeTracker.branch(leads_cloudmasked_filled)
9797
#BW5

test/runtests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ testnames = [n[6:(end - 3)] for n in alltests]
1717

1818
## Put the filenames to test below
1919

20-
to_test = alltests # uncomment this line to run all tests or add individual files below
20+
to_test = #alltests # uncomment this line to run all tests or add individual files below
2121
[
2222
# "test-create-landmask.jl",
2323
# "test-create-cloudmask.jl",
@@ -30,6 +30,7 @@ to_test = alltests # uncomment this line to run all tests or add individual file
3030
# "test-segmentation-b.jl",
3131
# "test-segmentation-c.jl",
3232
# "test-segmentation-d-e.jl",
33+
"test-segmentation-f.jl",
3334
# "test-bwtraceboundary.jl",
3435
# "test-resample-boundary.jl",
3536
# "test-regionprops.jl",

test/test-segmentation-a.jl

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,21 @@
1414
matlab_segmented_ice = convert(
1515
BitMatrix, float64.(load("$(test_data_dir)/matlab_segmented_ice.png"))
1616
)
17-
matlab_segmented_ice_cloudmasked = (
18-
load("$(test_data_dir)/matlab_segmented_ice_cloudmasked.png") .> 0.5
19-
)
17+
matlab_segmented_ice_cloudmasked = load("$(test_data_dir)/matlab_segmented_ice_cloudmasked.png") .>= 0.5
2018

2119
println("---------- Segment Image - Direct Method ------------")
2220
@time segmented_ice_cloudmasked = IceFloeTracker.segmented_ice_cloudmasking(
2321
ice_water_discriminated_image, cloudmask, ice_labels
2422
)
25-
segmented_ice_cloudmasked_filename =
26-
"$(test_output_dir)/segmented_a_ice_cloudmasked_" *
27-
Dates.format(Dates.now(), "yyyy-mm-dd-HHMMSS") *
28-
".png"
29-
IceFloeTracker.@persist segmented_ice_cloudmasked segmented_ice_cloudmasked_filename
23+
IceFloeTracker.@persist segmented_ice_cloudmasked "./test/test_outputs/segmented_a_ice_cloudmasked.png" true
3024

3125
@time segmented_A = IceFloeTracker.segmentation_A(segmented_ice_cloudmasked)
32-
segmented_a_filename =
33-
"$(test_output_dir)/segmented_a_" *
34-
Dates.format(Dates.now(), "yyyy-mm-dd-HHMMSS") *
35-
".png"
36-
IceFloeTracker.@persist segmented_A segmented_a_filename
26+
IceFloeTracker.@persist segmented_A "./test/test_outputs/segmented_a.png" true
3727

3828
@time segmented_ice = IceFloeTracker.kmeans_segmentation(
3929
ice_water_discriminated_image, ice_labels
4030
)
41-
segmented_ice_filename =
42-
"$(test_output_dir)/segmented_ice_" *
43-
Dates.format(Dates.now(), "yyyy-mm-dd-HHMMSS") *
44-
".png"
45-
IceFloeTracker.@persist segmented_ice segmented_ice_filename
31+
IceFloeTracker.@persist segmented_ice "./test/test_outputs/segmented_a_ice.png" true
4632

4733
@test typeof(segmented_A) == typeof(matlab_segmented_A_bitmatrix)
4834
@test test_similarity(matlab_segmented_A_bitmatrix, segmented_A, 0.032)

test/test-segmentation-f.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
## Load inputs for comparison
66
segmentation_B_not_ice_mask = float64.(load("$(test_data_dir)/matlab_not_ice_mask.png"))
7-
segmentation_C_ice_mask = load(segmented_c_test_file) .> 0.5
7+
segmentation_C_ice_mask = load(segmented_c_test_file) .>= 0.5
88
cloudmask = convert(BitMatrix, load(cloudmask_test_file))
99
landmask = convert(BitMatrix, load(current_landmask_file))
10-
watershed_intersect = load(watershed_test_file) .> 0.5
10+
watershed_intersect = load(watershed_test_file) .>= 0.5
1111
ice_labels =
1212
Int64.(
1313
vec(DelimitedFiles.readdlm("$(test_data_dir)/ice_labels_floe_region.csv", ','))
1414
)
1515
matlab_isolated_floes =
16-
float64.(load("$(test_data_dir)/matlab_isolated_floes.png")) .> 0.5
16+
float64.(load("$(test_data_dir)/matlab_isolated_floes.png")) .>= 0.5
1717

1818
## Run function with Matlab inputs
1919

0 commit comments

Comments
 (0)