mt.opencv.warping
Affine-warping and cropping an image.
Functions
do_warp_image()
: Takes an inverse warping transformation which goes from output image to input image and warps the input image.warp_image()
: Takes a warping transformation mapping input image coordinates to the unit square, scales it to the output resolution, then warps the input image.crop_image()
: Takes a crop window from input image and warp/resize it to output image.
- mt.opencv.warping.do_warp_image(out_image: ndarray, in_image: ndarray, inv_tfm: Aff2d, inter_mode: str = 'nearest', border_mode: str = 'constant')
Takes an inverse warping transformation which goes from output image to input image and warps the input image.
- Parameters:
out_image (numpy.ndarray) – output image to be warped and resized to
in_image (numpy.ndarray) – input image from which the warping takes place
inv_tfm (mt.geo.affine2d.Aff2d) – 2D transformation mapping pixel locations in the output image to pixel locations in the input image
inter_mode ({'nearest', 'bilinear'}) – interpolation mode. ‘nearest’ means nearest neighbour. ‘bilinear’ means bilinear interpolation
border_mode ({'constant', 'replicate'}) – border filling mode. ‘constant’ means filling zero constant. ‘replicate’ means replicating last pixels in each dimension.
- mt.opencv.warping.warp_image(out_image: ndarray, in_image: ndarray, warp_tfm: Aff2d, inter_mode: str = 'nearest', border_mode: str = 'constant')
Takes a warping transformation mapping input image coordinates to the unit square, scales it to the output resolution, then warps the input image.
- Parameters:
out_image (numpy.ndarray) – output image to be warped and resized to
in_image (numpy.ndarray) – input image from which the warping takes place
warp_tfm (mt.geo.affine2d.Aff2d) – 2D transformation mapping pixel locations in the input image to the [0,1]^2 square
inter_mode ({'nearest', 'bilinear'}) – interpolation mode. ‘nearest’ means nearest neighbour. ‘bilinear’ means bilinear interpolation
border_mode ({'constant', 'replicate'}) – border filling mode. ‘constant’ means filling zero constant. ‘replicate’ means replicating last pixels in each dimension.
- mt.opencv.warping.crop_image(out_image: ndarray, in_image: ndarray, crop_rect: Rect, inter_mode: str = 'nearest', border_mode: str = 'constant')
Takes a crop window from input image and warp/resize it to output image.
- Parameters:
out_image (numpy.ndarray) – output image to be cropped and resized to
in_image (numpy.ndarray) – input image from which the crop takes place
crop_rect (mt.geo.rect.Rect) – crop window
inter_mode ({'nearest', 'bilinear'}) – interpolation mode. ‘nearest’ means nearest neighbour interpolation. ‘bilinear’ means bilinear interpolation
border_mode ({'constant', 'replicate'}) – border filling mode. ‘constant’ means filling zero constant. ‘replicate’ means replicating last pixels in each dimension.