Jump to content

Deconvolution/2D+: Difference between revisions

m
Line 870:
 
function flatnested2d(a, siz)
dim1, dim2 = length(a), length(a[1])
@assert(dim1 <= siz[1] && dim2 <= siz[2])
ret = zeros(Int, prod(siz))
for i in 1:dim1length(a), j in 1:dim2length(a[1])
ret[siz[2] * (i - 1) + j] = a[i][j]
end
Line 880 ⟶ 878:
 
function flatnested3d(a, siz)
dim1, dim2, dim3 = length(a), length(a[1]), length(a[1][1])
@assert(dim1 <= siz[1] && dim2 <= siz[2] && dim3 < siz[3])
ret = zeros(Int, prod(siz))
for i in 1:dim1length(a), j in 1:dim2length(a[1]), k in 1:dim3length(a[1][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)
deconv1d(f1, g1, h1expecteddim1) = Int.(round.(deconv(Float64.(g1), Float64.(f1))))
 
function deconv1d(f1, g1, expecteddim1)
h1 = deconv(Float64.(g1), Float64.(f1))
Int.(round.(h1))
end
 
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]]
ret = Vector{Vector{Int}}()
for i in 1:xd2[1]
v = Vector{Int}()
for j in 1:xd2[2]
push!(v, h2[siz[2] * (i - 1) + j])
end
push!(ret, v)
end
ret
end
 
Line 915 ⟶ 899:
h3 = Int.(round.(real.(ifft(fft(flatnested3d(g3, siz)) ./
fft(flatnested3d(f3, siz))))))
push!(v, [[[h3[siz[2] * siz[3] *(i - 1) + siz[3] * (j - 1) + k]) for k in 1:xd3[3]]
ret = Vector{Vector{Vector{Int}}}()
for j in 1:xd3[2]] for i in 1:xd3[1]]
v2 = Vector{Vector{Int}}()
for j in 1:xd3[2]
v = Vector{Int}()
for k in 1:xd3[3]
push!(v, h3[siz[2] * siz[3] *(i - 1) + siz[3] * (j - 1) + k])
end
push!(v2, v)
end
push!(ret, v2)
end
ret
end
 
4,105

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.