OpenCVModel.distortion_map¶
giant.camera_models.opencv_model:
- OpenCVModel.distortion_map(shape=None, step=1)¶
This method computes the value of the distortion model across an entire image for use in creating distortion maps.
The
shapeandstepinputs to this method specify the size of the image (shape) as well as the size of the grid steps for computing the distortion values. The locations the distortion values are computed for are generated by:rows, cols = np.meshgrid(np.arange(0, shape[0], step), np.arange(0, shape[1], step), indexing='ij')
If shape is
Nonethen it is set to be(self.n_rows, self.n_cols).The value of the distortion is then computed for each row and column location in
rowsandcolsand then returned, along with therowsandcolsgrids in units of pixels.- In general this method will be used like::
>>> import matplotlib.pyplot as plt >>> from giant.camera_models import CameraModel >>> inst = CameraModel(field_of_view=1) # you can't actually do this >>> prows, pcols, dist = inst.distortion_map((1024, 1024), 100) >>> plt.figure() >>> cs = plt.contour(pcols, prows, np.linalg.norm(dist, axis=0).reshape(prows.shape)) >>> plt.clabel(cs, inline=True, fontsize=10) >>> plt.figure() >>> plt.quiver(pcols.flatten(), prows.flatten(), dist[0], dist[1])
to generate distortion maps of the current model.
- Parameters:
shape (None | Sequence[int] | ndarray[tuple[Any, ...], dtype[integer]]) – The size of the image or None
step (int) – The size of the step to use in sampling the distortion field
- Returns:
a tuple containing the
rowsgrid,colsgrid, and a (2,rows.size) array containing the distortion values in pixels (first row = x distortion values, seconds row=y distortion values)- Return type:
Tuple[ndarray, ndarray, ndarray]