From 4c021148f02f4553b1e29d0f90c46d4761bf9dc8 Mon Sep 17 00:00:00 2001 From: gnzng Date: Tue, 29 Jul 2025 16:10:45 -0700 Subject: [PATCH] Enhance line_based_frc function to align images using hann window and subpixel shifting --- src/cdtools/tools/analysis/analysis.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cdtools/tools/analysis/analysis.py b/src/cdtools/tools/analysis/analysis.py index 3655335..28bd275 100644 --- a/src/cdtools/tools/analysis/analysis.py +++ b/src/cdtools/tools/analysis/analysis.py @@ -1597,6 +1597,14 @@ def line_based_frc( if image1.ndim != 2 or image2.ndim != 2: raise ValueError("Images must be 2D") + # Aligning the images using find_shift and sinc_subpixel_shift + # using hann window to reduce artifacts + shift = ip.find_shift( + t.as_tensor(ip.hann_window(image1)), + t.as_tensor(ip.hann_window(image2)) + ) + image2 = ip.sinc_subpixel_shift(t.as_tensor(image2), shift).numpy() + if axis == 1: lines1, lines2 = image1, image2 n_freq = image1.shape[1] // 2