fix(v5): default fft spectrum to log magnitude
This commit is contained in:
@@ -223,15 +223,12 @@ def image_state_fft_spectrum_create(*, state, params):
|
||||
"""
|
||||
|
||||
source = load_image_array(state.image)
|
||||
mode = params.get("mode", "log_magnitude")
|
||||
if mode not in {"magnitude", "log_magnitude", "phase"}:
|
||||
raise ProcessingError("FFT mode must be magnitude, log_magnitude, or phase.")
|
||||
spectrum = image_fft(source)
|
||||
preview = fft_preview_image(spectrum, mode)
|
||||
preview = fft_preview_image(spectrum)
|
||||
fft_data_path = save_fft_array(spectrum, "state-fft-data")
|
||||
operation_params = {
|
||||
**params,
|
||||
"mode": mode,
|
||||
**(params or {}),
|
||||
"mode": "log_magnitude",
|
||||
"fft_data_path": fft_data_path,
|
||||
"source_state_id": str(state.id),
|
||||
"source_color_mode": "RGB" if source.ndim == 3 else "L",
|
||||
@@ -276,15 +273,10 @@ def image_fft(image):
|
||||
return np.stack(channels, axis=2)
|
||||
|
||||
|
||||
def fft_preview_image(spectrum, mode):
|
||||
"""Convert complex FFT data to a display-only uint8 preview image."""
|
||||
def fft_preview_image(spectrum):
|
||||
"""Convert complex FFT data to a display-only log-magnitude uint8 preview image."""
|
||||
|
||||
if mode == "phase":
|
||||
preview = np.angle(spectrum)
|
||||
else:
|
||||
preview = np.abs(spectrum)
|
||||
if mode == "log_magnitude":
|
||||
preview = np.log1p(preview)
|
||||
preview = np.log1p(np.abs(spectrum))
|
||||
return normalize_to_uint8(preview)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user