IDS peak IPL v1.14.0
Loading...
Searching...
No Matches
peak_ipl_gamma_corrector.hpp
Go to the documentation of this file.
1
11#pragma once
12
18
22namespace peak
23{
24namespace ipl
25{
26
27class Image;
28
32class GammaCorrector final
33{
34public:
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
145
157 void ProcessInPlace(Image& image) const;
158
171 PEAK_IPL_NO_DISCARD Image Process(const Image& inputImage) const;
172
173private:
174 PEAK_IPL_GAMMA_CORRECTOR_HANDLE m_backendHandle{};
175};
176
181
183{
184 if (m_backendHandle)
185 {
187 }
188}
189
191{
192 *this = std::move(other);
193}
194
196{
197
198
199 if (other.m_backendHandle)
200 {
202 }
203
204 m_backendHandle = other.m_backendHandle;
205}
206
208{
209 if (this != &other)
210 {
211 if (m_backendHandle)
212 {
214 }
215
216 if (other.m_backendHandle)
217 {
219 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_GammaCorrector_Acquire(other.m_backendHandle); });
220 }
221 }
222
223 m_backendHandle = other.m_backendHandle;
224
225 return *this;
226}
227
229{
230 if (this != &other)
231 {
232 if (m_backendHandle != nullptr)
233 {
235 }
236 m_backendHandle = other.m_backendHandle;
237 other.m_backendHandle = nullptr;
238 }
239
240 return *this;
241}
242
243inline void GammaCorrector::SetGammaCorrectionValue(float gammaValue)
244{
247 m_backendHandle, reinterpret_cast<float*>(&gammaValue));
248 });
249}
250
252{
253 float gammaValue;
254
257 m_backendHandle, reinterpret_cast<float*>(&gammaValue));
258 });
259
260 return gammaValue;
261}
262
264{
265 float gammaMin;
266
269 m_backendHandle, reinterpret_cast<float*>(&gammaMin));
270 });
271
272 return gammaMin;
273}
274
276{
277 float gammaMax;
278
281 m_backendHandle, reinterpret_cast<float*>(&gammaMax));
282 });
283
284 return gammaMax;
285}
286
288{
289 PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
290
293 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
294 reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
295 });
296
297 return isPixelFormatSupported > 0;
298}
299
300inline void GammaCorrector::ProcessInPlace(Image& image) const
301{
304 m_backendHandle, ImageBackendAccessor::BackendHandle(image));
305 });
306}
307
308inline Image GammaCorrector::Process(const Image& inputImage) const
309{
310 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
313 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
314 });
315
316 return ImageBackendAccessor::CreateImage(outputImageHandle);
317}
318
319} /* namespace ipl */
320} /* namespace peak */
Applies gamma correction to the data.
Definition peak_ipl_gamma_corrector.hpp:33
GammaCorrector & operator=(const GammaCorrector &other)
Copy assigment for GammaCorrector instance.
Definition peak_ipl_gamma_corrector.hpp:207
~GammaCorrector()
Destructor for the GammaCorrector instance.
Definition peak_ipl_gamma_corrector.hpp:182
float GammaCorrectionMin() const
Returns the minimum value of the gamma correction.
Definition peak_ipl_gamma_corrector.hpp:263
Image Process(const Image &inputImage) const
Corrects the gammas of the given image.
Definition peak_ipl_gamma_corrector.hpp:308
float GammaCorrectionValue() const
Returns the value of the gamma correction.
Definition peak_ipl_gamma_corrector.hpp:251
void SetGammaCorrectionValue(float gammaValue)
Sets the values of the gamma correction.
Definition peak_ipl_gamma_corrector.hpp:243
float GammaCorrectionMax() const
Returns the maximum value of the gamma correction.
Definition peak_ipl_gamma_corrector.hpp:275
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the gamma corrector supports the given pixel format.
Definition peak_ipl_gamma_corrector.hpp:287
GammaCorrector()
Constructor for a new GammaCorrector instance.
Definition peak_ipl_gamma_corrector.hpp:177
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:300
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:40
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:39
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:182
The "peak::ipl" namespace contains the whole image processing library.
Definition peak_ipl_binning.hpp:23
struct PEAK_IPL_GAMMA_CORRECTOR * PEAK_IPL_GAMMA_CORRECTOR_HANDLE
Definition peak_ipl_backend.h:365
PEAK_IPL_C_API PEAK_IPL_GammaCorrector_SetGammaCorrectionValue(PEAK_IPL_GAMMA_CORRECTOR_HANDLE gammaCorrectorHandle, float *gammaValue)
Sets the value of the gamma correction.
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_ProcessInPlace(PEAK_IPL_GAMMA_CORRECTOR_HANDLE gammaCorrectorHandle, PEAK_IPL_IMAGE_HANDLE imageHandle)
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_C_API PEAK_IPL_GammaCorrector_Acquire(PEAK_IPL_GAMMA_CORRECTOR_HANDLE gammaCorrectorHandle)
Increase the reference count of a gamma corrector object.
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition peak_ipl_backend.h:369
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_Construct(PEAK_IPL_GAMMA_CORRECTOR_HANDLE *gammaCorrectorHandle)
Creates a gamma corrector.
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_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
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_backend.h:26
int32_t PEAK_IPL_PIXEL_FORMAT
Definition peak_ipl_backend.h:188
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.
#define PEAK_IPL_C_ABI_PREFIX
Definition peak_ipl_dll_defines.h:16