CVB++ 15.0
test_images.hpp
1#pragma once
2
3#if defined _WIN32
4
5# include "../_cexports/c_foundation.h"
6
7# include "../global.hpp"
8# include "../image.hpp"
9# include "../exception.hpp"
10# include "../size_2d.hpp"
11
12# include "transform_2d.hpp"
13
14# include <memory>
15
16namespace Cvb
17{
18 CVB_BEGIN_INLINE_NS
19
20 namespace Foundation
21 {
22
24
28 namespace TestImages
29 {
30
45
46 namespace Private
47 {
48 /* Decompose the enumerated test image data types into the set of parameters
49 * required by the original C-function. */
50 inline void DecomposeTestImageDataType(TestImageDataType dt, int &bitsPerPixel, bool &isSigned, bool &isFloat)
51 {
52 switch (dt)
53 {
55 bitsPerPixel = 32;
56 isSigned = true;
57 isFloat = true;
58 break;
60 bitsPerPixel = 16;
61 isSigned = true;
62 isFloat = false;
63 break;
65 bitsPerPixel = 32;
66 isSigned = true;
67 isFloat = false;
68 break;
70 bitsPerPixel = 16;
71 isSigned = true;
72 isFloat = false;
73 break;
75 bitsPerPixel = 8;
76 isSigned = false;
77 isFloat = false;
78 break;
79 default:
80 throw std::invalid_argument("unknown test image data type requested");
81 }
82 }
83 } /* namespace Private */
84
87
96 {
97 int bitsPerPixel;
98 bool isSigned, isFloat;
99 Private::DecomposeTestImageDataType(dataType, bitsPerPixel, isSigned, isFloat);
100
101 return Internal::DoResCallObjectOut<Image>([&](void *&resimg) {
102 return CVB_CALL_CAPI(
103 CreateFilterTestImage(size.Width(), size.Height(), numPlanes, bitsPerPixel, isSigned, isFloat, resimg));
104 });
105 }
106
108
120 Axis axis, double offset = 0.0, double slope = 1.0)
121 {
122 if (axis == Axis::NoAxis)
123 {
124 throw std::invalid_argument("creating the test image needs at least one axis selected");
125 }
126
127 bool axisHorizontal = axis == Axis::X || axis == Axis::Both;
128 bool axisVertical = axis == Axis::Y || axis == Axis::Both;
129
130 int bitsPerPixel;
131 bool isSigned, isFloat;
132 Private::DecomposeTestImageDataType(dataType, bitsPerPixel, isSigned, isFloat);
133
134 return Internal::DoResCallObjectOut<Image>([&](void *&resimg) {
135 return CVB_CALL_CAPI(CreateGreyRamp(size.Width(), size.Height(), numPlanes, bitsPerPixel, isSigned, isFloat,
136 offset, slope, axisHorizontal, axisVertical, resimg));
137 });
138 }
139
140 } /* namespace TestImages */
141
143
146
147 } /* namespace Foundation */
148 CVB_END_INLINE_NS
149} /* namespace Cvb */
150
151#endif
Stores a pair of numbers that represents the width and the height of a subject, typically a rectangle...
Definition size_2d.hpp:20
T Height() const noexcept
Gets the vertical component of the size.
Definition size_2d.hpp:77
T Width() const noexcept
Gets the horizontal component of the size.
Definition size_2d.hpp:57
cvbres_t CreateFilterTestImage(long Width, long Height, long Dimension, long BitsPerPixel, cvbbool_t Signed, cvbbool_t Float, IMG &ImgOut)
cvbres_t CreateGreyRamp(long Width, long Height, long Dimension, long BitsPerPixel, cvbbool_t Signed, cvbbool_t Float, double Offset, double Slope, cvbbool_t AxisHorizontal, cvbbool_t AxisVertical, IMG &ImgOut)
Namespace for collection of test image generating functions from the Foundation package.
Definition test_images.hpp:29
TestImageDataType
Data types usable for test image generation.
Definition test_images.hpp:33
@ Float32
32 bits per pixel floating point data
Definition test_images.hpp:43
@ Unsigned16
Unsigned 16 bits per pixel integer data.
Definition test_images.hpp:37
@ Signed16
Signed 16 bits per pixel integer data.
Definition test_images.hpp:39
@ Signed32
Signed 32 bits per pixel integer data.
Definition test_images.hpp:41
@ Unsigned8
Unsigned 8 bits per pixel integer data.
Definition test_images.hpp:35
std::unique_ptr< Image > CreateJaehneImage(Size2D< int > size, int numPlanes, TestImageDataType dataType)
Create a filter test image as suggested by Prof. Jaehne, suitable for investigating the isotropy char...
Definition test_images.hpp:95
std::unique_ptr< Image > CreateRampImage(Size2D< int > size, int numPlanes, TestImageDataType dataType, Axis axis, double offset=0.0, double slope=1.0)
Create a gray ramp test image.
Definition test_images.hpp:119
Axis
Axis enumeration.
Definition transform_2d.hpp:78
Namespace for the Foundation package.
Definition decl_metric_aqs12_calibration_piece.hpp:11
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17