From 0d967084a0c6bdda693771b60f1896b7e6f3ae5e Mon Sep 17 00:00:00 2001 From: Its-my-right Date: Sun, 13 Jul 2025 16:09:32 +0200 Subject: [PATCH] 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 --- kindlecomicconverter/rainbow_artifacts_eraser.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/kindlecomicconverter/rainbow_artifacts_eraser.py b/kindlecomicconverter/rainbow_artifacts_eraser.py index 29ed773..ee6d705 100644 --- a/kindlecomicconverter/rainbow_artifacts_eraser.py +++ b/kindlecomicconverter/rainbow_artifacts_eraser.py @@ -14,8 +14,8 @@ def fourier_transform_image(img): return fft_result -def attenuate_diagonal_frequencies(fft_spectrum, freq_threshold=0.3, target_angle=135, - angle_tolerance=10, attenuation_factor=0.25): +def attenuate_diagonal_frequencies(fft_spectrum, freq_threshold=0.30, target_angle=135, + angle_tolerance=10, attenuation_factor=0.15): """ 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 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 angle_condition = np.zeros_like(angles_deg, dtype=bool) # 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 max_angle = (angle + angle_tolerance) % 360