Skip to content

Commit c98b36c

Browse files
committed
Added documentation for Fourier-based methods
1 parent a42d1ea commit c98b36c

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/sharpness/fourier.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
"""Module containing low-level functions based on Fourier analysis"""
2+
13
import numpy as np
24

35

46
def compute_power_spectrum(image, hanning=True):
7+
"""Utility method used for the other metrics in this"""
58
N = image.shape[0]
69
if hanning:
710
# Set up 2D Hanning window to deal with edge effects
@@ -16,16 +19,18 @@ def compute_power_spectrum(image, hanning=True):
1619

1720

1821
def fourier_rmse(image1, image2, hanning=True):
22+
"""Bivariate -- Unweighted RMSE between power spectra of the input images"""
1923
# Compute power spectra of both images
2024
power_spectrum1 = compute_power_spectrum(image1, hanning=hanning)
2125
power_spectrum2 = compute_power_spectrum(image2, hanning=hanning)
2226

2327
# Compute the mean squared error between power spectra
24-
mse = np.mean((power_spectrum1-power_spectrum2)**2)
28+
mse = np.mean((power_spectrum1 - power_spectrum2) ** 2)
2529
return np.sqrt(mse)
2630

2731

2832
def fourier_total_variation(image, hanning=True):
33+
"""Univariate -- Total variation within the power spectra of a given image"""
2934
N = image.shape[0]
3035
if hanning:
3136
# Set up 2D Hanning window to deal with edge effects
@@ -36,12 +41,3 @@ def fourier_total_variation(image, hanning=True):
3641
f_transform = np.fft.fft2(image)
3742
tv = np.sum(np.abs(f_transform))
3843
return tv
39-
40-
41-
if __name__ == '__main__':
42-
from skimage.data import camera
43-
image1 = camera()
44-
image2 = camera()
45-
46-
fourier_rmse = fourier_rmse(image1, image2)
47-
print("Fourier power spectrum RMSE:", fourier_rmse)

0 commit comments

Comments
 (0)