🎮 Simulator EP05_01: Ideal Low-Pass Filter
H = (D ≤ D₀) ? 1 : 0
Adjust D₀ and observe which positions of the 5×5 spectrum survive the filter.
Original Spectrum (Magnitude)
Filtered Result
–
In an old document scanner, the sensor captures crumpled paper and fiber texture along with the text — high-frequency noise that “pollutes” the spectrum at the edges. The maintenance technician has no access to the original image, only to the magnitude spectrum already computed by the scanner’s software. Their job is simple and surgical: keep only the central circle of low frequencies (the global structure of the document) and erase everything outside the radius \(D_0\), eliminating the fine texture without even needing to touch the spatial image.
This is the Ideal Low-Pass Filter (LPFI): the most direct spectral operation in the chapter, but also the one that best reveals the anatomy of a centered spectrum.
np.fft.fftshift).| Region | Distance to center | Filter effect |
|---|---|---|
| Center (\(D \le D_0\)) | Low frequencies | Preserved — global structure maintained |
| Edges (\(D > D_0\)) | High frequencies | Zeroed — texture and noise removed |
| Small \(D_0\) | — | Reconstructed image would be very blurry |
| Large \(D_0\) | — | Little filtering; almost all energy preserved |
Input:
Output:
| Input | Output | Observation |
|---|---|---|
| 3 3 1 10 20 30 40 50 60 70 80 90 |
0 20 0 40 50 60 0 80 0 |
Center \((1,1)\). Corners have \(D=\sqrt{2}\approx1.41 > 1\), hence they are zeroed; orthogonal neighbors have \(D=1 \le 1\) and are kept. |
| 1 3 0 5 9 7 |
0 9 0 | \(L=1, C=3\): center at \((0,1)\). Only the central position itself (\(D=0\)) survives \(D_0=0\). |
%%writefile EP05_01.cpp
// your solutionOverwriting EP05_01.cpp
TestSuite("EP05_01.cpp").run()✔️ EP05_01.cases already exists in casos/
📋 5 case(s) loaded from casos/EP05_01.cases
🔍 Testing C++: EP05_01.cpp
⚠️ EP05_01.cpp: Empty file (fewer than 3 lines). Tests skipped.