diff options
| author | yum <yum.food.vr@gmail.com> | 2025-07-28 01:43:06 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-07-28 01:43:06 -0700 |
| commit | 887136420c983bd504e38b36198921946623a0d7 (patch) | |
| tree | 7158735d8f07a142d9465ac62f903fc0d845218b /generate_fft_reference.py | |
| parent | 795cb4c8b5e45c7f772b9efb01799c0a722e984d (diff) | |
fix coordinates in generate_fft_reference.py
Diffstat (limited to 'generate_fft_reference.py')
| -rw-r--r-- | generate_fft_reference.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/generate_fft_reference.py b/generate_fft_reference.py index a7d58f4..db2289d 100644 --- a/generate_fft_reference.py +++ b/generate_fft_reference.py @@ -18,10 +18,13 @@ def main(): # Load input image and convert to luminance img = Image.open(args.input).convert('RGB') - img = img.resize((args.size, args.size), Image.Resampling.LANCZOS) + img = img.resize((args.size, args.size), Image.Resampling.NEAREST) img_array = np.array(img, dtype=np.float32) / 255.0 luminance = 0.2126 * img_array[:,:,0] + 0.7152 * img_array[:,:,1] + 0.0722 * img_array[:,:,2] + # Unity's UV origin is bottom-left, NumPy/PIL's is top-left; flip vertically to align + luminance = np.flipud(luminance) + # Perform 2D FFT (no fftshift, matching GPU implementation) fft_result = np.fft.fft2(luminance) @@ -30,6 +33,10 @@ def main(): real_part = fft_result.real.astype(np.float32) imag_part = fft_result.imag.astype(np.float32) + # Unity's output texture also uses bottom-left origin, so flip output too + real_part = np.flipud(real_part) + imag_part = np.flipud(imag_part) + # Create EXR height, width = args.size, args.size header = OpenEXR.Header(width, height) |
