@@ -99,3 +99,47 @@ Note that segments must always be stacked down the fourth dimension (with index
99993) of the ``pixel_array ``. In order to create a segmentation with multiple
100100segments for a single source frame, it is required to add a new dimension
101101(with length 1) as the first dimension (index 0) of the array.
102+
103+
104+ .. _correct-coordinate-mapping :
105+
106+ Correct coordinate mapping
107+ --------------------------
108+
109+ Prior to highdicom 0.14.1, mappings between image coordinates and reference
110+ coordinates did not take into account that there are two image coordinate
111+ systems, which are shifted by 0.5 pixels.
112+
113+ 1. **Pixel indices **: (column, row) indices into the pixel matrix. The values
114+ are zero-based integers in the range [0, Columns - 1] and [0, Rows - 1].
115+ Pixel indices are defined relative to the centers of pixels and the (0, 0)
116+ index is located at the center of the top left corner hand pixel of the
117+ total pixel matrix.
118+ 2. **Image coordinates **: (column, row) coordinates in the pixel matrix at
119+ sub-pixel resolution. The values are floating-point numbers in the range
120+ [0, Columns] and [0, Rows]. Image coordinates are defined relative to the
121+ top left corner of the pixels and the (0.0, 0.0) point is located at the top
122+ left corner of the top left corner hand pixel of the total pixel matrix.
123+
124+ To account for these differences, introduced two additional transformer classes
125+ in highdicom 0.14.1. and made changes to the existing ones.
126+ The existing transformer class now map between image coordinates and reference
127+ coordinates (:class: `highdicom.spatial.ImageToReferenceTransformer ` and
128+ :class: `highdicom.spatial.ReferenceToImageTransformer `).
129+ While the new transformer classes map between pixel indices and reference
130+ coordinates (:class: `highdicom.spatial.PixelToReferenceTransformer ` and
131+ :class: `highdicom.spatial.ReferenceToPixelTransformer `).
132+ Note that you want to use the former classes for converting between spatial
133+ coordinates (SCOORD) (:class: `highdicom.sr.ScoordContentItem `) and 3D spatial
134+ coordinates (SCOORD3D) (:class: `highdicom.sr.Scoord3DContentItem `) and the
135+ latter for determining the position of a pixel in the frame of reference or for
136+ projecting a coordinate in the frame of reference onto the image plane.
137+
138+ To make the distinction between pixel indices and image coordinates as clear as
139+ possible, we renamed the parameter of the
140+ :func: `highdicom.spatial.map_pixel_into_coordinate_system ` function from
141+ ``coordinate `` to ``index `` and enforce that the values that are provided via
142+ the argument are integers rather than floats.
143+ In addition, the return value of
144+ :func: `highdicom.spatial.map_coordinate_into_pixel_matrix ` is now a tuple of
145+ integers.
0 commit comments