CVB++ 15.0
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
21namespace Cvb
22{
23
24 CVB_BEGIN_INLINE_NS
25
27
28 class ImagePlane final : public IArray
29 {
31 friend Image;
33
34 public:
36
42 explicit ImagePlane(const class Plane &plane);
43
44 ImagePlane(const ImagePlane &other) = delete;
45 ImagePlane &operator=(const ImagePlane &other) = delete;
46 ImagePlane(ImagePlane &&other) noexcept = default;
47 ImagePlane &operator=(ImagePlane &&other) noexcept = default;
48 virtual ~ImagePlane() = default;
49
51
57 void *Handle() const noexcept override;
58
60
69 bool TryContiguousAccess(std::uint8_t *&basePtr) const noexcept;
70
72
80
82
93 bool TryLinearAccess(LinearAccessData &linearAccessData) const noexcept;
94
96
104
105 class DataType DataType() const noexcept override;
106
107 int Rank() const noexcept override
108 {
109 return 2;
110 }
111
113
117 const Image &Parent() const noexcept;
118
120
129 class Vpat Vpat() const;
130
132
136 std::unique_ptr<Image> Map() const;
137
139
144 double GetPixel(Point2D<int> position) const;
145
147 int Plane() const noexcept
148 {
149 return plane_;
150 }
151
153
159 template <class Type>
160 ContiguousIterator<Type> BeginContiguous();
161
163
169 template <class Type>
170 ContiguousIterator<Type> EndContiguous();
171
173
179 template <class Type>
181
183
189 template <class Type>
191
193
199 template <class Type>
200 ContiguousConstIterator<Type> CBeginContiguous() const;
201
203
209 template <class Type>
210 ContiguousConstIterator<Type> BeginContiguous() const
211 {
212 return CBeginContiguous<Type>();
213 }
214
216
222 template <class Type>
223 ContiguousConstIterator<Type> CEndContiguous() const;
224
226
232 template <class Type>
233 ContiguousConstIterator<Type> EndContiguous() const
234 {
235 return CEndContiguous<Type>();
236 }
237
239
245 template <class Type>
247
249
255 template <class Type>
260
262
268 template <class Type>
270
272
278 template <class Type>
283
285
291 template <class Type>
292 LinearIterator<Type> BeginLinear();
293
295
301 template <class Type>
302 LinearIterator<Type> EndLinear();
303
305
311 template <class Type>
313
315
321 template <class Type>
323
325
331 template <class Type>
332 LinearConstIterator<Type> CBeginLinear() const;
333
335
341 template <class Type>
342 LinearConstIterator<Type> BeginLinear() const
343 {
344 return CBeginLinear<Type>();
345 }
346
348
354 template <class Type>
355 LinearConstIterator<Type> CEndLinear() const;
356
358
364 template <class Type>
365 LinearConstIterator<Type> EndLinear() const
366 {
367 return CEndLinear<Type>();
368 }
369
371
377 template <class Type>
379
381
387 template <class Type>
392
394
400 template <class Type>
402
404
410 template <class Type>
415
417
423 template <class Type>
424 VpatIterator<Type> BeginVpat();
425
427
433 template <class Type>
434 VpatIterator<Type> EndVpat();
435
437
443 template <class Type>
445
447
453 template <class Type>
455
457
463 template <class Type>
464 VpatConstIterator<Type> CBeginVpat() const;
465
467
473 template <class Type>
474 VpatConstIterator<Type> BeginVpat() const
475 {
476 return CBeginVpat<Type>();
477 }
478
480
486 template <class Type>
487 VpatConstIterator<Type> CEndVpat() const;
488
490
496 template <class Type>
497 VpatConstIterator<Type> EndVpat() const
498 {
499 return CEndVpat<Type>();
500 }
501
503
509 template <class Type>
511
513
519 template <class Type>
524
526
532 template <class Type>
534
536
542 template <class Type>
547
548 private:
549 ImagePlane(int plane, const Image &image) noexcept
550 : plane_(plane)
551 , parentImage_(&image)
552 {
553 }
554
555 int plane_;
556
557 const Image *parentImage_ = nullptr;
558
560 };
561
562 template <>
563 struct PlaneTraits<ImagePlane>
564 {
565 using PlaneT = ImagePlane;
566 using TypeList = DispatchableTypeList<std::uint8_t, std::int8_t, std::uint16_t, std::int16_t, std::uint32_t,
567 std::int32_t, std::uint64_t, std::int64_t, float, double>;
568
569 static constexpr bool HasVpat = true;
570
571 static int GetWidth(const ImagePlane &plane);
572 static int GetHeight(const ImagePlane &plane);
573
574 static Cvb::DataType GetDataType(const ImagePlane &plane)
575 {
576 return plane.DataType();
577 }
578
579 static constexpr int GetRank(const ImagePlane &)
580 {
581 return 2;
582 }
583
584 static Cvb::Vpat GetVpat(const ImagePlane &plane)
585 {
586 return plane.Vpat();
587 }
588 };
589
590 CVB_END_INLINE_NS
591
592} // namespace Cvb
The Common Vision Blox image.
Definition decl_image.hpp:45
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
VpatConstIterator< Type > EndVpat() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:497
VpatConstIterator< Type > BeginVpat() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:474
std::reverse_iterator< LinearConstIterator< Type > > REndLinear() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:411
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:342
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:256
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:520
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:365
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:107
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:388
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:210
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:543
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:233
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 > > REndContiguous() const
Get iterator access to the plane.
Definition decl_image_plane.hpp:279
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 c_bayer_to_rgb.h:17
Definition global.hpp:1080