CVB++ 15.1
Loading...
Searching...
No Matches
decl_image_plane.hpp
1#pragma once
2
3#include <algorithm>
4#include <memory>
5#include <new>
6#include <system_error>
7#include <utility>
8
9#include "../_cexports/c_img.h"
10#include "../_cexports/c_utilities.h"
11
12#include "../global.hpp"
13#include "../point_2d.hpp"
14
15#include "../data_type.hpp"
16#include "../iarray.hpp"
17#include "../image_plane_contiguous_iterator.hpp"
18#include "../image_plane_linear_iterator.hpp"
19#include "../image_plane_vpat_iterator.hpp"
20
21#include "decl_wrapped_image.hpp"
22
23namespace Cvb
24{
25
26 CVB_BEGIN_INLINE_NS
27
29
30 class ImagePlane final : public IArray
31 {
33 friend Image;
35
36 public:
38
44 explicit ImagePlane(const class Plane &plane);
45
46 ImagePlane(const ImagePlane &other) = delete;
47 ImagePlane &operator=(const ImagePlane &other) = delete;
48 ImagePlane(ImagePlane &&other) noexcept = default;
49 ImagePlane &operator=(ImagePlane &&other) noexcept = default;
50 virtual ~ImagePlane() = default;
51
53
59 void *Handle() const noexcept override;
60
62
71 bool TryContiguousAccess(std::uint8_t *&basePtr) const noexcept;
72
74
82
84
95 bool TryLinearAccess(LinearAccessData &linearAccessData) const noexcept;
96
98
106
107 class DataType DataType() const noexcept override;
108
109 int Rank() const noexcept override
110 {
111 return 2;
112 }
113
115
119 const Image &Parent() const noexcept;
120
122
131 class Vpat Vpat() const;
132
134
138 std::unique_ptr<Image> Map() const;
139
141
146 double GetPixel(Point2D<int> position) const;
147
149 int Plane() const noexcept
150 {
151 return plane_;
152 }
153
155
161 template <class Type>
162 ContiguousIterator<Type> BeginContiguous();
163
165
171 template <class Type>
172 ContiguousIterator<Type> EndContiguous();
173
175
181 template <class Type>
183
185
191 template <class Type>
193
195
201 template <class Type>
202 ContiguousConstIterator<Type> CBeginContiguous() const;
203
205
211 template <class Type>
212 ContiguousConstIterator<Type> BeginContiguous() const
213 {
214 return CBeginContiguous<Type>();
215 }
216
218
224 template <class Type>
225 ContiguousConstIterator<Type> CEndContiguous() const;
226
228
234 template <class Type>
235 ContiguousConstIterator<Type> EndContiguous() const
236 {
237 return CEndContiguous<Type>();
238 }
239
241
247 template <class Type>
249
251
257 template <class Type>
262
264
270 template <class Type>
272
274
280 template <class Type>
285
287
293 template <class Type>
294 LinearIterator<Type> BeginLinear();
295
297
303 template <class Type>
304 LinearIterator<Type> EndLinear();
305
307
313 template <class Type>
315
317
323 template <class Type>
325
327
333 template <class Type>
334 LinearConstIterator<Type> CBeginLinear() const;
335
337
343 template <class Type>
344 LinearConstIterator<Type> BeginLinear() const
345 {
346 return CBeginLinear<Type>();
347 }
348
350
356 template <class Type>
357 LinearConstIterator<Type> CEndLinear() const;
358
360
366 template <class Type>
367 LinearConstIterator<Type> EndLinear() const
368 {
369 return CEndLinear<Type>();
370 }
371
373
379 template <class Type>
381
383
389 template <class Type>
394
396
402 template <class Type>
404
406
412 template <class Type>
417
419
425 template <class Type>
426 VpatIterator<Type> BeginVpat();
427
429
435 template <class Type>
436 VpatIterator<Type> EndVpat();
437
439
445 template <class Type>
447
449
455 template <class Type>
457
459
465 template <class Type>
466 VpatConstIterator<Type> CBeginVpat() const;
467
469
475 template <class Type>
476 VpatConstIterator<Type> BeginVpat() const
477 {
478 return CBeginVpat<Type>();
479 }
480
482
488 template <class Type>
489 VpatConstIterator<Type> CEndVpat() const;
490
492
498 template <class Type>
499 VpatConstIterator<Type> EndVpat() const
500 {
501 return CEndVpat<Type>();
502 }
503
505
511 template <class Type>
513
515
521 template <class Type>
526
528
534 template <class Type>
536
538
544 template <class Type>
549
550 private:
551 ImagePlane(int plane, const Image &image) noexcept
552 : plane_(plane)
553 , parentImage_(&image)
554 {
555 }
556
557 int plane_;
558
559 const Image *parentImage_ = nullptr;
560
562 };
563
564 template <>
565 struct PlaneTraits<ImagePlane>
566 {
567 using PlaneT = ImagePlane;
568 using TypeList = DispatchableTypeList<std::uint8_t, std::int8_t, std::uint16_t, std::int16_t, std::uint32_t,
569 std::int32_t, std::uint64_t, std::int64_t, float, double>;
570
571 static constexpr bool HasVpat = true;
572
573 static int GetWidth(const ImagePlane &plane);
574 static int GetHeight(const ImagePlane &plane);
575
576 static Cvb::DataType GetDataType(const ImagePlane &plane)
577 {
578 return plane.DataType();
579 }
580
581 static constexpr int GetRank(const ImagePlane &)
582 {
583 return 2;
584 }
585
586 static Cvb::Vpat GetVpat(const ImagePlane &plane)
587 {
588 return plane.Vpat();
589 }
590 };
591
592 CVB_END_INLINE_NS
593
594} // namespace Cvb
The Common Vision Blox image.
Definition decl_image.hpp:50
Image plane information container.
Definition decl_image_plane.hpp:31
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
VpatConstIterator< Type > EndVpat() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:499
VpatConstIterator< Type > BeginVpat() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:476
std::reverse_iterator< LinearConstIterator< Type > > REndLinear() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:413
VpatIterator< Type > EndVpat()
Get iterator access to the plane.
Definition detail_image_plane.hpp:292
LinearConstIterator< Type > BeginLinear() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:344
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< ContiguousConstIterator< Type > > RBeginContiguous() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:258
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
std::reverse_iterator< VpatConstIterator< Type > > RBeginVpat() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:522
LinearAccessData LinearAccess() const
Attempt a linear access on the plane's pixels.
Definition detail_image_plane.hpp:79
LinearConstIterator< Type > EndLinear() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:367
bool TryLinearAccess(LinearAccessData &linearAccessData) const noexcept
Attempt a linear access on the plane's pixels.
Definition detail_image_plane.hpp:64
int Rank() const noexcept override
Gets the number of dimensions for this array.
Definition decl_image_plane.hpp:109
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
std::reverse_iterator< VpatConstIterator< Type > > CREndVpat() const
Get iterator access to the plane.
Definition detail_image_plane.hpp:331
std::reverse_iterator< LinearConstIterator< Type > > RBeginLinear() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:390
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
ContiguousConstIterator< Type > BeginContiguous() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:212
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
std::reverse_iterator< VpatConstIterator< Type > > REndVpat() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:545
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
ContiguousConstIterator< Type > EndContiguous() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:235
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:149
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 > > REndContiguous() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:281
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
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
Virtual Pixel Access Table.
Definition decl_vpat.hpp:24
Root namespace for the Image Manager interface.
Definition version.hpp:11
Definition global.hpp:1049