IDSpeakIPL  v1.9.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:
42 
50 
62  GammaCorrector(const GammaCorrector& other);
63 
76 
85  GammaCorrector(GammaCorrector&& other) noexcept;
86 
95  GammaCorrector& operator=(GammaCorrector&& other) noexcept;
96 
106  void SetGammaCorrectionValue(float gammaValue);
107 
116 
125 
134 
144  PEAK_IPL_NO_DISCARD bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const;
145 
155  void ProcessInPlace(Image& image) const;
156 
167  PEAK_IPL_NO_DISCARD Image Process(const Image& inputImage) const;
168 
169 private:
170  PEAK_IPL_GAMMA_CORRECTOR_HANDLE m_backendHandle{};
171 };
172 
174 {
176 }
177 
179 {
180  if (m_backendHandle)
181  {
183  }
184 }
185 
187 {
188  *this = std::move(other);
189 }
190 
192 {
193 
194 
195  if (other.m_backendHandle)
196  {
198  }
199 
200  m_backendHandle = other.m_backendHandle;
201 }
202 
204 {
205  if (this != &other)
206  {
207  if (m_backendHandle)
208  {
210  }
211 
212  if (other.m_backendHandle)
213  {
215  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_GammaCorrector_Acquire(other.m_backendHandle); });
216  }
217  }
218 
219  m_backendHandle = other.m_backendHandle;
220 
221  return *this;
222 }
223 
225 {
226  if (this != &other)
227  {
228  if (m_backendHandle != nullptr)
229  {
231  }
232  m_backendHandle = other.m_backendHandle;
233  other.m_backendHandle = nullptr;
234  }
235 
236  return *this;
237 }
238 
239 inline void GammaCorrector::SetGammaCorrectionValue(float gammaValue)
240 {
243  m_backendHandle, reinterpret_cast<float*>(&gammaValue));
244  });
245 }
246 
248 {
249  float gammaValue;
250 
253  m_backendHandle, reinterpret_cast<float*>(&gammaValue));
254  });
255 
256  return gammaValue;
257 }
258 
260 {
261  float gammaMin;
262 
265  m_backendHandle, reinterpret_cast<float*>(&gammaMin));
266  });
267 
268  return gammaMin;
269 }
270 
272 {
273  float gammaMax;
274 
277  m_backendHandle, reinterpret_cast<float*>(&gammaMax));
278  });
279 
280  return gammaMax;
281 }
282 
283 inline bool GammaCorrector::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
284 {
285  PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
286 
289  static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
290  reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
291  });
292 
293  return isPixelFormatSupported > 0;
294 }
295 
296 inline void GammaCorrector::ProcessInPlace(Image& image) const
297 {
300  m_backendHandle, ImageBackendAccessor::BackendHandle(image));
301  });
302 }
303 
304 inline Image GammaCorrector::Process(const Image& inputImage) const
305 {
306  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
309  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
310  });
311 
312  return ImageBackendAccessor::CreateImage(outputImageHandle);
313 }
314 
315 } /* namespace ipl */
316 } /* namespace peak */
#define PEAK_IPL_NO_DISCARD
Definition: peak_ipl_backend.h:26
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:353
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 that is, it will change the input image...
Definition: peak_ipl_gamma_corrector.hpp:296
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.
PEAK_IPL_C_API PEAK_IPL_GammaCorrector_Acquire(PEAK_IPL_GAMMA_CORRECTOR_HANDLE gammaCorrectorHandle)
Increase the reference count of a gamma corrector object.
GammaCorrector & operator=(const GammaCorrector &other)
Copy assigment for GammaCorrector instance.
Definition: peak_ipl_gamma_corrector.hpp:203
PEAK_IPL_NO_DISCARD bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the gamma corrector supports the given pixel format.
Definition: peak_ipl_gamma_corrector.hpp:283
~GammaCorrector()
Destructor for the GammaCorrector instance.
Definition: peak_ipl_gamma_corrector.hpp:178
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition: peak_ipl_backend.h:357
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.
PEAK_IPL_NO_DISCARD float GammaCorrectionMax() const
Returns the maximum value of the gamma correction.
Definition: peak_ipl_gamma_corrector.hpp:271
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:41
void SetGammaCorrectionValue(float gammaValue)
Sets the values of the gamma correction.
Definition: peak_ipl_gamma_corrector.hpp:239
PEAK_IPL_NO_DISCARD Image Process(const Image &inputImage) const
Corrects the gammas of the given image.
Definition: peak_ipl_gamma_corrector.hpp:304
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.
PEAK_IPL_NO_DISCARD float GammaCorrectionValue() const
Returns the value of the gamma correction.
Definition: peak_ipl_gamma_corrector.hpp:247
PEAK_IPL_NO_DISCARD float GammaCorrectionMin() const
Returns the minimum value of the gamma correction.
Definition: peak_ipl_gamma_corrector.hpp:259
GammaCorrector()
Constructor for a new GammaCorrector instance.
Definition: peak_ipl_gamma_corrector.hpp:173