Skip to content

Commit

Permalink
image2
Browse files Browse the repository at this point in the history
  • Loading branch information
ZongyuLi-umich committed Oct 15, 2021
1 parent 368d4a2 commit d46c881
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/fft_convolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,31 @@ function fft_conv_adj!(

return output
end


"""
fft_conv_adj2!(output, image2, ker3, plans)
In-place version of adjoint of convolving a 2D `image2` with a 3D kernel `ker3`
"""
function fft_conv_adj2!(
output::AbstractArray{<:RealU,3},
image2::AbstractMatrix{<:RealU},
ker3::AbstractArray{<:RealU,3},
plans::Vector{<:PlanPSF},
)

size(output, 1) == size(image2, 1) || throw("size 1")
size(output, 3) == size(image2, 2) || throw("size 2")

fun = y -> fft_conv_adj!(
(@view output[:, y, :]),
image2,
(@view ker3[:, :, y]),
plans[Threads.threadid()],
)

ntasks = length(plans)
Threads.foreach(fun, _setup(1:size(output, 2)); ntasks)

return output
end
4 changes: 3 additions & 1 deletion test/adjoint-fftconv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# test adjoint consistency for FFT convolution methods on very small case

using SPECTrecon: plan_psf
using SPECTrecon: fft_conv!, fft_conv_adj!
using SPECTrecon: fft_conv!, fft_conv_adj!, fft_conv_adj2!
using SPECTrecon: fft_conv, fft_conv_adj
using LinearMapsAA: LinearMapAA
using Test: @test, @testset
Expand All @@ -29,6 +29,8 @@ end
@test maximum(result) 1
fft_conv_adj!(result, image3, ker3, plan)
@test maximum(result) 1.5 # boundary is the sum of replicate padding
fft_conv_adj2!(result, image3[:, 3, :], ker3, plan)
@test maximum(result) 1.5 # boundary is the sum of replicate padding
end


Expand Down

0 comments on commit d46c881

Please sign in to comment.