Turn a scanned, printed microphone calibration chart into a usable CSV for Room EQ Wizard (REW).
- I bought a "the t.bone MM-1 Measuring Microphone" from Thomann. It’s inexpensive and (unlike some Behringer units) it comes with an individual calibration curve.
- The catch: the curve is only provided on paper, which is useless for software workflows like REW without digitizing it.
- This tool lets you scan that sheet (or take a photo), process the image through an interactive pipeline, trace the plotted line, and export a REW-friendly CSV.
- Interactive pipeline UI: add, remove, reorder, and tweak processing steps.
- Robust image ops: crop, thresholding, adaptive thresholding, morphology (dilate/erode), blur, unsharp mask, Sobel edges.
- Curve tracing: extracts a single black curve and maps image coordinates to frequency/dB with adjustable axis scales.
- REW export: writes
Frequency_Hz,dBCSV for direct use in REW as a mic calibration file. - Flexible to real-world scans: handles different scanners, resolutions, mild skew, and lighting with parameter tuning.
- Import/export pipeline JSON so you can share and iterate on what works for your scans.
- Python 3.8+
- Packages:
numpy,Pillow(Tkinter is bundled with most Python installs on Windows/macOS; on some Linux distros you may needpython3-tk).
Install deps:
pip install numpy pillow
- GUI with optional image path:
python scan2rew.py path/to/your_scan.png - GUI picker (no args):
python scan2rew.py - Non‑GUI (headless) CSV export:
python scan2rew.py <image> <pipeline.json> <out.csv>
Recommended input: a reasonably straight, cropped image focusing on the chart area. Higher resolution (e.g., 300–600 DPI) helps.
Run the pipeline without opening the UI and write a REW CSV.
Usage
python scan2rew.py <image> <pipeline.json> <out.csv>
Behavior
- Loads the image as grayscale and applies the given pipeline JSON.
- Requires the pipeline to include "Trace to Graph" with sensible axis settings.
- Writes
Frequency_Hz,dBrows to<out.csv>.
Example
python scan2rew.py example/Scan01.JPG default_pipeline.json example/Scan01_REW.csv
- Scan the sheet or take a high-quality photo and save as PNG/TIFF/JPG.
- Open it in the app (
scan2rew.py). The left panel is your pipeline, the center shows step parameters, and the canvas previews Original vs Processed. - Add and tune steps until the chart’s curve becomes a clean single-pixel-ish dark trace across all columns (no gaps).
- Add the "Trace to Graph" step last. Tune its parameters and axis mapping so the traced line covers the full width/height range.
- Once tracing succeeds, the "Save REW CSV" button becomes enabled. Click it to export.
- Threshold / Adaptive Threshold: isolate the line from the background grid/paper.
- Morphology (Dilate/Erode): thicken and then clean the line, or remove noise.
- Gaussian Blur + Unsharp Mask: smooth jaggies and enhance edges before thresholding.
- Trace to Graph: turns the processed image into a mapped (freq, dB) series.
invert: flip black/white if the curve is light on dark.smooth: moving average over the traced y to reduce noise.stroke: thickness of the rendered trace overlay.f_min,f_max: frequency span (use log scale for typical mic charts).db_min,db_max: dB span matching your chart’s Y axis labels.x_scale:logorlinearbased on the chart’s X axis.y_origin:bottomif higher on the page is higher dB (most charts), otherwisetop.
When tracing succeeds, every image column must contain at least one dark pixel on the processed image (the app enforces this and will warn if there are gaps). If you see gaps, adjust earlier steps.
- Use the "Save REW CSV" button. The file has a header and two columns:
Frequency_Hz,dB
- Load this file in REW as your microphone calibration. Verify the range + polarity make sense by comparing with the printed curve.
Included default_pipeline.json replicates a working setup on my scan of the t.bone MM‑1 sheet. As a starting point:
- Morphology: Dilate,
k=3 - Morphology: Erode,
k=5 - Gaussian Blur:
radius=2.0 - Threshold:
t≈164,invert=false - Trace to Graph:
smooth≈1.6,x_scale=log,y_origin=bottom(adjustf_min/f_maxanddb_min/db_maxto match your chart labels)
Import this via "Import pipeline (JSON)", then tweak to your scan.
This repo includes a default pipeline (in default_pipeline.json) that uses the new Crop step first, followed by morphological cleanup, blur, threshold, and tracing.
Steps
- Run:
python scan2rew.py example/Scan01.JPG - Click "Import pipeline (JSON)" and select
default_pipeline.json. - In the Step Parameters, adjust
Crop(left,top,right,bottom) so the chart’s axes and curve fill the processed pane without margins. - Verify thresholded output shows a continuous dark trace across all columns. If needed, tweak Morphology/Blur/Threshold.
- In "Trace to Graph": set
x_scale=log,y_origin=bottom, and adjustf_min/f_max(e.g., 20–20000 Hz) anddb_min/db_maxto match the printed chart. - Click "Save REW CSV" and save as
example/Scan01_REW.csv.
Open the CSV in REW as the mic calibration file and visually confirm it matches the printed curve.
- Crop before processing so the curve occupies most of the image width/height.
- Remove color if your scan is tinted; the app converts to grayscale internally but neutral scans help.
- If the grid overwhelms the curve, try slight blur → threshold, or adaptive threshold with a suitable window size.
- If traced output looks flipped vertically, toggle
y_origin. If frequencies look wrong, switchx_scaleor adjustf_min/f_max.
scan2rew.py: the interactive processing app (also supports headless CLI).default_pipeline.json: default pipeline that worked on the included example.example/: sample inputs and outputs (e.g.,example/Scan01.JPG,example/Scan01_REW.csv).
- Add explicit crop/deskew tools in-app.
- Add grid removal helpers and color channel selection.
- Add optional multi-curve separation (if charts include multiple lines).
- MIT — see
LICENSEfor details.
- Built to digitize the t.bone MM‑1 paper calibration chart for use in REW. Should be adaptable to similar charts from other microphones.
