Image.DSI_refine#
- classmethod Image.DSI_refine(DSI: ndarray, dmin: int = 0) tuple[Self, Self][source]#
Refine disparity from disparity space image
- Parameters:
DSI (ndarray(H,W,D)) – disparity space image
dmin (int, optional) – disparity of the first plane of the DSI, defaults to 0
- Returns:
refined disparity image and the curvature at the peak
- Return type:
2-tuple of
Image
Performs subpixel interpolation on the peaks in the DSI to provide disparity estimates to a fraction of a pixel. A parabola is fitted to the peak and the two values either side of it, and the position of the parabola’s peak is the refined disparity.
Each plane of the DSI is a disparity, and the first plane is the first element of the
drangepassed tostereo_simple. The DSI does not record this, so by default the returned disparities are relative to it: 0 is the first plane, 1 is the second, and so on, and a fraction gives the position between planes. Passdminequal todrange[0]to turn them into true disparity values.The result is NaN where there is no valid peak: where the best disparity is the first or last plane, so one neighbour is missing, where a neighbour is NaN, or where every plane is NaN. Planes that are NaN are never chosen as the peak.
Examples
rocks_l = Image.Read("rocks2-l.png", reduce=2) rocks_r = Image.Read("rocks2-r.png", reduce=2) disparity, similarity, DSI = rocks_l.stereo_simple(rocks_r, hw=3, drange=[40, 90]) disparity, curvature = Image.DSI_refine(DSI, dmin=40)
Changed in version 2.5.0: The
drangeargument is replaced bydmin.drangewas compared with plane indices, not disparities, which made it unusable unless the first disparity was 0. A DSI plane that is NaN no longer gives a NaN result for a pixel that has a valid peak.References
P. Corke, Robotics, Vision & Control for Python, Springer, 2023, Section 14.4.1.
See also