1from __future__
import annotations
4from typing
import Tuple, Union, NamedTuple, cast
16 @ingroup ids_peak_common_python_types
22 Luminance or grayscale intensity channel. Common in single-channel images.
28 Red color channel. May appear in various layouts (e.g., RGB, ARGB).
34 Green color channel. Commonly part of multichannel color formats.
40 Blue color channel. Present in formats like BGR, RGBA, etc.
46 Alpha (opacity or transparency) channel. Often used for blending and masking.
52 Represents the X coordinate channel (e.g., in point clouds).
58 Represents the Y coordinate channel (e.g., in point clouds).
64 Represents the Z coordinate channel (e.g., in point clouds).
70 Raw Bayer pattern data from image sensors (e.g., BGGR, RGGB).
76 Chrominance U channel (Cb). Represents the blue-difference chroma component in YUV/YCbCr color spaces.
82 Chrominance V channel (Cr). Represents the red-difference chroma component in YUV/YCbCr color spaces.
88 channels: tuple[Channel, ...]
89 storage_bits_per_channel: int
90 allocated_bits_per_pixel: int
93 unpacked_format: PixelFormat
99 Enum listing all supported pixel formats and their internal IDs.
101 Each enumerator represents a specific pixel layout and bit depth,
102 used for interpreting raw image data correctly.
104 This class also offers methods to query characteristics of specific
105 pixel formats, such as value ranges, storage sizes, and channel configurations.
107 @ingroup ids_peak_common_python_types
110 BAYER_GR_8 = 0x01080008
111 BAYER_GR_10 = 0x0110000C
112 BAYER_GR_12 = 0x01100010
114 BAYER_RG_8 = 0x01080009
115 BAYER_RG_10 = 0x0110000D
116 BAYER_RG_12 = 0x01100011
118 BAYER_GB_8 = 0x0108000A
119 BAYER_GB_10 = 0x0110000E
120 BAYER_GB_12 = 0x01100012
122 BAYER_BG_8 = 0x0108000B
123 BAYER_BG_10 = 0x0110000F
124 BAYER_BG_12 = 0x01100013
131 CONFIDENCE_8 = 0x010800C6
132 CONFIDENCE_16 = 0x011000C7
134 COORD3D_C8 = 0x010800B1
135 COORD3D_C16 = 0x011000B8
136 COORD3D_C32F = 0x012000BF
138 COORD3D_ABC32F = 0x026000C0
140 YUV420_8_YY_UV_SEMIPLANAR_IDS = 0x420C0001
141 YUV420_8_YY_VU_SEMIPLANAR_IDS = 0x420C0002
143 YUV422_8_UYVY = 0x0210001F
161 BAYER_BG_10_PACKED = 0x010A0052
162 BAYER_BG_12_PACKED = 0x010C0053
164 BAYER_GB_10_PACKED = 0x010A0054
165 BAYER_GB_12_PACKED = 0x010C0055
167 BAYER_GR_10_PACKED = 0x010A0056
168 BAYER_GR_12_PACKED = 0x010C0057
170 BAYER_RG_10_PACKED = 0x010A0058
171 BAYER_RG_12_PACKED = 0x010C0059
173 MONO_10_PACKED = 0x010A0046
174 MONO_12_PACKED = 0x010C0047
176 RGB_10_PACKED_32 = 0x0220001D
177 BGR_10_PACKED_32 = 0x0220001E
179 BAYER_RG_10_GROUPED_40_IDS = 0x40000001
180 BAYER_GB_10_GROUPED_40_IDS = 0x40000002
181 BAYER_GR_10_GROUPED_40_IDS = 0x40000003
182 BAYER_BG_10_GROUPED_40_IDS = 0x40000004
184 BAYER_RG_12_GROUPED_24_IDS = 0x40000011
185 BAYER_GB_12_GROUPED_24_IDS = 0x40000012
186 BAYER_GR_12_GROUPED_24_IDS = 0x40000013
187 BAYER_BG_12_GROUPED_24_IDS = 0x40000014
189 MONO_10_GROUPED_40_IDS = 0x4000000f
190 MONO_12_GROUPED_24_IDS = 0x4000001f
194 for pixelformat
in _pixel_format_metadata:
195 if pixelformat.string_value == string_value:
203 Return a human-readable string of the PixelFormat object.
210 Return an unambiguous string of the PixelFormat object.
212 return f
"PixelFormat.{self.name}(value={hex(self._value_)}, string_value={self.string_value!r})"
218 Returns the minimum possible value per channel for the pixel format.
229 Returns the maximum possible value per channel for the pixel format.
240 Returns the number of bits used per channel for storage.
242 return self.
_metadata.storage_bits_per_channel
248 Returns the total number of bits used per pixel for storage.
256 Returns the human-readable name of the pixel format.
264 Returns the list of channels in the pixel format.
272 Returns the number of allocated bits per pixel.
274 return self.
_metadata.allocated_bits_per_pixel
280 Returns the numpy dtype string for this pixel format.
288 Returns True if the pixel format has an intensity channel.
296 Returns the total number of channels in the pixel format.
304 Returns True if the pixel format has only a single channel.
312 Returns True if the pixel format is packed.
320 Returns the unpacked pixel format for a packed pixel format.
321 If the pixel format is already unpacked,
322 the same format is returned.
329 Returns the index of a specific channel within the pixel format.
336 Returns True if the pixel format has a specific channel.
343 Calculates the memory size in bytes for a given image size.
345 area = size.width * size.height
350 return cast(_PixelFormatMetadata, _pixel_format_metadata.get(self))
354 return self.
_metadata.numpy_dtype ==
"float32"
357_pixel_format_metadata = {
359 string_value=
"BayerGR8",
360 channels=(Channel.BAYER,),
361 storage_bits_per_channel=8,
362 allocated_bits_per_pixel=8,
365 unpacked_format=PixelFormat.BAYER_GR_8
369 string_value=
"BayerGR10",
370 channels=(Channel.BAYER,),
371 storage_bits_per_channel=10,
372 allocated_bits_per_pixel=16,
373 numpy_dtype=
"uint16",
375 unpacked_format=PixelFormat.BAYER_GR_10
379 string_value=
"BayerGR12",
380 channels=(Channel.BAYER,),
381 storage_bits_per_channel=12,
382 allocated_bits_per_pixel=16,
383 numpy_dtype=
"uint16",
385 unpacked_format=PixelFormat.BAYER_GR_12
389 string_value=
"BayerRG8",
390 channels=(Channel.BAYER,),
391 storage_bits_per_channel=8,
392 allocated_bits_per_pixel=8,
395 unpacked_format=PixelFormat.BAYER_RG_8
399 string_value=
"BayerRG10",
400 channels=(Channel.BAYER,),
401 storage_bits_per_channel=10,
402 allocated_bits_per_pixel=16,
403 numpy_dtype=
"uint16",
405 unpacked_format=PixelFormat.BAYER_RG_10
409 string_value=
"BayerRG12",
410 channels=(Channel.BAYER,),
411 storage_bits_per_channel=12,
412 allocated_bits_per_pixel=16,
413 numpy_dtype=
"uint16",
415 unpacked_format=PixelFormat.BAYER_RG_12
419 string_value=
"BayerGB8",
420 channels=(Channel.BAYER,),
421 storage_bits_per_channel=8,
422 allocated_bits_per_pixel=8,
425 unpacked_format=PixelFormat.BAYER_GB_8
429 string_value=
"BayerGB10",
430 channels=(Channel.BAYER,),
431 storage_bits_per_channel=10,
432 allocated_bits_per_pixel=16,
433 numpy_dtype=
"uint16",
435 unpacked_format=PixelFormat.BAYER_GB_10
439 string_value=
"BayerGB12",
440 channels=(Channel.BAYER,),
441 storage_bits_per_channel=12,
442 allocated_bits_per_pixel=16,
443 numpy_dtype=
"uint16",
445 unpacked_format=PixelFormat.BAYER_GB_12
449 string_value=
"BayerBG8",
450 channels=(Channel.BAYER,),
451 storage_bits_per_channel=8,
452 allocated_bits_per_pixel=8,
455 unpacked_format=PixelFormat.BAYER_BG_8
459 string_value=
"BayerBG10",
460 channels=(Channel.BAYER,),
461 storage_bits_per_channel=10,
462 allocated_bits_per_pixel=16,
463 numpy_dtype=
"uint16",
465 unpacked_format=PixelFormat.BAYER_BG_10
469 string_value=
"BayerBG12",
470 channels=(Channel.BAYER,),
471 storage_bits_per_channel=12,
472 allocated_bits_per_pixel=16,
473 numpy_dtype=
"uint16",
475 unpacked_format=PixelFormat.BAYER_BG_12
479 string_value=
"Mono8",
480 channels=(Channel.INTENSITY,),
481 storage_bits_per_channel=8,
482 allocated_bits_per_pixel=8,
485 unpacked_format=PixelFormat.MONO_8
489 string_value=
"Mono10",
490 channels=(Channel.INTENSITY,),
491 storage_bits_per_channel=10,
492 allocated_bits_per_pixel=16,
493 numpy_dtype=
"uint16",
495 unpacked_format=PixelFormat.MONO_10
499 string_value=
"Mono12",
500 channels=(Channel.INTENSITY,),
501 storage_bits_per_channel=12,
502 allocated_bits_per_pixel=16,
503 numpy_dtype=
"uint16",
505 unpacked_format=PixelFormat.MONO_12
509 string_value=
"Mono16",
510 channels=(Channel.INTENSITY,),
511 storage_bits_per_channel=16,
512 allocated_bits_per_pixel=16,
513 numpy_dtype=
"uint16",
515 unpacked_format=PixelFormat.MONO_16
519 string_value=
"Confidence8",
520 channels=(Channel.INTENSITY,),
521 storage_bits_per_channel=8,
522 allocated_bits_per_pixel=8,
525 unpacked_format=PixelFormat.CONFIDENCE_8
529 string_value=
"Confidence16",
530 channels=(Channel.INTENSITY,),
531 storage_bits_per_channel=16,
532 allocated_bits_per_pixel=16,
533 numpy_dtype=
"uint16",
535 unpacked_format=PixelFormat.CONFIDENCE_16
539 string_value=
"Coord3D_C8",
540 channels=(Channel.INTENSITY,),
541 storage_bits_per_channel=8,
542 allocated_bits_per_pixel=8,
545 unpacked_format=PixelFormat.COORD3D_C8
549 string_value=
"Coord3D_C16",
550 channels=(Channel.INTENSITY,),
551 storage_bits_per_channel=16,
552 allocated_bits_per_pixel=16,
553 numpy_dtype=
"uint16",
555 unpacked_format=PixelFormat.COORD3D_C16
559 string_value=
"Coord3D_C32f",
560 channels=(Channel.INTENSITY,),
561 storage_bits_per_channel=32,
562 allocated_bits_per_pixel=32,
563 numpy_dtype=
"float32",
565 unpacked_format=PixelFormat.COORD3D_C32F
569 string_value=
"Coord3D_ABC32f",
570 channels=(Channel.X, Channel.Y, Channel.Z),
571 storage_bits_per_channel=32,
572 allocated_bits_per_pixel=96,
573 numpy_dtype=
"float32",
575 unpacked_format=PixelFormat.COORD3D_ABC32F
579 string_value=
"YUV420_8_YY_UV_SemiplanarIDS",
580 channels=(Channel.INTENSITY, Channel.CHROMA_U, Channel.CHROMA_V),
581 storage_bits_per_channel=8,
582 allocated_bits_per_pixel=12,
585 unpacked_format=PixelFormat.YUV420_8_YY_UV_SEMIPLANAR_IDS
589 string_value=
"YUV420_8_YY_VU_SemiplanarIDS",
590 channels=(Channel.INTENSITY, Channel.CHROMA_V, Channel.CHROMA_U),
591 storage_bits_per_channel=8,
592 allocated_bits_per_pixel=12,
595 unpacked_format=PixelFormat.YUV420_8_YY_VU_SEMIPLANAR_IDS
599 string_value=
"YUV422_8_UYVY",
600 channels=(Channel.INTENSITY, Channel.CHROMA_U, Channel.CHROMA_V),
601 storage_bits_per_channel=8,
602 allocated_bits_per_pixel=16,
605 unpacked_format=PixelFormat.YUV422_8_UYVY
610 channels=(Channel.RED, Channel.GREEN, Channel.BLUE),
611 storage_bits_per_channel=8,
612 allocated_bits_per_pixel=24,
615 unpacked_format=PixelFormat.RGB_8
619 string_value=
"RGB10",
620 channels=(Channel.RED, Channel.GREEN, Channel.BLUE),
621 storage_bits_per_channel=10,
622 allocated_bits_per_pixel=48,
623 numpy_dtype=
"uint16",
625 unpacked_format=PixelFormat.RGB_10
629 string_value=
"RGB12",
630 channels=(Channel.RED, Channel.GREEN, Channel.BLUE),
631 storage_bits_per_channel=12,
632 allocated_bits_per_pixel=48,
633 numpy_dtype=
"uint16",
635 unpacked_format=PixelFormat.RGB_12
640 channels=(Channel.BLUE, Channel.GREEN, Channel.RED),
641 storage_bits_per_channel=8,
642 allocated_bits_per_pixel=24,
645 unpacked_format=PixelFormat.BGR_8
649 string_value=
"BGR10",
650 channels=(Channel.BLUE, Channel.GREEN, Channel.RED),
651 storage_bits_per_channel=10,
652 allocated_bits_per_pixel=48,
653 numpy_dtype=
"uint16",
655 unpacked_format=PixelFormat.BGR_10
659 string_value=
"BGR12",
660 channels=(Channel.BLUE, Channel.GREEN, Channel.RED),
661 storage_bits_per_channel=12,
662 allocated_bits_per_pixel=48,
663 numpy_dtype=
"uint16",
665 unpacked_format=PixelFormat.BGR_12
669 string_value=
"RGBa8",
670 channels=(Channel.RED, Channel.GREEN, Channel.BLUE, Channel.ALPHA),
671 storage_bits_per_channel=8,
672 allocated_bits_per_pixel=32,
675 unpacked_format=PixelFormat.RGBA_8
679 string_value=
"RGBa10",
680 channels=(Channel.RED, Channel.GREEN, Channel.BLUE, Channel.ALPHA),
681 storage_bits_per_channel=10,
682 allocated_bits_per_pixel=64,
683 numpy_dtype=
"uint16",
685 unpacked_format=PixelFormat.RGBA_10
689 string_value=
"RGBa12",
690 channels=(Channel.RED, Channel.GREEN, Channel.BLUE, Channel.ALPHA),
691 storage_bits_per_channel=12,
692 allocated_bits_per_pixel=64,
693 numpy_dtype=
"uint16",
695 unpacked_format=PixelFormat.RGBA_12
699 string_value=
"BGRa8",
700 channels=(Channel.BLUE, Channel.GREEN, Channel.RED, Channel.ALPHA),
701 storage_bits_per_channel=8,
702 allocated_bits_per_pixel=32,
705 unpacked_format=PixelFormat.BGRA_8
709 string_value=
"BGRa10",
710 channels=(Channel.BLUE, Channel.GREEN, Channel.RED, Channel.ALPHA),
711 storage_bits_per_channel=10,
712 allocated_bits_per_pixel=64,
713 numpy_dtype=
"uint16",
715 unpacked_format=PixelFormat.BGRA_10
719 string_value=
"BGRa12",
720 channels=(Channel.BLUE, Channel.GREEN, Channel.RED, Channel.ALPHA),
721 storage_bits_per_channel=12,
722 allocated_bits_per_pixel=64,
723 numpy_dtype=
"uint16",
725 unpacked_format=PixelFormat.BGRA_12
729 string_value=
"BayerBG10p",
730 channels=(Channel.BAYER,),
731 storage_bits_per_channel=10,
732 allocated_bits_per_pixel=10,
733 numpy_dtype=
"uint16",
735 unpacked_format=PixelFormat.BAYER_BG_10
739 string_value=
"BayerBG12p",
740 channels=(Channel.BAYER,),
741 storage_bits_per_channel=12,
742 allocated_bits_per_pixel=12,
743 numpy_dtype=
"uint16",
745 unpacked_format=PixelFormat.BAYER_BG_12
749 string_value=
"BayerGB10p",
750 channels=(Channel.BAYER,),
751 storage_bits_per_channel=10,
752 allocated_bits_per_pixel=10,
753 numpy_dtype=
"uint16",
755 unpacked_format=PixelFormat.BAYER_GB_10
759 string_value=
"BayerGB12p",
760 channels=(Channel.BAYER,),
761 storage_bits_per_channel=12,
762 allocated_bits_per_pixel=12,
763 numpy_dtype=
"uint16",
765 unpacked_format=PixelFormat.BAYER_GB_12
769 string_value=
"BayerGR10p",
770 channels=(Channel.BAYER,),
771 storage_bits_per_channel=10,
772 allocated_bits_per_pixel=10,
773 numpy_dtype=
"uint16",
775 unpacked_format=PixelFormat.BAYER_GR_10
779 string_value=
"BayerGR12p",
780 channels=(Channel.BAYER,),
781 storage_bits_per_channel=12,
782 allocated_bits_per_pixel=12,
783 numpy_dtype=
"uint16",
785 unpacked_format=PixelFormat.BAYER_GR_12
789 string_value=
"BayerRG10p",
790 channels=(Channel.BAYER,),
791 storage_bits_per_channel=10,
792 allocated_bits_per_pixel=10,
793 numpy_dtype=
"uint16",
795 unpacked_format=PixelFormat.BAYER_RG_10
799 string_value=
"BayerRG12p",
800 channels=(Channel.BAYER,),
801 storage_bits_per_channel=12,
802 allocated_bits_per_pixel=12,
803 numpy_dtype=
"uint16",
805 unpacked_format=PixelFormat.BAYER_RG_12
809 string_value=
"Mono10p",
810 channels=(Channel.INTENSITY,),
811 storage_bits_per_channel=10,
812 allocated_bits_per_pixel=10,
813 numpy_dtype=
"uint16",
815 unpacked_format=PixelFormat.MONO_10
819 string_value=
"Mono12p",
820 channels=(Channel.INTENSITY,),
821 storage_bits_per_channel=12,
822 allocated_bits_per_pixel=12,
823 numpy_dtype=
"uint16",
825 unpacked_format=PixelFormat.MONO_12
829 string_value=
"RGB10p32",
830 channels=(Channel.RED, Channel.GREEN, Channel.BLUE),
831 storage_bits_per_channel=10,
832 allocated_bits_per_pixel=32,
833 numpy_dtype=
"uint32",
835 unpacked_format=PixelFormat.RGB_10
839 string_value=
"BGR10p32",
840 channels=(Channel.BLUE, Channel.GREEN, Channel.RED),
841 storage_bits_per_channel=10,
842 allocated_bits_per_pixel=32,
843 numpy_dtype=
"uint32",
845 unpacked_format=PixelFormat.BGR_10
849 string_value=
"BayerRG10g40IDS",
850 channels=(Channel.BAYER,),
851 storage_bits_per_channel=10,
852 allocated_bits_per_pixel=10,
853 numpy_dtype=
"uint16",
855 unpacked_format=PixelFormat.BAYER_RG_10
859 string_value=
"BayerGB10g40IDS",
860 channels=(Channel.BAYER,),
861 storage_bits_per_channel=10,
862 allocated_bits_per_pixel=10,
863 numpy_dtype=
"uint16",
865 unpacked_format=PixelFormat.BAYER_GB_10
869 string_value=
"BayerGR10g40IDS",
870 channels=(Channel.BAYER,),
871 storage_bits_per_channel=10,
872 allocated_bits_per_pixel=10,
873 numpy_dtype=
"uint16",
875 unpacked_format=PixelFormat.BAYER_GR_10
879 string_value=
"BayerBG10g40IDS",
880 channels=(Channel.BAYER,),
881 storage_bits_per_channel=10,
882 allocated_bits_per_pixel=10,
883 numpy_dtype=
"uint16",
885 unpacked_format=PixelFormat.BAYER_BG_10
889 string_value=
"BayerRG12g24IDS",
890 channels=(Channel.BAYER,),
891 storage_bits_per_channel=12,
892 allocated_bits_per_pixel=12,
893 numpy_dtype=
"uint16",
895 unpacked_format=PixelFormat.BAYER_RG_12
899 string_value=
"BayerGB12g24IDS",
900 channels=(Channel.BAYER,),
901 storage_bits_per_channel=12,
902 allocated_bits_per_pixel=12,
903 numpy_dtype=
"uint16",
905 unpacked_format=PixelFormat.BAYER_GB_12
909 string_value=
"BayerGR12g24IDS",
910 channels=(Channel.BAYER,),
911 storage_bits_per_channel=12,
912 allocated_bits_per_pixel=12,
913 numpy_dtype=
"uint16",
915 unpacked_format=PixelFormat.BAYER_GR_12
919 string_value=
"BayerBG12g24IDS",
920 channels=(Channel.BAYER,),
921 storage_bits_per_channel=12,
922 allocated_bits_per_pixel=12,
923 numpy_dtype=
"uint16",
925 unpacked_format=PixelFormat.BAYER_BG_12
929 string_value=
"Mono10g40IDS",
930 channels=(Channel.INTENSITY,),
931 storage_bits_per_channel=10,
932 allocated_bits_per_pixel=10,
933 numpy_dtype=
"uint16",
935 unpacked_format=PixelFormat.MONO_10
939 string_value=
"Mono12g24IDS",
940 channels=(Channel.INTENSITY,),
941 storage_bits_per_channel=12,
942 allocated_bits_per_pixel=12,
943 numpy_dtype=
"uint16",
945 unpacked_format=PixelFormat.MONO_12
Thrown when an unsupported operation or feature is used.