operations.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Copyright 2013 Lovell Fuller and others.
  2. // SPDX-License-Identifier: Apache-2.0
  3. #ifndef SRC_OPERATIONS_H_
  4. #define SRC_OPERATIONS_H_
  5. #include <algorithm>
  6. #include <functional>
  7. #include <memory>
  8. #include <tuple>
  9. #include <vips/vips8>
  10. using vips::VImage;
  11. namespace sharp {
  12. /*
  13. * Tint an image using the specified chroma, preserving the original image luminance
  14. */
  15. VImage Tint(VImage image, double const a, double const b);
  16. /*
  17. * Stretch luminance to cover full dynamic range.
  18. */
  19. VImage Normalise(VImage image, int const lower, int const upper);
  20. /*
  21. * Contrast limiting adapative histogram equalization (CLAHE)
  22. */
  23. VImage Clahe(VImage image, int const width, int const height, int const maxSlope);
  24. /*
  25. * Gamma encoding/decoding
  26. */
  27. VImage Gamma(VImage image, double const exponent);
  28. /*
  29. * Flatten image to remove alpha channel
  30. */
  31. VImage Flatten(VImage image, std::vector<double> flattenBackground);
  32. /*
  33. * Produce the "negative" of the image.
  34. */
  35. VImage Negate(VImage image, bool const negateAlpha);
  36. /*
  37. * Gaussian blur. Use sigma of -1.0 for fast blur.
  38. */
  39. VImage Blur(VImage image, double const sigma);
  40. /*
  41. * Convolution with a kernel.
  42. */
  43. VImage Convolve(VImage image, int const width, int const height,
  44. double const scale, double const offset, std::unique_ptr<double[]> const &kernel_v);
  45. /*
  46. * Sharpen flat and jagged areas. Use sigma of -1.0 for fast sharpen.
  47. */
  48. VImage Sharpen(VImage image, double const sigma, double const m1, double const m2,
  49. double const x1, double const y2, double const y3);
  50. /*
  51. Threshold an image
  52. */
  53. VImage Threshold(VImage image, double const threshold, bool const thresholdColor);
  54. /*
  55. Perform boolean/bitwise operation on image color channels - results in one channel image
  56. */
  57. VImage Bandbool(VImage image, VipsOperationBoolean const boolean);
  58. /*
  59. Perform bitwise boolean operation between images
  60. */
  61. VImage Boolean(VImage image, VImage imageR, VipsOperationBoolean const boolean);
  62. /*
  63. Trim an image
  64. */
  65. VImage Trim(VImage image, std::vector<double> background, double const threshold);
  66. /*
  67. * Linear adjustment (a * in + b)
  68. */
  69. VImage Linear(VImage image, std::vector<double> const a, std::vector<double> const b);
  70. /*
  71. * Unflatten
  72. */
  73. VImage Unflatten(VImage image);
  74. /*
  75. * Recomb with a Matrix of the given bands/channel size.
  76. * Eg. RGB will be a 3x3 matrix.
  77. */
  78. VImage Recomb(VImage image, std::unique_ptr<double[]> const &matrix);
  79. /*
  80. * Modulate brightness, saturation, hue and lightness
  81. */
  82. VImage Modulate(VImage image, double const brightness, double const saturation,
  83. int const hue, double const lightness);
  84. /*
  85. * Ensure the image is in a given colourspace
  86. */
  87. VImage EnsureColourspace(VImage image, VipsInterpretation colourspace);
  88. /*
  89. * Split and crop each frame, reassemble, and update pageHeight.
  90. */
  91. VImage CropMultiPage(VImage image, int left, int top, int width, int height,
  92. int nPages, int *pageHeight);
  93. /*
  94. * Split into frames, embed each frame, reassemble, and update pageHeight.
  95. */
  96. VImage EmbedMultiPage(VImage image, int left, int top, int width, int height,
  97. VipsExtend extendWith, std::vector<double> background, int nPages, int *pageHeight);
  98. } // namespace sharp
  99. #endif // SRC_OPERATIONS_H_