Full_process.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. //HDR READER
  2. //https://www.flipcode.com/archives/HDR_Image_Reader.shtml
  3. #include "pch.h"
  4. #include <iostream>
  5. #include <chrono>
  6. #include <cstdlib>
  7. #include <vector>
  8. #include <ctime>
  9. #include <Eigen/Core>
  10. #include <unsupported/Eigen/Splines>
  11. #include "ImageHDR.hpp"
  12. #include "YCurve.hpp"
  13. #include "Conversion.hpp"
  14. #include "Full_process.hpp"
  15. float* exposure(float* data, unsigned int width, unsigned int height, float exposure)
  16. {
  17. ImageHDR img(data, width, height);
  18. img.exposure(exposure);
  19. float* ret = new float[width * height * 3];
  20. memcpy(ret, img.data, width * height * 3 * sizeof(float));
  21. return ret;
  22. }
  23. float* contrast(float* data, unsigned int width, unsigned int height, float constrast)
  24. {
  25. ImageHDR img(data, width, height);
  26. img.contrast(constrast);
  27. float* ret = new float[width * height * 3];
  28. memcpy(ret, img.data, width * height * 3 * sizeof(float));
  29. return ret;
  30. }
  31. float* yCurve(float* data, unsigned int width, unsigned int height, float yCs, float yCb, float yCm, float yCw, float yCh)
  32. {
  33. ImageHDR img(data, width, height);
  34. img.yCurve(yCs, yCb, yCm, yCw, yCh);
  35. float* ret = new float[width * height * 3];
  36. memcpy(ret, img.data, width * height * 3 * sizeof(float));
  37. return ret;
  38. }
  39. float* lightnessMask(float* data, unsigned int width, unsigned int height, bool lms, bool lmb, bool lmm, bool lmw, bool lmh)
  40. {
  41. ImageHDR img(data, width, height);
  42. img.lightnessMask(lms, lmb, lmm, lmw, lmh);
  43. float* ret = new float[width * height * 3];
  44. memcpy(ret, img.data, width * height * 3 * sizeof(float));
  45. return ret;
  46. }
  47. float* saturation(float* data, unsigned int width, unsigned int height, float saturation)
  48. {
  49. ImageHDR img(data, width, height);
  50. img.saturation(saturation);
  51. float* ret = new float[width * height * 3];
  52. memcpy(ret, img.data, width * height * 3 * sizeof(float));
  53. return ret;
  54. }
  55. float* colorEditor(float* data, unsigned int width, unsigned int height, float ce_sel_light_l, float ce_sel_light_h, float ce_sel_chr_l, float ce_sel_chr_h, float ce_sel_hue_l, float ce_sel_hue_h, float ce_tol, float ce_edit_hue, float ce_edit_expo, float ce_edit_con, float ce_edit_sat, bool ce_mask)
  56. {
  57. ImageHDR img(data, width, height);
  58. float sel_light[2] = { ce_sel_light_l, ce_sel_light_h };
  59. float sel_chr[2] = { ce_sel_chr_l, ce_sel_chr_h };
  60. float sel_hue[2] = { ce_sel_hue_l, ce_sel_hue_h };
  61. img.colorEditor(sel_light, sel_chr, sel_hue, ce_tol, ce_edit_hue, ce_edit_expo, ce_edit_con, ce_edit_sat, ce_mask);
  62. float* ret = new float[width * height * 3];
  63. memcpy(ret, img.data, width * height * 3 * sizeof(float));
  64. return ret;
  65. }
  66. float* full_process(float* data, unsigned int width, unsigned int height,
  67. float exposure,
  68. float contrast,
  69. float yCs, float yCb, float yCm, float yCw, float yCh,
  70. bool lms, bool lmb, bool lmm, bool lmw, bool lmh,
  71. float saturation,
  72. float ce_sel_light_l, float ce_sel_light_h, float ce_sel_chr_l, float ce_sel_chr_h, float ce_sel_hue_l, float ce_sel_hue_h, float ce_tol, float ce_edit_hue, float ce_edit_expo, float ce_edit_con, float ce_edit_sat, bool ce_mask)
  73. {
  74. ImageHDR img(data, width, height);
  75. // ******************************************
  76. img.exposure(exposure);
  77. // ******************************************
  78. // ******************************************
  79. img.contrast(contrast);
  80. // ******************************************
  81. // ******************************************
  82. img.yCurve(yCs, yCb, yCm, yCw, yCh);
  83. // ******************************************
  84. // ******************************************
  85. img.lightnessMask(lms, lmb, lmm, lmw, lmh);
  86. // ******************************************
  87. // ******************************************
  88. img.saturation(saturation);
  89. // ******************************************
  90. // ******************************************
  91. float sel_light[2] = {ce_sel_light_l, ce_sel_light_h};
  92. float sel_chr[2] = {ce_sel_chr_l, ce_sel_chr_h};
  93. float sel_hue[2] = {ce_sel_hue_l, ce_sel_hue_h};
  94. img.colorEditor(sel_light, sel_chr, sel_hue, ce_tol, ce_edit_hue, ce_edit_expo, ce_edit_con, ce_edit_sat, ce_mask);
  95. // ******************************************
  96. float *ret = new float[width*height*3];
  97. memcpy(ret, img.data, width * height * 3 * sizeof(float));
  98. return ret;
  99. }