Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed tensor type issue in affinetransform and warp #189

Merged
merged 1 commit into from
Sep 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ local function warp(...)
dok.error('Incorrect arguments (clamp_mode is not clamp | pad)!', 'image.warp')
end

local field = field:typeAs(torch.Tensor()) -- coerce matrix to default tensor type
local dim2 = false
if src:nDimension() == 2 then
dim2 = true
Expand Down Expand Up @@ -1065,14 +1066,15 @@ local function affinetransform(...)
local grid_y = torch.ger( torch.linspace(-1,1,height), torch.ones(width) )
local grid_x = torch.ger( torch.ones(height), torch.linspace(-1,1,width) )

local grid_xy = torch.FloatTensor()
local grid_xy = torch.Tensor()
grid_xy:resize(2,height,width)
grid_xy[1] = grid_y * ((height-1)/2) * -1
grid_xy[2] = grid_x * ((width-1)/2) * -1
local view_xy = grid_xy:reshape(2,height*width)

local matrix = matrix:typeAs(torch.Tensor()) -- coerce matrix to default tensor type
local field = torch.mm(matrix, view_xy)
field = (grid_xy - field:reshape( 2, height, width )):double()
field = (grid_xy - field:reshape( 2, height, width ))

-- offset field for translation
translation = torch.Tensor(translation)
Expand Down