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

Fix wrong pixel channel truncation in binary threshold and truncate threshold #697

Open
marco-langer opened this issue Jun 27, 2022 · 2 comments · May be fixed by #701
Open

Fix wrong pixel channel truncation in binary threshold and truncate threshold #697

marco-langer opened this issue Jun 27, 2022 · 2 comments · May be fixed by #701
Labels
ext/image_processing boost/gil/extension/image_processing
Milestone

Comments

@marco-langer
Copy link
Contributor

marco-langer commented Jun 27, 2022

Actual behavior

gil::threshold_truncate() and gil::threshold_binary() from gil/image_processing/truncate.hpp employ a hard-coded value of 0 for the channel minimum value and a value of std::numeric_limits<channel_t>::max() for the maximum value. This works only for unsigned integer channel types such as gil::rgb8_pixel_t and gil::gray8_pixel_t, but does not work for signed channel types and also not for floating point types whose value range is limited from 0.0 to 1.0.

Edit: Otsu thresholding also employs std::numeric_limits, which is invalid for scoped channels.

Expected behavior

Correct channel value truncation according to the channel min/max values.

@mloskot
Copy link
Member

mloskot commented Jun 27, 2022

I may vaguely recall that I agreed with @miralshah365 to begin with support unsigned integer channel types only.
There should be at least a static assertion though as a documentation of such limitation.

It would be nice to have this fixed/improved indeed.

@mloskot mloskot added the ext/image_processing boost/gil/extension/image_processing label Jun 27, 2022
@marco-langer
Copy link
Contributor Author

As far as I see there is currently only one static assert making sure that input and output views are compatible.

@mloskot mloskot added this to the Boost 1.81+ milestone Jul 7, 2022
@mloskot mloskot modified the milestones: Boost 1.82, Boost 1.83+ Mar 31, 2023
@mloskot mloskot modified the milestones: Boost 1.86, 1.87.0 Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ext/image_processing boost/gil/extension/image_processing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants