Concept Flow - Image filtering (gaussian_filter)
Input Image Array
Apply gaussian_filter
Smooth Image Output
Use or Display Result
Start with an image array, apply gaussian_filter to smooth it, then get the filtered image for use or display.
import numpy as np from scipy.ndimage import gaussian_filter image = np.array([[10, 10, 10], [10, 50, 10], [10, 10, 10]]) filtered = gaussian_filter(image, sigma=1)
| Step | Action | Input Value | Filter Parameter | Output Value |
|---|---|---|---|---|
| 1 | Input image created | [[10,10,10],[10,50,10],[10,10,10]] | sigma=1 | Same as input |
| 2 | Apply gaussian_filter | Image array | sigma=1 | Smoothed image array |
| 3 | Calculate weighted average for center pixel | Center=50 neighbors=10 | sigma=1 | Center pixel approx 22.5 |
| 4 | Calculate weighted average for corner pixel | Corner=10 neighbors=10 and 50 | sigma=1 | Corner pixel approx 12.5 |
| 5 | Filtered image ready | N/A | N/A | [[12.5, 15.6, 12.5],[15.6, 22.5, 15.6],[12.5, 15.6, 12.5]] |
| Variable | Start | After gaussian_filter | Final |
|---|---|---|---|
| image | [[10,10,10],[10,50,10],[10,10,10]] | [[10,10,10],[10,50,10],[10,10,10]] | Same as start |
| filtered | None | N/A | [[12.5, 15.6, 12.5],[15.6, 22.5, 15.6],[12.5, 15.6, 12.5]] |
gaussian_filter(image, sigma) - Smooths image by weighted averaging neighbors - sigma controls blur amount (higher = more blur) - Output is same shape, float values - Useful to reduce noise or details - Works on numpy arrays representing images