-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
479 imbrighten #480
Merged
Merged
479 imbrighten #480
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cb07a63
feat: brighten
cpaniaguam 95d4c27
test: brighten
cpaniaguam 89d480d
fix: fix to_uint8
cpaniaguam a2f24bf
Merge branch 'main' into 479-imbrighten
cpaniaguam 6fdc0ca
Merge branch 'main' into 479-imbrighten
cpaniaguam e01c6d3
Merge branch 'main' into 479-imbrighten
cpaniaguam 64297cc
Merge branch 'main' into 479-imbrighten
cpaniaguam d0926da
Update IceFloeTracker.jl
cpaniaguam 7de87c3
fix: test for imadjust
cpaniaguam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the CI fails because of this deletion. Maybe keep the
include("imadjust.jl")
and add include("brighten.jl")? It looks like there is still animadjust.jl
script, suggesting that maybe we need both?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must have done that trying to resolve merge conflicts. I think it's fixed now. Thanks.