Application Scenarios
- Periodic Noise Removal: Identify and filter periodic interference patterns
- Texture Analysis: Extract directional and periodic features from frequency domain
- Image Enhancement: Frequency-domain sharpening and smoothing
- Pattern Recognition: Frequency-based texture classification
Usage Examples
Basic Usage
Frequency Domain Filtering with Custom Mask
Low-pass Filter (smooth)
Class Description
CFAImageFourier
Fourier analysis for grayscale or RGB images. 2D FFT computed at initialization. Supports decomposition, visualization, reconstruction, and custom frequency masking.
__init__(image)
image: Grayscale (H,W) or RGB (H,W,3). FFT is computed immediately; for grayscale one pair is stored, for RGB three channel pairs are stored.
get_raw_spectrum()
Returns (magnitude_list, phase_list) — raw (not log-scaled). Use these for reconstruction, not the display versions.
get_display_spectrum(alpha=1.0, beta=0, magnitude=array([]), phase=array([]))
Returns (display_mag, display_phase) — log-scaled 8-bit visualization. Pass custom magnitude/phase to visualize masked spectra.
get_reconstruct(magnitude=array([]), phase=array([]))
IFFT(IFFTSHIFT(mag * exp(1j * phase))), normalized to [0,255]. Returns uint8 image.
extract_by_freq_mask(mask_mag=array([]), mask_phase=array([]))
Apply binary mask to frequency domain, then reconstruct. Shape: same as frequency map (H,W).
plot(...)
Side-by-side 2-row grid: original, raw magnitude, raw phase, customized magnitude, customized phase, full reconstruction, masked reconstruction.
get_image_components(image) [static]
Returns (magnitude, phase) for a single-channel image using 2D FFT + fftshift.
normalize_and_enhance(array, alpha=1.0, beta=0) [static]
Normalize to [0,255] and apply linear contrast scaling. Returns uint8.
Algorithm
Forward FFT Pipeline
Reconstruction Pipeline
Display Enhancement
Important Notes
- Input: Only 2D grayscale or 3D RGB supported; others raise ValueError
- Raw vs Display: Use
get_raw_spectrum()for reconstruction; display version is log-scaled - Mask: Shape must match frequency map (H,W); 0=zero out, 1=keep
- RGB: Independent FFT per channel; reconstruction merges channels with cv2.merge
References
- Brigham, E. O. (1988). The Fast Fourier Transform and Its Applications.
- Gonzalez, R. C., & Woods, R. E. (2018). Digital Image Processing (4th ed.).