-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 490-add-watershed-workflows
- Loading branch information
Showing
12 changed files
with
154 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
get_brighten_mask(equalized_gray_reconstructed_img, gamma_green) | ||
# Arguments | ||
- `equalized_gray_reconstructed_img`: The equalized gray reconstructed image (uint8 in Matlab). | ||
- `gamma_green`: The gamma value for the green channel (also uint8). | ||
# Returns | ||
Difference equalized_gray_reconstructed_img - gamma_green clamped between 0 and 255. | ||
""" | ||
function get_brighten_mask(equalized_gray_reconstructed_img, gamma_green) | ||
return to_uint8(equalized_gray_reconstructed_img - gamma_green) | ||
end | ||
|
||
""" | ||
imbrighten(img, brighten_mask, bright_factor) | ||
Brighten the image using a mask and a brightening factor. | ||
# Arguments | ||
- `img`: The input image. | ||
- `brighten_mask`: A mask indicating the pixels to brighten. | ||
- `bright_factor`: The factor by which to brighten the pixels. | ||
# Returns | ||
- The brightened image. | ||
""" | ||
function imbrighten(img, brighten_mask, bright_factor) | ||
img = Float64.(img) | ||
brighten_mask = brighten_mask .> 0 | ||
img[brighten_mask] .= img[brighten_mask] * bright_factor | ||
return img = to_uint8(img) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using IceFloeTracker: get_brighten_mask, imbrighten | ||
|
||
@testset "brighten tests" begin | ||
@testset "get_brighten_mask" begin | ||
img = rand(0:255, 5, 5) | ||
bumped_img = img .+ 1 | ||
mask = get_brighten_mask(img, bumped_img) | ||
@test all(mask .== 0) | ||
end | ||
|
||
@testset "imbrighten tests" begin | ||
img = [1 2; 3 4] | ||
brighten_mask = [1 0; 1 0] | ||
|
||
test_cases = [(1.25, [1 2; 4 4]), (0.1, [0 2; 0 4]), (0.9, img)] | ||
|
||
for (bright_factor, expected_result) in test_cases | ||
result = imbrighten(img, brighten_mask, bright_factor) | ||
@test result == expected_result | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
@testset "imadjust" begin | ||
Random.seed!(123) | ||
img = rand(0:255, 100, 100) | ||
sum(IceFloeTracker.imadjust(img)) == 1291155 | ||
@test sum(IceFloeTracker.imadjust(img)) == 1291155 | ||
end |