ImageHDR.hpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // This file is part of HDRip.
  2. //
  3. // HDRip is free software: you can redistribute it and/or modify it
  4. // under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation, either version 3 of the License, or
  6. // (at your option) any later version.
  7. //
  8. // HDRip is distributed in the hope that it will be useful, but
  9. // WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with HDRip. If not, see <https://www.gnu.org/licenses/>.
  15. //
  16. // HDRip project
  17. // Author : Rémi Synave
  18. // Contact : remi.synave@univ-littoral.fr
  19. #ifndef IMAGEHDR__HPP
  20. #define IMAGEHDR__HPP
  21. #include <cstring>
  22. #include <iostream>
  23. #include "Eigen/Core"
  24. #include "Colorspace.hpp"
  25. class ImageHDR {
  26. public:
  27. bool linear;
  28. unsigned int width, height;
  29. float* data; //3 float per pixel. data size should be width*height*3
  30. float min_intensity, max_intensity;
  31. unsigned int colorspace;
  32. public:
  33. // Constructors/Loading
  34. ImageHDR(float* d = NULL, unsigned int w = 0, unsigned int h = 0);
  35. // Destructor
  36. ~ImageHDR() {delete[] data;};// devrait être delete[] data;
  37. // save - getter/setter
  38. float getR(const unsigned int i, const unsigned j) const { return data[(j * width + i) * 3]; };
  39. float getG(const unsigned int i, const unsigned j) const { return data[(j * width + i) * 3 + 1]; };
  40. float getB(const unsigned int i, const unsigned j) const { return data[(j * width + i) * 3 + 2]; };
  41. void setR(const unsigned int i, const unsigned j, float r) { data[(j * width + i) * 3] = r; };
  42. void setG(const unsigned int i, const unsigned j, float g) { data[(j * width + i) * 3 + 1] = g; };
  43. void setB(const unsigned int i, const unsigned j, float b) { data[(j * width + i) * 3 + 2] = b; };
  44. void display_pixel(unsigned int i) const;
  45. void display_pixel(unsigned int i, unsigned int j) const;
  46. void display_debug() const;
  47. // image processing
  48. void linear_to_non_linear();
  49. void non_linear_to_linear();
  50. void exposure(const float ev);
  51. void contrast(const float c);
  52. void ycurve_histogram_regularization(float* colorDataY, float* colorDataFY);
  53. void yCurve(float s, float b, float m, float w, float h);
  54. void lightnessMask(bool s, bool b, bool m, bool w, bool h);
  55. void saturation(float s);
  56. void colorEditor(float* selection_lightness, float* selection_chroma, float* selection_hue, float tolerance, float edit_hue, float edit_exposure, float edit_contrast, float edit_saturation, bool mask);
  57. private:
  58. // Conversions
  59. Eigen::VectorXf to_EigenVector() const;
  60. };
  61. #endif