img_translate
- systemds.operator.algorithm.img_translate(img_in: Matrix, offset_x: float, offset_y: float, out_w: int, out_h: int, fill_value: float)
The Image Translate function translates the image. Optionally resizes the image (without scaling). Uses nearest neighbor sampling.
>>> import numpy as np >>> from systemds.context import SystemDSContext >>> from systemds.operator.algorithm import img_translate >>> >>> with SystemDSContext() as sds: ... img = sds.from_numpy( ... np.array([[ 10., 20., 30.], ... [ 40., 50., 60.], ... [ 70., 80., 90.]], dtype=np.float32) ... ) ... result_img = img_translate(img, 1., 1., 3, 3, 255.).compute() ... print(result_img) [[255. 255. 255.] [255. 10. 20.] [255. 40. 50.]]
- Parameters:
img_in – Input image as 2D matrix with top left corner at [1, 1]
offset_x – The distance to move the image in x direction
offset_y – The distance to move the image in y direction
out_w – Width of the output image
out_h – Height of the output image
fill_value – The background of the image
- Returns:
Output image as 2D matrix with top left corner at [1, 1]