Tensorflow.js tf.image.rotateWithOffset() Function
Tensorflow.js is an open-source library developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment.
The .image.rotateWithOffset() function is used to rotate the input image tensor anticlockwise along with an alternative offset center of spin. At present, its accessible in the CPU, WebGL, as well as WASM backends.
tf.image.rotateWithOffset(image, radians, fillValue?, center?)
- images: The stated 4d tensor, which is of configuration [batch, imageHeight, imageWidth, depth]. It can be of type tf.Tensor4D, TypedArray, or Array.
- radians: The stated number of rotation. It is of type number.
- fillValue: It is the optional value which is used to fill in the vacant space that is unused after rotation. It can either be an individual grayscale value i.e. from 0 to 255, or else an array of three numerals i.e. [red, green, blue] indicating the red, green, as well as blue channels. The by default value is zero i.e. black channel. It can be of type number or [number, number, number].
- center: It is the stated center of spin. It can either be an individual value i.e. from 0 to 1, or else an array of two numerals i.e. [centerX, centerY]. The by default value is 0.5. It can be of type number or [number, number].
Return Value: It returns tf.Tensor4D.
Example 1: In this example, we will be going to use a 4d tensor and radians parameter in tf.image.rotateWithOffset() function.
Tensor [[[[0, 0 ], [0, 0 ]], [[0, 0 ], [1, 33]]]]
Example 2: In this example, we will be going to use an array of floats, fillValue, as well as center.
Tensor [[[[1, 2, 3, 3], [1, 2, 3, 3]], [[1, 2, 3, 3], [1, 2, 3, 3]]]]