File size: 762 Bytes
753375e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Bake a synthetic noisy image + clean ground-truth sidecar into APP_TMP_DIR."""
from __future__ import annotations

import sys

import numpy as np
import tifffile

from core.io import APP_TMP_DIR, register_protected
from core.synth import add_noise, clean_image


def main() -> int:
    clean = clean_image(H=256, W=256, seed=7)
    noisy = add_noise(clean, sigma=0.13, seed=7)
    out = APP_TMP_DIR / "example.tif"
    tifffile.imwrite(out, (noisy * 255).astype("uint8"))
    np.save(APP_TMP_DIR / "example_clean.npy", clean)               # ground-truth sidecar
    register_protected(out)
    register_protected(APP_TMP_DIR / "example_clean.npy")
    print(f"wrote {out}  shape={noisy.shape}")
    return 0


if __name__ == "__main__":
    sys.exit(main())