Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

expose rescale_rfft functions #4

@alisterburt

Description

@alisterburt

over at teamtomo/membrain-seg#76 @LorenzLamm and @JoelVO like torch-fourier-rescale but wants to reweight frequencies prior to fourier pad/crop

We should expose the lower level, currently private _rescale_rfft_2d/3d functions

docs will be required for people to use this well - example below can serve as a template

proposed API:

import torch
import torch.fft
from torch_fourier_rescale import fourier_rescale_rfft_3d
from my_package import reweight

volume = torch.rand((32, 32, 32))

# fftshift so that origin of phases in DFT is in the center of the image
# this maintains the center of the image at the position of DC component pre/post rescaling
volume = torch.fft.fftshift(volume, dim=(-3, -2, -1))
dft = torch.fft.rfftn(image, dim=(-3, -2, -1))
dft = torch.fft.fftshift(dft, dim=(-3, -2))

# do the reweighting
dft = reweight(dft)
dft = rescale_rfft_3d(dft)

# transform back to real space and recenter
dft = torch.fft.ifftshift(dft, dim=(-3, -2))
rescaled_volume = torch.fft.irfftn(dft, dim=(-3, -2, -1))
rescaled_volume = torch.fft.ifftshift(rescaled_image, dim=(-3, -2, -1))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions