PinholeModel.distortion_map¶
giant.camera_models.pinhole_model
:
- PinholeModel.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
shape
andstep
inputs 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
None
then 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
rows
andcols
and then returned, along with therows
andcols
grids 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 (Sequence | ndarray | None) – 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
rows
grid,cols
grid, 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]