insert_shape¶
- insert_shape(im, element, center=None, corner=None, value=1, mode='overwrite')[source]¶
Inserts sub-image into a larger image at the specified location.
If the inserted image extends beyond the boundaries of the image it will be cropped accordingly.
- Parameters:
im (ndarray) – The image into which the sub-image will be inserted
element (ndarray) – The sub-image to insert
center (tuple) – Coordinates indicating the position in the main image where the inserted imaged will be centered. If
center
is given thencorner
cannot be specified. Note thatcenter
can only be used if all dimensions ofelement
are odd, otherwise the meaning of center is not defined.corner (tuple) – Coordinates indicating the position in the main image where the lower corner (i.e. [0, 0, 0]) of the inserted image should be anchored. If
center
is given thencorner
cannot be specified.value (scalar) – A scalar value to apply to the sub-image. The default is 1.
mode (string) – If ‘overwrite’ (default) the inserted image replaces the values in the main image. If ‘overlay’ the inserted image is added to the main image. In both cases the inserted image is multiplied by
value
first.
- Returns:
im – A copy of
im
with the supplied element inserted.- Return type:
ndarray
Examples
Click here to view online example.