- T - Top
- B - Bottom
- L - Left
- R - Right
Remember that images loaded into a matrix uses the height as rows and width as columns. So x,y coordinates are flipped y,x to get i,j coordinates.
Check if your coordinates are actually sub-pixel coordinates. If they are, confirm where the origin starts within a pixel. This just means your coordinates are actually within a pixel. For example (0, 0) TL can mean TL of the TL pixel or the center of the TL pixel or more weirdly the BL of the TL pixel.
Usually it should be the TL of the TL pixel. But I've read certain things use the center of the TL pixel instead. This means it is possible to have valid negative subpixel coordinates.
Where I notate TL of the TL
this means origin subpixel coordinate starts at the TL of the TL pixel.
x = x
y = height - y - 1
Example:
BL 0,0 at a 3x3 Image
x = 0
y = 3 - 0 - 1 = 2
TL = 0,3
x = x
y = height - y + 1
Example:
BL 1,1 at 3x3 Image
x = 1
y = 3 - 1 + 1 = 3
TL = 1,3
x = x
y = height - y
Example:
BL 0,100.65 at 101x101 Image
x = 0
y = 101 - 100.65
TL = 0,0.35
x = x
y = height - y + 1
Example:
BL 1,101.65 at 101x101 Image
x = 1
y = 101 - 101.65 + 1 = 0.35
TL = 1,0.35