|
@@ -80,6 +80,8 @@ function iproc.scale_with_gamma22(src, width, height, filter, blur)
|
|
|
return dest
|
|
|
end
|
|
|
function iproc.padding(img, w1, w2, h1, h2)
|
|
|
+ local conversion
|
|
|
+ img, conversion = iproc.byte2float(img)
|
|
|
image = image or require 'image'
|
|
|
local dst_height = img:size(2) + h1 + h2
|
|
|
local dst_width = img:size(3) + w1 + w2
|
|
@@ -88,9 +90,15 @@ function iproc.padding(img, w1, w2, h1, h2)
|
|
|
flow[2] = torch.ger(torch.ones(dst_height), torch.linspace(0, dst_width - 1, dst_width))
|
|
|
flow[1]:add(-h1)
|
|
|
flow[2]:add(-w1)
|
|
|
- return image.warp(img, flow, "simple", false, "clamp")
|
|
|
+ local dest = image.warp(img, flow, "simple", false, "clamp")
|
|
|
+ if conversion then
|
|
|
+ dest = iproc.float2byte(dest)
|
|
|
+ end
|
|
|
+ return dest
|
|
|
end
|
|
|
function iproc.zero_padding(img, w1, w2, h1, h2)
|
|
|
+ local conversion
|
|
|
+ img, conversion = iproc.byte2float(img)
|
|
|
image = image or require 'image'
|
|
|
local dst_height = img:size(2) + h1 + h2
|
|
|
local dst_width = img:size(3) + w1 + w2
|
|
@@ -99,7 +107,11 @@ function iproc.zero_padding(img, w1, w2, h1, h2)
|
|
|
flow[2] = torch.ger(torch.ones(dst_height), torch.linspace(0, dst_width - 1, dst_width))
|
|
|
flow[1]:add(-h1)
|
|
|
flow[2]:add(-w1)
|
|
|
- return image.warp(img, flow, "simple", false, "pad", 0)
|
|
|
+ local dest = image.warp(img, flow, "simple", false, "pad", 0)
|
|
|
+ if conversion then
|
|
|
+ dest = iproc.float2byte(dest)
|
|
|
+ end
|
|
|
+ return dest
|
|
|
end
|
|
|
function iproc.white_noise(src, std, rgb_weights, gamma)
|
|
|
gamma = gamma or 0.454545
|