Smoothing
Learn about the types of image smoothing, and when to use them.
We'll cover the following...
Smoothing an image
1.
When do we need to smooth an image?
Show Answer
Q1 / Q1
Did you find this helpful?
What do we mean by noise?
Noise in an image is a random quantity that adds to the signal, corrupting the pixel’s gray level or color. As a function of the imaging system that generates our images and the lighting conditions, noise could be so severe as to prevent any automated inspection task.
Let’s see this in action. Consider the image below, severely affected by uncorrelated Gaussian noise.
Press + to interact
Let’s convert this image to grayscale, apply various uniform thresholds, and see the resulting masks.
Press + to interact
import cv2original_img = cv2.imread('./images/fruits/bananas_black1b_noise.jpg')grayscale_img = cv2.cvtColor(original_img, cv2.COLOR_BGR2GRAY)# Apply various uniform thresholdsthresholds = [60, 90, 105, 120, 150]for threshold_ndx in range(len(thresholds)):threshold = thresholds[threshold_ndx]retval, mask = cv2.threshold(grayscale_img, threshold, 255, cv2.THRESH_BINARY)# Annotate the mask with the applied threshold valuecv2.putText(mask, str(threshold), (0, 60), cv2.FONT_HERSHEY_SIMPLEX,1.0, 255, 2)cv2.imwrite(f'./output/{threshold_ndx + 1}_mask.png', mask)cv2.imwrite('./output/0_original.png', original_img)
In line 10, we call the ...