Deconvolution/2D+: Difference between revisions
m
→{{header|Julia}}
Line 870:
function flatnested2d(a, siz)
ret = zeros(Int, prod(siz))
for i in 1:
ret[siz[2] * (i - 1) + j] = a[i][j]
end
Line 880 ⟶ 878:
function flatnested3d(a, siz)
ret = zeros(Int, prod(siz))
for i in 1:
ret[siz[2] * siz[3] * (i - 1) + siz[3] * (j - 1) + k] = a[i][j][k]
end
Line 890 ⟶ 886:
topow2(siz) = map(x -> nextpow(2, x), siz)
▲ h1 = deconv(Float64.(g1), Float64.(f1))
function deconv2d(f2, g2, xd2)
Line 900 ⟶ 892:
h2 = Int.(round.(real.(ifft(fft(flatnested2d(g2, siz)) ./
fft(flatnested2d(f2, siz))))))
[[h2[siz[2] * (i - 1) + j] for j in 1:xd2[2]] for i in 1:xd2[1]]
end
Line 915 ⟶ 899:
h3 = Int.(round.(real.(ifft(fft(flatnested3d(g3, siz)) ./
fft(flatnested3d(f3, siz))))))
for j in 1:xd3[2]] for i in 1:xd3[1]]
▲ push!(v, h3[siz[2] * siz[3] *(i - 1) + siz[3] * (j - 1) + k])
end
|