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

feat: Allow Complex valued FFT #275

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions src/imfilter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,11 @@ function _imfilter_fft!(r::AbstractCPU{FFT},
end

function filtfft(A, krn)
Copy link
Member

@johnnychen94 johnnychen94 Oct 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the absence @kunzaatko.

Roughly speaking, JuliaImages treats two families of types as numeric types: Colorant{<:Number} and T<:Number.
Thus it's a good idea for the dispatch design to explicitly express this.

I'd like to see three methods:

# simple channelview/colorview wrapper over the plain number methods
filtfft(A::AbstractArray{CT}, krn) where CT<:Colorant 

filtfft(A::AbstractArray{T}, krn) where T<:Complex # your newly added method
filtfft(A::AbstractArray{T}, krn) where T<:Real

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. Thank you for your work on this package!
I would argue that we are missing the methods for complex kernels in the two bottom methods. I implemented these in the new version.

B = fft(A)
B .*= conj!(fft(krn))
ifft(B)
end
function filtfft(A::AbstractArray{AT}, krn::AbstractArray{KT}) where {AT<:Real,KT<:Real}
B = rfft(A)
B .*= conj!(rfft(krn))
irfft(B, length(axes(A, 1)))
Expand Down
Loading