Module: Magro::Transform
- Defined in:
- lib/magro/transform.rb
Overview
Transform module provide functions of image transfom.
Class Method Summary collapse
-
.resize(image, height:, width:) ⇒ Numo::UInt8
Resizes an image with bilinear interpolation method.
Class Method Details
.resize(image, height:, width:) ⇒ Numo::UInt8
Resizes an image with bilinear interpolation method.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/magro/transform.rb', line 21 def resize(image, height:, width:) n_channels = image.shape[2] if n_channels.nil? bilinear_resize(image, height, width) else resized = image.class.zeros(height, width, n_channels) n_channels.times { |c| resized[true, true, c] = bilinear_resize(image[true, true, c], height, width) } resized end end |