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

FSIM index #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions src/ImageQualityIndexes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ImageFiltering: KernelFactors, kernelfactors, imfilter
using Statistics: mean, std
using Base.Iterators: repeated, flatten

include("fsim.jl")
include("generic.jl")
include("psnr.jl")
include("ssim.jl")
Expand All @@ -18,6 +19,9 @@ include("colorfulness.jl")
include("deprecations.jl")

export
# fsim
fsim,

# generic
assess,

Expand Down
34 changes: 34 additions & 0 deletions src/fsim.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# using ImagePhaseCongruency
# using Images

function fsim_similarity_measure(x, y, constant)
"""
Calculate feature similarity measurement between two images
"""
numerator = 2 * x * y .+ constant
denominator = x^2 .+ y^2 .+ constant

return numerator ./ denominator
end

function fsim(org_img, pred_img, T1=0.85, T2=160)
# alpha,beta parameters used to adjust the relative importance of PC and GM features
alpha = 1
beta = 1
fsim_list = []
for i in [red,green,blue]
(M1, m1, or1, ft1, EO1, T1) = phasecong3(i.(org_img);nscale=4,minwavelength=6, mult=2,sigmaonf=0.5978)
(M2, m2, or2, ft2, EO2, T2) = phasecong3(i.(pred_img);nscale=4,minwavelength=6, mult=2,sigmaonf=0.5978)
pco_sum = M1
pcp_sum = M2
grad1x, grad1y, gm1, orient1 = imedge(i.(org_img))
grad2x, grad2y, gm2, orient2 = imedge(i.(pred_img))
S_pc = fsim_similarity_measure(pco_sum, pcp_sum, T1)
S_g = fsim_similarity_measure(gm1, gm2, T2)
S_l = (S_pc^alpha) .* (S_g^beta)
numerator = sum(S_l .* map(max,pco_sum, pcp_sum))
denominator = sum(map(max,pco_sum, pcp_sum))
push!(fsim_list, numerator / denominator)
end
return mean(fsim_list)
end