Final Dimensions: The sampled image will have dimensions \(\lceil L/f \rceil \times \lceil C/f \rceil\). In programming terms, this is equivalent to the resulting size of a slice with step \(f\).
Implementation: Do not use ready-made functions from image processing libraries (such as OpenCV or PIL) for resizing. Implement the pixel selection logic manually or via matrix slicing.
Aliasing: Note that this process may cause the aliasing effect (jagged edges), where fine details are lost or unwanted patterns appear.
2.12.2.1 🧠 Discretization of Space
Subsampling reduces the spatial resolution of an image by selecting only one pixel every \(f\) pixels in each direction. It is the inverse process of interpolation:
Parameter
Function
Effect
Factor \(f\)
Sampling step
Defines the selection interval. A factor of \(2\) reduces the width and height by half.
Resolution
Pixel density
Decreases the total amount of spatial information in the image.
Aliasing
Side effect
Emergence of staircase patterns or blocks due to the loss of fine details.
2.12.2.2 📋 Task (specification for VPL)
Input:
The first line contains L.
The second line contains C.
The third line contains the factor f.
The following lines contain the elements of the \(L \times C\) matrix.
Output:
The reduced matrix with dimensions corresponding to the slicing by f.
2.12.2.3 📌 Examples
Input
Output
Observation
2
4
2
10 20 30 40
50 60 70 80
10 30
Factor 2 selects pixels (0,0) and (0,2) from the first row. The second row is ignored.
Adjust the subsampling factor (f) to observe the reduction in the spatial dimension of the matrix and the skip-sampling of the top-left pixels of each f × f block.
1
f = 1 → Original Resolution (4×4) | f = 2 → Half (2×2) | f = 3 or 4 → Single Sample (1×1)
Original (4×4)
Subsampled (Variable Size)
Factor f = 1 → keeps all original pixels (4×4)
Figure 2.13: EP02_02 Simulator: Spatial Subsampling (Resolution Reduction by f-Step)
%%writefile EP02_02.py# Python code
Overwriting EP02_02.py
TestSuite("EP02_02.py").run()
✔️ EP02_02.cases already exists in casos/
📋 5 case(s) loaded from casos/EP02_02.cases
🔍 Testing Python: EP02_02.py
⚠️ EP02_02.py: Empty file (fewer than 3 lines). Tests skipped.