9#include "../_cexports/c_img.h"
11#include "../global.hpp"
12#include "../data_type.hpp"
14#include "../_decl/decl_image_plane.hpp"
15#include "../_decl/decl_vpat.hpp"
16#include "../_decl/decl_linear_access.hpp"
17#include "../_decl/decl_image.hpp"
18#include "../plane.hpp"
19#include "../_decl/decl_wrapped_image.hpp"
29 if (plane.
Rank() != 2)
30 throw std::runtime_error(
"only two dimensional planes can be converted to image planes");
32 planeImage_ = WrappedImage::FromArray(plane);
46 if (linearAccess.
XInc() != dataType.BytesPerPixel())
48 auto size =
Parent().Size();
49 if (linearAccess.
YInc()
52 basePtr = linearAccess.
BasePtr();
66 void *basePtr =
nullptr;
69 if (!CExports::GetLinearAccess(
Handle(),
static_cast<CExports::cvbdim_t
>(plane_), &basePtr, &xInc, &yInc))
102 return Internal::DoBoolCallObjectOut<Image>([&](
void *&img) {
109 if (position.
X() < 0 || position.
Y() < 0 || position.
X() >=
Parent().Width() || position.
Y() >=
Parent().Height())
117 if (dataType.IsFloat())
119 switch (dataType.BytesPerPixel())
122 val =
static_cast<double>(vpat.Value<
float>(position));
126 val = vpat.Value<
double>(position);
133 else if (dataType.IsSignedInteger())
135 switch (dataType.BytesPerPixel())
138 val =
static_cast<double>(vpat.Value<
std::int8_t>(position));
142 val =
static_cast<double>(vpat.Value<
std::int16_t>(position));
146 val =
static_cast<double>(vpat.Value<
std::int32_t>(position));
150 val =
static_cast<double>(vpat.Value<
std::int64_t>(position));
159 switch (dataType.BytesPerPixel())
162 val =
static_cast<double>(vpat.Value<
std::uint8_t>(position));
166 val =
static_cast<double>(vpat.Value<
std::uint16_t>(position));
170 val =
static_cast<double>(vpat.Value<
std::uint32_t>(position));
174 val =
static_cast<double>(vpat.Value<
std::uint64_t>(position));
185 template <
class Type>
188 return ContiguousIterator<Type>(
reinterpret_cast<Type *
>(
ContiguousAccess()), 0);
191 template <
class Type>
195 return ContiguousIterator<Type>(
reinterpret_cast<Type *
>(
ContiguousAccess()), size.Width() * size.Height());
198 template <
class Type>
204 template <
class Type>
210 template <
class Type>
213 return ContiguousConstIterator<Type>(
reinterpret_cast<Type *
>(
ContiguousAccess()), 0);
216 template <
class Type>
220 return ContiguousConstIterator<Type>(
reinterpret_cast<Type *
>(
ContiguousAccess()), size.Width() * size.Height());
223 template <
class Type>
229 template <
class Type>
235 template <
class Type>
241 template <
class Type>
248 template <
class Type>
254 template <
class Type>
260 template <
class Type>
266 template <
class Type>
273 template <
class Type>
279 template <
class Type>
285 template <
class Type>
288 return VpatIterator<Type>(
Vpat(),
Parent().Size());
291 template <
class Type>
298 template <
class Type>
304 template <
class Type>
311 template <
class Type>
314 return VpatConstIterator<Type>(
Vpat(),
Parent().Size());
317 template <
class Type>
324 template <
class Type>
330 template <
class Type>
340 static_cast<int>(CExports::ImageDatatype(
Handle(),
static_cast<CExports::cvbdim_t
>(plane_))));
348 inline int PlaneTraits<ImagePlane>::GetHeight(
const ImagePlane &plane)
350 return plane.Parent().Height();
static DataType FromNativeDescriptor(int dataTypeDescriptor) noexcept
Construct a data type descriptor from one of the native library's descriptor values.
Definition data_type.hpp:31
The Common Vision Blox image.
Definition decl_image.hpp:50
int Width() const noexcept
Width of the image in pixels.
Definition decl_image.hpp:309
Size2D< int > Size() const noexcept
Size of the image in pixels.
Definition decl_image.hpp:428
void * Handle() const noexcept
Classic API image handle.
Definition decl_image.hpp:237
Image plane information container.
Definition decl_image_plane.hpp:29
class DataType DataType() const noexcept override
Data type descriptor for this array.
Definition detail_image_plane.hpp:337
std::uint8_t * ContiguousAccess() const
Attempt a contiguous access on the plane's pixels.
Definition detail_image_plane.hpp:56
VpatIterator< Type > EndVpat()
Get iterator access to the plane.
Definition detail_image_plane.hpp:292
ContiguousConstIterator< Type > CBeginContiguous() const
Get iterator access to the plane.
Definition detail_image_plane.hpp:211
std::reverse_iterator< LinearIterator< Type > > RBeginLinear()
Get iterator access to the plane.
Definition detail_image_plane.hpp:249
std::reverse_iterator< ContiguousIterator< Type > > REndContiguous()
Get iterator access to the plane.
Definition detail_image_plane.hpp:205
VpatConstIterator< Type > CEndVpat() const
Get iterator access to the plane.
Definition detail_image_plane.hpp:318
ContiguousIterator< Type > BeginContiguous()
Get iterator access to the plane.
Definition detail_image_plane.hpp:186
ContiguousIterator< Type > EndContiguous()
Get iterator access to the plane.
Definition detail_image_plane.hpp:192
LinearAccessData LinearAccess() const
Attempt a linear access on the plane's pixels.
Definition detail_image_plane.hpp:79
bool TryLinearAccess(LinearAccessData &linearAccessData) const noexcept
Attempt a linear access on the plane's pixels.
Definition detail_image_plane.hpp:64
std::reverse_iterator< VpatConstIterator< Type > > CRBeginVpat() const
Get iterator access to the plane.
Definition detail_image_plane.hpp:325
VpatConstIterator< Type > CBeginVpat() const
Get iterator access to the plane.
Definition detail_image_plane.hpp:312
std::reverse_iterator< LinearConstIterator< Type > > CREndLinear() const
Get iterator access to the plane.
Definition detail_image_plane.hpp:280
LinearConstIterator< Type > CEndLinear() const
Get iterator access to the plane.
Definition detail_image_plane.hpp:267
VpatIterator< Type > BeginVpat()
Get iterator access to the plane.
Definition detail_image_plane.hpp:286
std::reverse_iterator< LinearConstIterator< Type > > CRBeginLinear() const
Get iterator access to the plane.
Definition detail_image_plane.hpp:274
class Vpat Vpat() const
Accesses the virtual pixel access table.
Definition detail_image_plane.hpp:95
std::reverse_iterator< VpatConstIterator< Type > > CREndVpat() const
Get iterator access to the plane.
Definition detail_image_plane.hpp:331
std::reverse_iterator< ContiguousConstIterator< Type > > CRBeginContiguous() const
Get iterator access to the plane.
Definition detail_image_plane.hpp:224
LinearIterator< Type > EndLinear()
Get iterator access to the plane.
Definition detail_image_plane.hpp:242
std::unique_ptr< Image > Map() const
Create a map from a single image plane that shares its memory with the original plane.
Definition detail_image_plane.hpp:100
void * Handle() const noexcept override
Classic API image handle.
Definition detail_image_plane.hpp:35
bool TryContiguousAccess(std::uint8_t *&basePtr) const noexcept
Attempt a contiguous access on the plane's pixels.
Definition detail_image_plane.hpp:40
std::reverse_iterator< VpatIterator< Type > > REndVpat()
Get iterator access to the plane.
Definition detail_image_plane.hpp:305
ImagePlane(const class Plane &plane)
Implicitly convert a plane to an image plane.
Definition detail_image_plane.hpp:26
std::reverse_iterator< ContiguousIterator< Type > > RBeginContiguous()
Get iterator access to the plane.
Definition detail_image_plane.hpp:199
double GetPixel(Point2D< int > position) const
Gets the pixel value at the given position.
Definition detail_image_plane.hpp:107
ContiguousConstIterator< Type > CEndContiguous() const
Get iterator access to the plane.
Definition detail_image_plane.hpp:217
std::reverse_iterator< VpatIterator< Type > > RBeginVpat()
Get iterator access to the plane.
Definition detail_image_plane.hpp:299
int Plane() const noexcept
Plane index in the image, to which this plane refers to.
Definition decl_image_plane.hpp:147
const Image & Parent() const noexcept
Image to which this plane descriptor refers to.
Definition detail_image_plane.hpp:87
LinearIterator< Type > BeginLinear()
Get iterator access to the plane.
Definition detail_image_plane.hpp:236
LinearConstIterator< Type > CBeginLinear() const
Get iterator access to the plane.
Definition detail_image_plane.hpp:261
std::reverse_iterator< LinearIterator< Type > > REndLinear()
Get iterator access to the plane.
Definition detail_image_plane.hpp:255
std::reverse_iterator< ContiguousConstIterator< Type > > CREndContiguous() const
Get iterator access to the plane.
Definition detail_image_plane.hpp:230
Linear access properties.
Definition decl_linear_access.hpp:25
std::intptr_t XInc() const noexcept
X-increment for linear access.
Definition decl_linear_access.hpp:112
std::intptr_t YInc() const noexcept
Y-increment for linear access.
Definition decl_linear_access.hpp:122
std::uint8_t * BasePtr() const noexcept
Linear access base pointer.
Definition decl_linear_access.hpp:102
int Rank() const noexcept override
Gets the number of dimensions of this plane.
Definition decl_plane.hpp:111
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
T X() const noexcept
Gets the x-component of the point.
Definition point_2d.hpp:84
T Y() const noexcept
Gets the y-component of the point.
Definition point_2d.hpp:104
Virtual Pixel Access Table.
Definition decl_vpat.hpp:24
cvbbool_t CreateImageSubList(IMG ImageIn, cvbval_t PlaneIndex, cvbval_t NumPlanes, cvbbool_t MapImage, IMG &ImageOut)
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
Definition global.hpp:1080