gusimplewhiteboard
wb_pixel_coordinate Struct Reference

WHITEBOARD_POSTER_STRING_CONVERSION. More...

#include <wb_pixel_coordinate.h>

Inheritance diagram for wb_pixel_coordinate:
Collaboration diagram for wb_pixel_coordinate:

Public Attributes

int16_t x
 The x coordinate. More...
 
int16_t y
 The y coordinate. More...
 

Detailed Description

WHITEBOARD_POSTER_STRING_CONVERSION.

A pixel_coordinate is the whiteboard representation for the position of a pixel in an image in centered pixel coordinate. The centered pixel coordinate coordinate system is defined using four fields (x, y, resWidth, resHeight). The x and y fields are contained within this type, however, the resWidth and resHeight values are contained elsewhere. This is to save space within this message; often multiple pixel coordinates are used and having to stipulate the resolution width and height for each coordinate is wasteful.

The x and y fields must conform to the following constraints: -floor((resWidth - 1) / 2) <= x <= ceil((resWidth - 1) / 2), -floor((resHeight - 1) / 2) <= y <= ceil((resHeight - 1) / 2).

This places the (0, 0) point in the center of the image. The coordinate system can be depicted graphically as follows:

ceil((resHeight - 1) / 2)
---
^
|
y|
|
-x | x
-floor((resWidth - 1) / 2) |<----------|---------->| ceil((resWidth - 1) / 2)
(0,0)*|
|
-y|
|
V
---
-floor((resHeight - 1) / 2)
int16_t y
The y coordinate.
int16_t x
The x coordinate.

Importantly here, the (0, 0) pixel is in the 3rd quadrant. This is because when even numbers are used for resWidth and resHeight, the (0, 0) point would be between pixels. Below is a table detailing the bounds for common resolutions:

      Resolution      |                    left/rightmost pixel                |               bottom/topmost pixel
(resWidth, resHeight) | (-floor((resWidth - 1) / 2), ceil((resWidth - 1) / 2)) | (-floor((resHeight - 1) / 2), ceil(resHeight - 1) / 2)

--------------------—+-----------------------------------------------------—+-----------------------------------------------------— (640, 480) | (-319, 320) | (-239, 240) (800, 600) | (-399, 400) | (-299, 300) (1280, 720) | (-639, 640) | (-359, 360) (1920, 1080) | (-959, 960) | (-539, 540)

Definition at line 149 of file wb_pixel_coordinate.h.

Member Data Documentation

◆ x

int16_t wb_pixel_coordinate::x

The x coordinate.

This coordinate represents a pixel within an image in centered pixel coordinates. This coordinate system is bound by some resolution width and height (resWidth, resHeight). This coordinate represents a position along the horizontal axis bound by resWidth. As such, the value assigned to this property must be in the following range in order to be in the image: -floor((resWidth - 1) / 2) <= x <= ceil((resWidth - 1) / 2)

This therefore shifts the center coordinate (0) to the third quadrant. The coordinate system can be depicted graphically as follows:

ceil((resHeight - 1) / 2)
---
^
|
y|
|
-x | x
-floor((resWidth - 1) / 2) |<----------|---------->| ceil((resWidth - 1) / 2)
(0,0)*|
|
-y|
|
V
---
-floor((resHeight - 1) / 2)

Definition at line 182 of file wb_pixel_coordinate.h.

Referenced by guWhiteboard::PixelCoordinate::PixelCoordinate(), guWhiteboard::PixelCoordinate::operator=(), guWhiteboard::PixelCoordinate::set_x(), wb_pixel_coordinate_from_network_serialised(), wb_px_coord_to_px_coord(), and guWhiteboard::PixelCoordinate::x().

◆ y

int16_t wb_pixel_coordinate::y

The y coordinate.

This coordinate represents a pixel within an image in centered pixel coordinates. This coordinate system is bound by some resolution width and height (resWidth, resHeight). This coordinate represents a position along the vertical axis bound by resHeight. As such, the value assigned to this property must be in the following range in order to be in the image: -floor((resHeight - 1) / 2) <= y <= ceil((resHeight - 1) / 2)

This therefore shifts the center coordinate (0) to the third quadrant. The coordinate system can be depicted graphically as follows:

ceil((resHeight - 1) / 2)
---
^
|
y|
|
-x | x
-floor((resWidth - 1) / 2) |<----------|---------->| ceil((resWidth - 1) / 2)
(0,0)*|
|
-y|
|
V
---
-floor((resHeight - 1) / 2)

Definition at line 214 of file wb_pixel_coordinate.h.

Referenced by guWhiteboard::PixelCoordinate::PixelCoordinate(), guWhiteboard::PixelCoordinate::operator=(), guWhiteboard::PixelCoordinate::set_y(), wb_pixel_coordinate_from_network_serialised(), wb_px_coord_to_px_coord(), and guWhiteboard::PixelCoordinate::y().


The documentation for this struct was generated from the following file: