在 lua 中设置图像大小

Set image size in lua

我写了下面的代码来在 lua 中显示图像:

imagefile="/path/"
img=image.load(imagefile)
image.display(img)

图片尺寸为 200x200。如何将图片调整为 100*100 或其他尺寸?

默认环境下没有图像处理。您的表和函数的名称似乎与 Torch 匹配。如果是这种情况,请使用 image.scale.

文档中的相关引用 (https://github.com/torch/image/blob/master/doc/simpletransform.md#res-imagescalesrc-width-height-mode):

image.scale(src, width, height, [mode])

Rescale the height and width of image src to have width width and height height. Variable mode specifies type of interpolation to be used. Valid values include bilinear (the default), bicubic, or simple interpolation. Returns a new res Tensor.