Contains pixel structures for Simd::View formats and drawing colors. More...
Data Structures | |
| struct | Bgr24 |
| 24-bit BGR pixel. More... | |
| struct | Bgra32 |
| 32-bit BGRA pixel. More... | |
| struct | Hsl24 |
| 24-bit HSL pixel. More... | |
| struct | Hsv24 |
| 24-bit HSV pixel. More... | |
| struct | Rgb24 |
| 24-bit RGB pixel. More... | |
| struct | Rgba32 |
| 32-bit RGBA pixel. More... | |
Detailed Description
Contains pixel structures for Simd::View formats and drawing colors.
Each structure is the memory layout of the matching Simd::View::Format (Bgr24, Bgra32, Hsv24, Hsl24, Rgb24, Rgba32). Channel fields are stored in that order and the structure size is the pixel size, so a value can be written into a view and passed as the color of Simd::DrawLine, Simd::DrawRectangle, Simd::DrawFilledRectangle, Simd::Font::Draw and Simd::FillPixel. Those functions require sizeof(color) to equal the canvas pixel size.
OpenCV frames used by the motion example are BGR. They use Pixel::Bgr24 as the color type. TestMotion paints alarmed objects with Bgr24(0, 0, 255), other objects with Bgr24(0, 255, 255) and event text with Bgr24(255, 255, 255). DrawRectangle, DrawLine and Font::Draw take that color on the Bgr24 frame. The Font example uses Pixel::Bgra32 on a Bgra32 canvas, including FillPixel(image, Bgra32(128, 128, 0)).
Bgr24 and Bgra32 constructors take channels as blue, green, red. Rgb24 and Rgba32 constructors take them as red, green, blue. TestRandom::GetColor therefore builds Bgr24(b, g, r) and Rgb24(r, g, b) from the same (b, g, r) triple, so "B", "G" and "R" labels have the same color on BGR and RGB canvases. Conversion constructors copy the matching channels and exchange red and blue between BGR and RGB layouts. Alpha is omitted when the result is 24-bit. A 24-bit source converted to 32 bits uses alpha 255 unless another value is passed. Bgra32 and Rgba32 conversions copy alpha.
Pixels are read and written with View::At and View::Row. The transform test assigns view.At<Pixel::Bgr24>(x, y) and view.At<Pixel::Bgra32>(x, y). The font test fills a row with View::Row<Pixel::Bgra32>. The static At methods do the same lookup and also require view.format to match the pixel type. col is the x coordinate and row is the y coordinate.
Hsv24 and Hsl24 are the element types of images produced by Simd::BgrToHsv and Simd::BgrToHsl. Every component is an 8-bit value in [0, 255].
Using example: