IDS peak IPL  v1.7.0
peak_ipl_gamma_corrector.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
18 
22 namespace peak
23 {
24 namespace ipl
25 {
26 
27 class Image;
28 
32 class GammaCorrector final
33 {
34 public:
37  GammaCorrector(const GammaCorrector& other) = delete;
38  GammaCorrector& operator=(const GammaCorrector& other) = delete;
39  GammaCorrector(GammaCorrector&& other) noexcept;
40  GammaCorrector& operator=(GammaCorrector&& other) noexcept;
41 
51  void SetGammaCorrectionValue(float gammaValue);
52 
60  float GammaCorrectionValue() const;
61 
69  float GammaCorrectionMin() const;
70 
78  float GammaCorrectionMax() const;
79 
89  bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const;
90 
100  void ProcessInPlace(Image& image) const;
101 
112  Image Process(const Image& inputImage) const;
113 
114 private:
115  PEAK_IPL_GAMMA_CORRECTOR_HANDLE m_backendHandle{};
116 };
117 
119 {
121 }
122 
124 {
125  if (m_backendHandle)
126  {
128  }
129 }
130 
132 {
133  *this = std::move(other);
134 }
135 
137 {
138  if (this != &other)
139  {
141  m_backendHandle = other.m_backendHandle;
142  other.m_backendHandle = nullptr;
143  }
144 
145  return *this;
146 }
147 
148 inline void GammaCorrector::SetGammaCorrectionValue(float gammaValue)
149 {
152  m_backendHandle, reinterpret_cast<float*>(&gammaValue));
153  });
154 }
155 
157 {
158  float gammaValue;
159 
162  m_backendHandle, reinterpret_cast<float*>(&gammaValue));
163  });
164 
165  return gammaValue;
166 }
167 
169 {
170  float gammaMin;
171 
174  m_backendHandle, reinterpret_cast<float*>(&gammaMin));
175  });
176 
177  return gammaMin;
178 }
179 
181 {
182  float gammaMax;
183 
186  m_backendHandle, reinterpret_cast<float*>(&gammaMax));
187  });
188 
189  return gammaMax;
190 }
191 
192 inline bool GammaCorrector::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
193 {
194  PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
195 
198  static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
199  reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
200  });
201 
202  return isPixelFormatSupported > 0;
203 }
204 
205 inline void GammaCorrector::ProcessInPlace(Image& image) const
206 {
209  m_backendHandle, ImageBackendAccessor::BackendHandle(image));
210  });
211 }
212 
213 inline Image GammaCorrector::Process(const Image& inputImage) const
214 {
215  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
218  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
219  });
220 
221  return ImageBackendAccessor::CreateImage(outputImageHandle);
222 }
223 
224 } /* namespace ipl */
225 } /* namespace peak */
PEAK_IPL_C_API PEAK_IPL_GammaCorrector_SetGammaCorrectionValue(PEAK_IPL_GAMMA_CORRECTOR_HANDLE gammaCorrectorHandle, float *gammaValue)
Sets the value of the gamma correction.
#define PEAK_IPL_C_ABI_PREFIX
Definition: peak_ipl_dll_defines.h:16
PixelFormatName
Enum holding the possible pixel format names.
Definition: peak_ipl_simple_types.hpp:38
struct PEAK_IPL_GAMMA_CORRECTOR * PEAK_IPL_GAMMA_CORRECTOR_HANDLE
Definition: peak_ipl_backend.h:322
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
PEAK_IPL_C_API PEAK_IPL_GammaCorrector_Construct(PEAK_IPL_GAMMA_CORRECTOR_HANDLE *gammaCorrectorHandle)
Creates a gamma corrector.
PEAK_IPL_C_API PEAK_IPL_GammaCorrector_ProcessInPlace(PEAK_IPL_GAMMA_CORRECTOR_HANDLE gammaCorrectorHandle, PEAK_IPL_IMAGE_HANDLE imageHandle)
Corrects the gammas of the given image.
Applies gamma correction to the data.
Definition: peak_ipl_gamma_corrector.hpp:32
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:182
void ProcessInPlace(Image &image) const
Corrects the gammas of the given image in place i.e. it will change the input image.
Definition: peak_ipl_gamma_corrector.hpp:205
Stores the pixel format, width and height of an image and the pointer to the image buffer...
Definition: peak_ipl_image.hpp:39
PEAK_IPL_C_API PEAK_IPL_GammaCorrector_Destruct(PEAK_IPL_GAMMA_CORRECTOR_HANDLE gammaCorrectorHandle)
Destroys the gamma corrector associated with the given handle.
PEAK_IPL_C_API PEAK_IPL_GammaCorrector_GetIsPixelFormatSupported(PEAK_IPL_GAMMA_CORRECTOR_HANDLE gammaCorrectorHandle, PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_BOOL8 *isPixelFormatSupported)
Asks the given gamma corrector whether it supports the given pixel format.
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the gamma corrector supports the given pixel format.
Definition: peak_ipl_gamma_corrector.hpp:192
~GammaCorrector()
Definition: peak_ipl_gamma_corrector.hpp:123
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition: peak_ipl_backend.h:326
GammaCorrector & operator=(const GammaCorrector &other)=delete
PEAK_IPL_C_API PEAK_IPL_GammaCorrector_GetGammaCorrectionMin(PEAK_IPL_GAMMA_CORRECTOR_HANDLE gammaCorrectorHandle, float *gammaMin)
Returns the minimum gamma corrector value which can be set.
float GammaCorrectionMax() const
Returns the maximum value of the gamma correction.
Definition: peak_ipl_gamma_corrector.hpp:180
PEAK_IPL_C_API PEAK_IPL_GammaCorrector_GetGammaCorrectionMax(PEAK_IPL_GAMMA_CORRECTOR_HANDLE gammaCorrectorHandle, float *gammaMax)
Returns the maximum gamma corrector value which can be set.
int8_t PEAK_IPL_BOOL8
Definition: peak_ipl_backend.h:25
void SetGammaCorrectionValue(float gammaValue)
Sets the values of the gamma correction.
Definition: peak_ipl_gamma_corrector.hpp:148
Image Process(const Image &inputImage) const
Corrects the gammas of the given image.
Definition: peak_ipl_gamma_corrector.hpp:213
PEAK_IPL_C_API PEAK_IPL_GammaCorrector_Process(PEAK_IPL_GAMMA_CORRECTOR_HANDLE gammaCorrectorHandle, PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Corrects the gammas of the given image.
PEAK_IPL_C_API PEAK_IPL_GammaCorrector_GetGammaCorrectionValue(PEAK_IPL_GAMMA_CORRECTOR_HANDLE gammaCorrectorHandle, float *gammaValue)
Returns the gamma corrector value.
float GammaCorrectionValue() const
Returns the value of the gamma correction.
Definition: peak_ipl_gamma_corrector.hpp:156
float GammaCorrectionMin() const
Returns the minimum value of the gamma correction.
Definition: peak_ipl_gamma_corrector.hpp:168
GammaCorrector()
Definition: peak_ipl_gamma_corrector.hpp:118