tezvyn:

Removing salt-and-pepper noise

AI-drafted, machine-checkedSource: interviewintermediate
WHAT IT TESTS

filter choice for impulse noise.

OUTLINE

use a median filter; it replaces a pixel with the neighborhood median so extreme outliers are discarded.

RED FLAG

choosing Gaussian blur, which averages outliers in and smears edges.

WHAT THIS TESTS The interviewer wants you to connect the statistical nature of the noise to the right denoising operator, and to articulate why averaging fails on impulse noise.

A GOOD ANSWER COVERS Salt-and-pepper noise, also called impulse noise, randomly flips scattered pixels to the maximum or minimum intensity, producing white and black specks. The right tool is the median filter, a non-linear filter that slides a window over the image and replaces the center pixel with the median of the values in that window. Because the corrupted pixels are extreme outliers, they land at the very ends of the sorted list and are never selected as the median, so they are discarded rather than spread.

COMMON WRONG ANSWERS Choosing a Gaussian or box blur. These are linear averaging filters, so an outlier value of 255 still contributes its full weight to the average, dragging the result toward the noise and only partially attenuating each speck while blurring genuine edges. Believing a stronger blur eventually fixes it; it only smears.

LIKELY FOLLOW-UPS How does window size trade detail against noise removal. What happens at very high noise density. Why does the median preserve edges better than the mean.

ONE CONCRETE EXAMPLE Consider a 3 by 3 neighborhood whose true values are around 120 but where one pixel was corrupted to 255. The nine sorted values might be 118, 119, 120, 120, 121, 121, 122, 123, 255. The median is the fifth value, 121, which is exactly the local true intensity, and the corrupting 255 is ignored entirely. A mean filter on the same window would compute roughly 135 because the 255 pulls the average up, leaving a visible bright halo and a softened edge. This is why the median filter cleanly removes specks while keeping edges sharp: it selects an actual representative neighbor instead of blending. The trade-off is that a larger window removes denser noise but can erase fine texture, so you size the window to the noise level.

Read the original → en.wikipedia.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.