• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kunzaatko / TransferFunctions.jl / 17428316153

03 Sep 2025 08:54AM UTC coverage: 86.298% (-0.05%) from 86.345%
17428316153

push

github

kunzaatko
feat(ext): Add support for `FFT.fft` on Colorant types

17 of 18 new or added lines in 1 file covered. (94.44%)

1 existing line in 1 file now uncovered.

655 of 759 relevant lines covered (86.3%)

39553920.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.0
/ext/ImageCoreExt.jl
1
module ImageCoreExt
2
using ImageCore, FFTViews, FFTW
3
using TransferFunctions
4
using TransferFunctions.FFT
5
using ImageCore: Color1
6

7
# TODO: Use `channel_view` and call the underlining `corrfft` method instead of creating a new one <03-09-25> 
8
function TransferFunctions.corrfft(A::AbstractArray{CT}, K) where {CT<:Colorant}
15✔
9
    Av, dims = channelview_dims(A)
15✔
10
    Kc = kreshape(CT, K)
15✔
11
    B = rfft(Av, dims)
15✔
12
    B .*= conj!(rfft(Kc, dims))
30✔
13
    Avf = irfft(B, length(axes(Av, dims[1])), dims)
15✔
14
    colorview(base_colorant_type(CT){eltype(Avf)}, Avf)
15✔
15
end
16

17
function FFT.fft(A::AbstractArray{CT}) where {T<:Real, CT<:Color1{T}} 
10✔
18
    rfft_out = FFTW.rfft(channelview(A))
10✔
19
    if eltype(rfft_out) <: Complex 
10✔
20
        FFT.RFFTOut(rfft_out, length(axes(A,1)))
10✔
21
    else # FIX: Does this ever occur even? Is is possible that the `rfft` outputs a real array instead of a complex one? <03-09-25> 
NEW
22
        FFT.RFFTOut(colorview(base_colorant_type(CT){eltype(rfft_out)}, rfft_out), length(axes(A,1)))
×
23
    end
24
end
25

26
# FIX: This is currently separated only because `FFT` does not support `dims` yet. <03-09-25> 
27
function TransferFunctions.corrfft(A::AbstractArray{CT}, K) where {CT<:ImageCore.Color1}
25✔
28
    Av = channelview(A)
25✔
29
    Kc = kreshape(CT, K)
25✔
30
    B = FFT.fft(Av)
25✔
31
    B .*= conj!(FFT.fft(Kc))
25✔
32
    Avf = FFT.ifft(B)
25✔
33
    colorview(base_colorant_type(CT){eltype(Avf)}, Avf)
25✔
34
end
35

36
channelview_dims(A::AbstractArray{C,N}) where {C<:Colorant,N} = channelview(A), ntuple(d -> d + 1, Val(N))
36✔
UNCOV
37
channelview_dims(A::AbstractArray{C,N}) where {C<:ImageCore.Color1,N} = channelview(A), ntuple(identity, Val(N))
×
38

39
function kreshape(::Type{C}, K::FFTView) where {C<:Colorant}
6✔
40
    Kp = parent(K)
15✔
41
    FFTView(reshape(K, 1, size(Kp)...))
15✔
42
end
43
kreshape(::Type{C}, K::FFTView) where {C<:ImageCore.Color1} = K
25✔
44
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc