Repository navigation
Multithreading + Color Rework #234
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
Changes from 19 commits
37ebc32
06e3892
dcea45e
61b9229
59f7706
4c59dfd
056c750
7c9012c
ab78ed3
43f84f8
7098b36
e73f4d0
f7a1328
6febffe
e3e7b58
3238420
9e1e7bb
f5c0ad6
f2d3e48
657dbcf
0a59653
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Krasner marked this conversation as resolved.
Resolved
|
|
Ryan-Millard marked this conversation as resolved.
Resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #ifndef LABAPixel_H | ||
| #define LABAPixel_H | ||
|
|
||
| #include "LABPixel.h" | ||
|
|
||
| namespace ImageLib { | ||
| template <typename NumberT> | ||
| struct LABAPixel : public ImageLib::LABPixel<NumberT> { | ||
| // ----- Members ----- | ||
| NumberT alpha; | ||
|
|
||
| // ----- Constructors ----- | ||
| constexpr LABAPixel(NumberT l = 0, NumberT a = 0, NumberT b = 0, | ||
| NumberT alpha = 255) | ||
| : LABPixel<NumberT>(l, a, b), alpha(alpha) {} | ||
|
|
||
| // ----- Modifiers ----- | ||
| [[nodiscard]] inline bool operator==(const LABAPixel &other) const { | ||
| return LABPixel<NumberT>::operator==(other) && alpha == other.alpha; | ||
| } | ||
| [[nodiscard]] inline bool operator!=(const LABAPixel &other) const { | ||
| return !(*this == other); | ||
| } | ||
|
|
||
| // ----- Utilities ----- | ||
| inline void setGray(NumberT gray, NumberT alpha = 255) { | ||
| LABPixel<NumberT>::setGray(gray); | ||
| this->alpha = alpha; | ||
| } | ||
|
|
||
| } __attribute__((packed)); | ||
| } // namespace ImageLib | ||
|
|
||
| #endif // LABAPixel_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #ifndef LABPIXEL_H | ||
| #define LABPIXEL_H | ||
|
|
||
| #include "Pixel.h" | ||
|
|
||
| /* | ||
| can support signed data types | ||
| preferrably float or double | ||
| */ | ||
|
|
||
| namespace ImageLib { | ||
| template <typename NumberT> struct LABPixel : public Pixel<NumberT> { | ||
| // ----- Members ----- | ||
| NumberT l, a, b; | ||
|
|
||
| constexpr LABPixel(NumberT l = 0, NumberT a = 0, NumberT b = 0) | ||
| : l(l), a(a), b(b) {} | ||
|
|
||
| // ----- Modifiers ----- | ||
| [[nodiscard]] inline bool operator==(const LABPixel &other) const { | ||
| return l == other.l && a == other.a && b == other.b; | ||
| } | ||
| [[nodiscard]] inline bool operator!=(const LABPixel &other) const { | ||
| return !(*this == other); | ||
| } | ||
|
|
||
| // ----- Utilities ----- | ||
| inline void setGray(NumberT new_luma) { | ||
| l = new_luma; | ||
| a = b = 0; | ||
| } | ||
|
|
||
| } __attribute__((packed)); | ||
| } // namespace ImageLib | ||
|
|
||
| #endif // LABPIXEL_H |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you decide to use templates if you cast to a specific type in the implementation file?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In bilateralFilter we convert from uint8_t (rgb) to double (cielab) but in kmeans some computations are in float. For example rgb-lab conversions can still happen independent on input and output datatype. interally all the computations are in double but the user can specify what datatypes the conversion function should expect
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is perfectly fine, but I think we should be using The reason I say concepts are a good choice is because the type checking I implemented in files like |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,39 @@ | ||
| #ifndef CIELAB_H | ||
| #define CIELAB_H | ||
|
|
||
| #include "LABAPixel.h" | ||
| #include "LABPixel.h" | ||
| #include "RGBAPixel.h" | ||
| #include "RGBPixel.h" | ||
| #include <cstdint> | ||
| #include <type_traits> | ||
|
|
||
| void rgb_to_lab(const uint8_t r_u8, const uint8_t g_u8, const uint8_t b_u8, | ||
| double &out_l, double &out_a, double &out_b); | ||
| // templates must be in headers | ||
|
|
||
| template <typename Tin, typename Tout> | ||
| void rgb_to_lab(const Tin r_u8, const Tin g_u8, const Tin b_u8, Tout &out_l, | ||
| Tout &out_a, Tout &out_b); | ||
|
|
||
| template <typename Tin, typename Tout> | ||
| void lab_to_rgb(const Tin L, const Tin A, const Tin B, Tout &r_u8, Tout &g_u8, | ||
| Tout &b_u8); | ||
|
|
||
| template <typename Tin, typename Tout> | ||
| void rgb_to_lab(const ImageLib::RGBAPixel<Tin> &rgba, | ||
| ImageLib::LABAPixel<Tout> &laba); | ||
|
|
||
| template <typename Tin, typename Tout> | ||
| void rgb_to_lab(const ImageLib::RGBPixel<Tin> &rgb, | ||
| ImageLib::LABPixel<Tout> &lab); | ||
|
|
||
| template <typename Tin, typename Tout> | ||
| void lab_to_rgb(const ImageLib::LABAPixel<Tin> &laba, | ||
| ImageLib::RGBAPixel<Tout> &rgba); | ||
|
|
||
| template <typename Tin, typename Tout> | ||
| void lab_to_rgb(const ImageLib::LABPixel<Tin> &lab, | ||
| ImageLib::RGBPixel<Tout> &rgb); | ||
|
|
||
| #include "cielab_impl.h" | ||
|
|
||
| void lab_to_rgb(const double L, const double A, const double B, uint8_t &r_u8, | ||
| uint8_t &g_u8, uint8_t &b_u8); | ||
| #endif // CIELAB_H |
Uh oh!
There was an error while loading. Please reload this page.