【问题标题】:How to skew an image in Torch如何在 Torch 中倾斜图像
【发布时间】:2016-08-17 22:30:04
【问题描述】:

我正在尝试扭曲图像以输入 NN,但我似乎不知道该怎么做。似乎没有太多图书馆可以提供我正在寻找的东西。

最好它适用于类型 torch.FloatTensor

edit:实际上,函数 image.warp 看起来很有希望,但 warp_test.lua 并不是特别有用。我只是想将 x 中的图像倾斜不同的量

【问题讨论】:

    标签: image image-processing lua torch


    【解决方案1】:

    这是一个简单的版本:

    require 'torch'
    require 'image'
    
    local function skew(input, factor)
      local w, h  = input:size(3), input:size(2)
      local y     = torch.range(0, h - 1):view(h, 1):expand(h, w)
      local x     = torch.range(0, w - 1):view(1, w):expand(h, w)
      local field = torch.Tensor(2, h, w)
      field[1]    = y
      field[2]    = torch.add(x, factor or 0, y)
      return image.warp(input, field, "bilinear", false, "pad", 0)
    end
    
    local output = skew(image.lena(), 0.25)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-12
      • 2020-04-12
      • 1970-01-01
      • 2011-05-20
      • 2023-03-08
      • 2013-07-19
      相关资源
      最近更新 更多