Skip to content
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

AdjustBrightness and AdjustContrast without clamp01 #76

Closed
itan1 opened this issue Jan 3, 2023 · 1 comment · Fixed by #77
Closed

AdjustBrightness and AdjustContrast without clamp01 #76

itan1 opened this issue Jan 3, 2023 · 1 comment · Fixed by #77

Comments

@itan1
Copy link
Contributor

itan1 commented Jan 3, 2023

Currently the output images are clamped with clamp01 in AdjustBrightness (here) and AdjustContrast (here).

I am working with medical data with a different grayscale range than [0,1] so I would like to use the augmentation methods but without clamping. Was there a specific reason to use the clamping? Can I add an optional clamp flag like below?

function adjustcontrast!(dst::AbstractArray{U}, img::AbstractArray{T}, factor; clamp=true) where {T, U}
    map!(dst, img) do x
        convert(U, clamp ? clamp01(x * factor) : x * factor)
    end
end
@lorenzoh
Copy link
Member

lorenzoh commented Jan 6, 2023

The reason for the default clamping is that the default low-memory color type is RGB{N0f8} which is represented under the hood as UInt8s. When trying to convert a number outside the inveral [0, 1] back to that representation, an error is thrown.

Happy to accept a PR adding the clamp = true flag for AdjustBrightness and AdjustContrast :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants