update readme.md
Browse files
README.md
CHANGED
|
@@ -1 +1,141 @@
|
|
| 1 |
-
# Image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Image Postprocess β GUI (with Camera Simulator)
|
| 2 |
+
|
| 3 |
+
A polished PyQt5 GUI for the `image_postprocess` pipeline that adds live previews, an input/output analysis panel, an optional camera simulator, and easy parameter control β all wrapped in a clean, user-friendly interface.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## Features
|
| 8 |
+
- Select input, optional reference, and output paths with live previews.
|
| 9 |
+
- **Auto Mode**: one slider to control an expressive preset of postprocess parameters.
|
| 10 |
+
- **Manual Mode**: full access to noise, CLAHE, FFT, phase perturbation, pixel perturbation, etc.
|
| 11 |
+
- Camera pipeline simulator: Bayer/demosaic, JPEG cycles/quality, vignette, chromatic aberration, motion blur, hot pixels, read-noise, banding.
|
| 12 |
+
- Input / output analysis panels (via `AnalysisPanel`) to inspect images before/after processing.
|
| 13 |
+
- Background worker thread with progress reporting and rich error dialog (traceback viewer).
|
| 14 |
+
- Graceful handling of `image_postprocess` import errors (shows a critical dialog with the import error).
|
| 15 |
+
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
## Quick start
|
| 19 |
+
|
| 20 |
+
### Requirements
|
| 21 |
+
- Python 3.8+ recommended
|
| 22 |
+
- PyPI packages:
|
| 23 |
+
```bash
|
| 24 |
+
pip install pyqt5 pillow numpy matplotlib
|
| 25 |
+
# optional but recommended for color matching / some functionality:
|
| 26 |
+
pip install opencv-python
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
### Files expected in the same folder
|
| 30 |
+
- `image_postprocess.py` β your processing logic (export `process_image(...)` or compatible API).
|
| 31 |
+
- `worker.py` β Worker thread wrapper used to run the pipeline in background.
|
| 32 |
+
- `analysis_panel.py` β UI widget used for input/output analysis.
|
| 33 |
+
- `utils.py` β must provide `qpixmap_from_path(path, max_size=(w,h))`.
|
| 34 |
+
|
| 35 |
+
### Run
|
| 36 |
+
Save the GUI script (for example) as `image_postprocess_gui.py` (or use the existing name `image_postprocess_gui_with_analysis_updated.py`) and run:
|
| 37 |
+
|
| 38 |
+
```bash
|
| 39 |
+
python3 image_postprocess_gui.py
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
If `image_postprocess` cannot be imported, the GUI will show an error explaining the import failure (see **Troubleshooting** below).
|
| 43 |
+
|
| 44 |
+
---
|
| 45 |
+
|
| 46 |
+
## Using the GUI (at-a-glance)
|
| 47 |
+
1. **Choose Input** β opens file dialog; sets suggested output path automatically.
|
| 48 |
+
2. *(optional)* **Choose Reference** β used for FFT/color reference (OpenCV-based color match supported).
|
| 49 |
+
3. **Choose Output** β where processed image will be written.
|
| 50 |
+
4. **Auto Mode** β enable for a single slider to control a bundled preset.
|
| 51 |
+
5. **Manual Mode** β tune individual parameters in the Parameters group.
|
| 52 |
+
6. **Camera Simulator** β enable to reveal camera-specific controls (Bayer, JPEG cycles, vignette, chroma, etc.).
|
| 53 |
+
7. Click **Run β Process Image** to start. The GUI disables controls while running and shows progress.
|
| 54 |
+
8. When finished, the output preview and Output analysis panel update automatically.
|
| 55 |
+
|
| 56 |
+
---
|
| 57 |
+
|
| 58 |
+
## Parameters / Controls β `args` mapping
|
| 59 |
+
|
| 60 |
+
When you click **Run**, the GUI builds a lightweight argument namespace (similar to a `SimpleNamespace`) and passes it to the worker. Below are the important mappings used by the GUI (so you know what your `process_image` should expect):
|
| 61 |
+
|
| 62 |
+
- `args.noise_std` β Gaussian noise STD (fraction of 255)
|
| 63 |
+
- `args.clahe_clip` β CLAHE clip limit
|
| 64 |
+
- `args.tile` β CLAHE tile size
|
| 65 |
+
- `args.cutoff` β Fourier cutoff (0.01β1.0)
|
| 66 |
+
- `args.fstrength` β Fourier strength (0β1)
|
| 67 |
+
- `args.phase_perturb` β phase perturbation STD (radians)
|
| 68 |
+
- `args.randomness` β Fourier randomness factor
|
| 69 |
+
- `args.perturb` β small pixel perturbations
|
| 70 |
+
- `args.fft_mode` β one of `auto`, `ref`, `model`
|
| 71 |
+
- `args.fft_alpha` β alpha exponent for 1/f model (used when `fft_mode=='model'`)
|
| 72 |
+
- `args.radial_smooth` β radial smoothing bins for spectrum matching
|
| 73 |
+
- `args.jpeg_cycles` β number of lossy JPEG encode/decode cycles (camera sim)
|
| 74 |
+
- `args.jpeg_qmin`, `args.jpeg_qmax` β JPEG quality range used by camera sim
|
| 75 |
+
- `args.vignette_strength` β vignette intensity (0β1)
|
| 76 |
+
- `args.chroma_strength` β chromatic aberration strength (pixels)
|
| 77 |
+
- `args.iso_scale` β exposure multiplier (camera sim)
|
| 78 |
+
- `args.read_noise` β read noise in DN (camera sim)
|
| 79 |
+
- `args.hot_pixel_prob` β probability of hot pixels (camera sim)
|
| 80 |
+
- `args.banding_strength` β banding strength
|
| 81 |
+
- `args.motion_blur_kernel` β motion blur kernel size
|
| 82 |
+
- `args.seed` β integer seed or `None` when seed==0 in UI
|
| 83 |
+
- `args.sim_camera` β bool: run camera simulation path
|
| 84 |
+
- `args.no_no_bayer` β toggles Bayer/demosaic (True = enable RGGB demosaic)
|
| 85 |
+
- `args.fft_ref` β path to reference image (string) or `None`
|
| 86 |
+
|
| 87 |
+
> **Tip:** Your `process_image(inpath, outpath, args)` should be tolerant of missing keys (use `getattr(args, 'name', default)`), or accept the same `SimpleNamespace` object the GUI builds.
|
| 88 |
+
|
| 89 |
+
---
|
| 90 |
+
|
| 91 |
+
## Error handling / UI behavior
|
| 92 |
+
- The GUI uses a `Worker` thread to avoid blocking the UI. Worker emits signals: `started`, `finished(outpath)`, `error(msg, traceback_text)`.
|
| 93 |
+
- On error, a dialog displays the error message and a full traceback for debugging.
|
| 94 |
+
- If `image_postprocess` fails to import at startup, a critical dialog shows the exception details; fix the module or dependencies and restart.
|
| 95 |
+
|
| 96 |
+
---
|
| 97 |
+
|
| 98 |
+
## Development notes
|
| 99 |
+
- **Integrating your pipeline:** make sure `image_postprocess.py` exports a `process_image(inpath, outpath, args)` function (or adapt `worker.py` to match your pipeline signature).
|
| 100 |
+
- **Analysis panels:** `AnalysisPanel` should provide `update_from_path(path)`; used for both input and output.
|
| 101 |
+
- **Preview helper:** `utils.qpixmap_from_path` is used to load scaled QPixmap for previews β useful for keeping UI responsive.
|
| 102 |
+
- **Packaging:** If you want a single executable, consider `PyInstaller` (note: include `worker.py`, `analysis_panel.py`, `utils.py`, and the pipeline module).
|
| 103 |
+
|
| 104 |
+
---
|
| 105 |
+
|
| 106 |
+
## Troubleshooting
|
| 107 |
+
- **ImportError for `image_postprocess`** β ensure `image_postprocess.py` is in the same directory or on `PYTHONPATH`. Also confirm required packages (numpy, Pillow, opencv) are installed. The GUI shows the import error text at startup.
|
| 108 |
+
- **Previews blank/no image** β check that `qpixmap_from_path` returns a valid QPixmap. The preview widget falls back to `No image` if file missing.
|
| 109 |
+
- **Processing hangs** β confirm Worker is implemented to emit `finished` or `error`. If your `process_image` blocks indefinitely, the GUI will appear unresponsive (worker runs in background thread but won't return).
|
| 110 |
+
- **Color matching unavailable** β color matching uses OpenCV; if you did not install `opencv-python`, the GUI will still run, but reference-based color matching will be disabled.
|
| 111 |
+
|
| 112 |
+
---
|
| 113 |
+
|
| 114 |
+
## Example: minimal `process_image` signature
|
| 115 |
+
```python
|
| 116 |
+
# image_postprocess.py (sketch)
|
| 117 |
+
def process_image(inpath: str, outpath: str, args):
|
| 118 |
+
# args is a SimpleNamespace with attributes described above
|
| 119 |
+
# load image (PIL / numpy), run your pipeline, save output
|
| 120 |
+
pass
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
---
|
| 124 |
+
|
| 125 |
+
## Contributing
|
| 126 |
+
- PRs welcome. If you modify UI layout or parameter names, keep the `args` mapping consistent or update `README` and `worker.py` accordingly.
|
| 127 |
+
- Add unit tests for `worker.py` and the parameter serialization if you intend to refactor.
|
| 128 |
+
|
| 129 |
+
---
|
| 130 |
+
|
| 131 |
+
## License
|
| 132 |
+
MIT β free to use and adapt. Please include attribution if you fork or republish.
|
| 133 |
+
|
| 134 |
+
---
|
| 135 |
+
|
| 136 |
+
## Screenshot
|
| 137 |
+
Add a screenshot in `docs/screenshot.png` to show off the UI:
|
| 138 |
+
|
| 139 |
+
```markdown
|
| 140 |
+

|
| 141 |
+
```
|