Skip to content

Commit

Permalink
Merge pull request #207 from WilhelmusLab/add-tiling-preprocessing-su…
Browse files Browse the repository at this point in the history
…pport

feat(preprocess): add tiling CLI support
  • Loading branch information
hollandjg authored Jan 24, 2025
2 parents 0fb2d8a + 7479fb1 commit ac928cd
Show file tree
Hide file tree
Showing 8 changed files with 577 additions and 28 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/build-docker-julia.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,18 @@ jobs:
build-args: |
JULIA_CPU_TARGET=generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1);x86-64-v4,-rdrnd,base(1)
- name: Test CLI
- name: Test Preprocessing (Lopez CLI)
working-directory: ./test
run: source ./test-IFTPipeline.jl-cli.sh && IFT="docker run -v `pwd`:/app -w /app --rm ${{ env.TEST_TAG }}" preprocess_lopez input_data/ne-greenland.20220914.terra.250m

- name: Test Preprocessing CLI (Lopez with Tiling)
working-directory: ./test
run: source ./test-IFTPipeline.jl-cli.sh && IFT="docker run -v `pwd`:/app -w /app --rm ${{ env.TEST_TAG }}" preprocess_lopez_tiling input_data/ne-greenland.20220914.terra.250m

- name: Test Tracker CLI
working-directory: ./test
run: source ./test-IFTPipeline.jl-cli.sh && IFT="docker run -v `pwd`:/app -w /app --rm ${{ env.TEST_TAG }}" track_lopez input_data/ne-greenland.2022091{3,4}.terra.250m/

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
Expand Down
195 changes: 193 additions & 2 deletions IFTPipeline.jl/src/cli.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,192 @@ function mkclipreprocess_single!(settings)
"--output", "-o"
help = "Path to output segmented image file (.tiff)"
required = true

end
return nothing
end

function mkcli_preprocess_tiling_single!(settings)
@add_arg_table! settings["preprocess_tiling_single"] begin
"--truecolor", "-t"
help = "Truecolor image file (.tiff)"
required = true

"--falsecolor", "-r"
help = "Falsecolor image file (.tiff)"
required = true

"--landmask-dilated", "-d"
help = "Landmask image file (dilated, .tiff)"
required = true

"--segmented", "-s"
help = "Path to output segmented image file (.tiff)"
required = true

"--labeled", "-l"
help = "Path to output labeled image file (.tiff)"
required = true


# Tiling parameters

"--tile-rblocks"
default = 8
arg_type = Int
required = false

"--tile-cblocks"
default = 8
arg_type = Int
required = false


# Ice labels thresholds

"--ice-labels-prelim-threshold"
default = 110.0
arg_type = Float64
required = false

"--ice-labels-band-7-threshold"
default = 200.0
arg_type = Float64
required = false

"--ice-labels-band-2-threshold"
default = 190.0
arg_type = Float64
required = false

"--ice-labels-ratio-lower"
default = 0.0
arg_type = Float64
required = false

"--ice-labels-ratio-upper"
default = 0.75
arg_type = Float64
required = false


# Adaptive histogram equalization parameters

"--adapthisteq-white-threshold"
default = 25.5
arg_type = Float64
required = false

"--adapthisteq-entropy-threshold"
default = 4
arg_type = Float64
required = false

"--adapthisteq-white-fraction-threshold"
default = 0.4
arg_type = Float64
required = false


# Gamma parameters

"--gamma"
default = 1
arg_type = Float64
required = false

"--gamma-factor"
default = 1
arg_type = Float64
required = false

"--gamma-threshold"
default = 220
arg_type = Float64
required = false


# Unsharp mask parameters

"--unsharp-mask-radius"
default = 10
arg_type = Int
required = false

"--unsharp-mask-amount"
default = 2.0
arg_type = Float64
required = false

"--unsharp-mask-factor"
default = 255.0
arg_type = Float64
required = false


# Brighten parameters

"--brighten-factor"
default = 0.1
arg_type = Float64
required = false


# Preliminary ice mask parameters

"--prelim-icemask-radius"
default = 10
arg_type = Int
required = false

"--prelim-icemask-amount"
default = 2
arg_type = Int
required = false

"--prelim-icemask-factor"
default = 0.5
arg_type = Float64
required = false


# Main ice mask parameters

"--icemask-band-7-threshold"
default = 5
arg_type = Int
required = false

"--icemask-band-2-threshold"
default = 230
arg_type = Int
required = false

"--icemask-band-1-threshold"
default = 240
arg_type = Int
required = false

"--icemask-band-7-threshold-relaxed"
default = 10
arg_type = Int
required = false

"--icemask-band-1-threshold-relaxed"
default = 190
arg_type = Int
required = false

"--icemask-possible-ice-threshold"
default = 75
arg_type = Int
required = false

"--icemask-n-clusters"
default = 3
arg_type = Int
required = false

end
return nothing
end
Expand Down Expand Up @@ -456,6 +642,7 @@ function mkcli!(settings, common_args)
"landmask_single" => mkclilandmask_single!,
"preprocess" => mkclipreprocess!,
"preprocess_single" => mkclipreprocess_single!,
"preprocess_tiling_single" => mkcli_preprocess_tiling_single!,
"extractfeatures" => mkcliextract!,
"extractfeatures_single" => mkcliextract_single!,
"makeh5files" => mkclimakeh5!,
Expand Down Expand Up @@ -486,11 +673,15 @@ function main()
action = :command

"preprocess"
help = "Preprocess truecolor/falsecolor images"
help = "Label ice in a directory of truecolor & falsecolor images using full-image-based processing"
action = :command

"preprocess_single"
help = "Preprocess truecolor/falsecolor images"
help = "Label ice in a single set of truecolor & falsecolor images using full-image-based processing"
action = :command

"preprocess_tiling_single"
help = "Label ice in a single set of truecolor & falsecolor images using tile-based processing"
action = :command

"extractfeatures"
Expand Down
Loading

0 comments on commit ac928cd

Please sign in to comment.