cv3.create.ones_like

cv3.create.ones_like(img)[source]

Create an array of ones with the same shape and type as the input array.

Parameters:

img (numpy.ndarray) – Input array whose shape and type will be used to create the new array.

Returns:

Array filled with ones having the same shape and type

as the input array.

Return type:

numpy.ndarray

Example

>>> import cv3
>>> original = cv3.zeros(50, 50, 3)
>>> new_img = cv3.ones_like(original)  # Create array with same shape as original
>>> print(new_img.shape)
(50, 50, 3)