mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 01:36:27 +00:00
Revert the addition of perpendicular angles and lower attenuation_factor
It was a mistake to add the perpendicular angles in the previous commit: I had the rainbow effect removal process called 2 times when I did this, for testing purposes (One before downscale and one after downscale). The proper way to call the process is only after the downscale. And in this case it is not necessary to remove frequencies along the perpendicular angles. In the mean time, attenuation_factor=0.15 has proven to work well along a collection of testing images. It should be my latest commit for this feature
This commit is contained in:
@@ -14,8 +14,8 @@ def fourier_transform_image(img):
|
|||||||
|
|
||||||
return fft_result
|
return fft_result
|
||||||
|
|
||||||
def attenuate_diagonal_frequencies(fft_spectrum, freq_threshold=0.3, target_angle=135,
|
def attenuate_diagonal_frequencies(fft_spectrum, freq_threshold=0.30, target_angle=135,
|
||||||
angle_tolerance=10, attenuation_factor=0.25):
|
angle_tolerance=10, attenuation_factor=0.15):
|
||||||
"""
|
"""
|
||||||
Attenuates specific frequencies in the Fourier domain (optimized version for rfft2).
|
Attenuates specific frequencies in the Fourier domain (optimized version for rfft2).
|
||||||
|
|
||||||
@@ -64,15 +64,11 @@ def attenuate_diagonal_frequencies(fft_spectrum, freq_threshold=0.3, target_angl
|
|||||||
# Calculation of complementary angle
|
# Calculation of complementary angle
|
||||||
target_angle_2 = (target_angle + 180) % 360
|
target_angle_2 = (target_angle + 180) % 360
|
||||||
|
|
||||||
# Calulation of perpendicular angles (for better final rendering)
|
|
||||||
target_angle_3 = (target_angle + 90) % 360
|
|
||||||
target_angle_4 = (target_angle_3 + 180) % 360
|
|
||||||
|
|
||||||
# Create angular conditions in a vectorized way
|
# Create angular conditions in a vectorized way
|
||||||
angle_condition = np.zeros_like(angles_deg, dtype=bool)
|
angle_condition = np.zeros_like(angles_deg, dtype=bool)
|
||||||
|
|
||||||
# Process both angles simultaneously
|
# Process both angles simultaneously
|
||||||
for angle in [target_angle, target_angle_2, target_angle_3, target_angle_4]:
|
for angle in [target_angle, target_angle_2]:
|
||||||
min_angle = (angle - angle_tolerance) % 360
|
min_angle = (angle - angle_tolerance) % 360
|
||||||
max_angle = (angle + angle_tolerance) % 360
|
max_angle = (angle + angle_tolerance) % 360
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user