Let's say I want to know the height and width of image.lena()
. What method should I call on it? A link to a resource for methods on images would be great as the Torch help
command does not work in this case.
image.lena()
returns a Torch 3-dimensional tensor where the first dimension is the number of channels (3 for a RGB image), and the last ones are resp. the height (nb. of rows) and width (nb. of columns) of the image.
So all you need to do is use the size(dim)
method as follow:
require 'image'
local img = image.lena()
print(torch.typename(img)) -- torch.DoubleTensor
local nchan, height, width = img:size(1), img:size(2), img:size(3)
print('nb. channels: ' .. nchan) -- 3
print('width: ' .. width .. ', height: ' .. height) -- 512, 512