TonemapDurand.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.PhotoModule;
  3. using OpenCVForUnity.UtilsModule;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Runtime.InteropServices;
  7. namespace OpenCVForUnity.XphotoModule
  8. {
  9. // C++: class TonemapDurand
  10. /**
  11. * This algorithm decomposes image into two layers: base layer and detail layer using bilateral filter
  12. * and compresses contrast of the base layer thus preserving all the details.
  13. *
  14. * This implementation uses regular bilateral filter from OpenCV.
  15. *
  16. * Saturation enhancement is possible as in cv::TonemapDrago.
  17. *
  18. * For more information see CITE: DD02 .
  19. */
  20. public class TonemapDurand : Tonemap
  21. {
  22. protected override void Dispose(bool disposing)
  23. {
  24. try
  25. {
  26. if (disposing)
  27. {
  28. }
  29. if (IsEnabledDispose)
  30. {
  31. if (nativeObj != IntPtr.Zero)
  32. xphoto_TonemapDurand_delete(nativeObj);
  33. nativeObj = IntPtr.Zero;
  34. }
  35. }
  36. finally
  37. {
  38. base.Dispose(disposing);
  39. }
  40. }
  41. protected internal TonemapDurand(IntPtr addr) : base(addr) { }
  42. // internal usage only
  43. public static new TonemapDurand __fromPtr__(IntPtr addr) { return new TonemapDurand(addr); }
  44. //
  45. // C++: float cv::xphoto::TonemapDurand::getSaturation()
  46. //
  47. public float getSaturation()
  48. {
  49. ThrowIfDisposed();
  50. return xphoto_TonemapDurand_getSaturation_10(nativeObj);
  51. }
  52. //
  53. // C++: void cv::xphoto::TonemapDurand::setSaturation(float saturation)
  54. //
  55. public void setSaturation(float saturation)
  56. {
  57. ThrowIfDisposed();
  58. xphoto_TonemapDurand_setSaturation_10(nativeObj, saturation);
  59. }
  60. //
  61. // C++: float cv::xphoto::TonemapDurand::getContrast()
  62. //
  63. public float getContrast()
  64. {
  65. ThrowIfDisposed();
  66. return xphoto_TonemapDurand_getContrast_10(nativeObj);
  67. }
  68. //
  69. // C++: void cv::xphoto::TonemapDurand::setContrast(float contrast)
  70. //
  71. public void setContrast(float contrast)
  72. {
  73. ThrowIfDisposed();
  74. xphoto_TonemapDurand_setContrast_10(nativeObj, contrast);
  75. }
  76. //
  77. // C++: float cv::xphoto::TonemapDurand::getSigmaSpace()
  78. //
  79. public float getSigmaSpace()
  80. {
  81. ThrowIfDisposed();
  82. return xphoto_TonemapDurand_getSigmaSpace_10(nativeObj);
  83. }
  84. //
  85. // C++: void cv::xphoto::TonemapDurand::setSigmaSpace(float sigma_space)
  86. //
  87. public void setSigmaSpace(float sigma_space)
  88. {
  89. ThrowIfDisposed();
  90. xphoto_TonemapDurand_setSigmaSpace_10(nativeObj, sigma_space);
  91. }
  92. //
  93. // C++: float cv::xphoto::TonemapDurand::getSigmaColor()
  94. //
  95. public float getSigmaColor()
  96. {
  97. ThrowIfDisposed();
  98. return xphoto_TonemapDurand_getSigmaColor_10(nativeObj);
  99. }
  100. //
  101. // C++: void cv::xphoto::TonemapDurand::setSigmaColor(float sigma_color)
  102. //
  103. public void setSigmaColor(float sigma_color)
  104. {
  105. ThrowIfDisposed();
  106. xphoto_TonemapDurand_setSigmaColor_10(nativeObj, sigma_color);
  107. }
  108. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  109. const string LIBNAME = "__Internal";
  110. #else
  111. const string LIBNAME = "opencvforunity";
  112. #endif
  113. // C++: float cv::xphoto::TonemapDurand::getSaturation()
  114. [DllImport(LIBNAME)]
  115. private static extern float xphoto_TonemapDurand_getSaturation_10(IntPtr nativeObj);
  116. // C++: void cv::xphoto::TonemapDurand::setSaturation(float saturation)
  117. [DllImport(LIBNAME)]
  118. private static extern void xphoto_TonemapDurand_setSaturation_10(IntPtr nativeObj, float saturation);
  119. // C++: float cv::xphoto::TonemapDurand::getContrast()
  120. [DllImport(LIBNAME)]
  121. private static extern float xphoto_TonemapDurand_getContrast_10(IntPtr nativeObj);
  122. // C++: void cv::xphoto::TonemapDurand::setContrast(float contrast)
  123. [DllImport(LIBNAME)]
  124. private static extern void xphoto_TonemapDurand_setContrast_10(IntPtr nativeObj, float contrast);
  125. // C++: float cv::xphoto::TonemapDurand::getSigmaSpace()
  126. [DllImport(LIBNAME)]
  127. private static extern float xphoto_TonemapDurand_getSigmaSpace_10(IntPtr nativeObj);
  128. // C++: void cv::xphoto::TonemapDurand::setSigmaSpace(float sigma_space)
  129. [DllImport(LIBNAME)]
  130. private static extern void xphoto_TonemapDurand_setSigmaSpace_10(IntPtr nativeObj, float sigma_space);
  131. // C++: float cv::xphoto::TonemapDurand::getSigmaColor()
  132. [DllImport(LIBNAME)]
  133. private static extern float xphoto_TonemapDurand_getSigmaColor_10(IntPtr nativeObj);
  134. // C++: void cv::xphoto::TonemapDurand::setSigmaColor(float sigma_color)
  135. [DllImport(LIBNAME)]
  136. private static extern void xphoto_TonemapDurand_setSigmaColor_10(IntPtr nativeObj, float sigma_color);
  137. // native support for java finalize()
  138. [DllImport(LIBNAME)]
  139. private static extern void xphoto_TonemapDurand_delete(IntPtr nativeObj);
  140. }
  141. }