<jupyter_start><jupyter_text>Environment* activate envopnecv* anaconda & python2.7 & opencv & win7  1. 2D Convolution**averaging*** computing the average of the pixel values inside that window* convolution is a basic operation on image<jupyter_code>import cv2
import numpy as np
from matplotlib import pyplot as plt

img = cv2.imread('lena.jpg', cv2.IMREAD_GRAYSCALE )# IMREAD_GRAYSCALE, IMREAD_COLOR

kernel = np.ones((5,5),np.float32)/25
dst = cv2.filter2D(img,-1,kernel)

plt.subplot(121),plt.imshow(img, cmap = 'gray', interpolation = 'bicubic'),plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(dst, cmap = 'gray', interpolation = 'bicubic'),plt.title('Averaging')
plt.xticks([]), plt.yticks([])
plt.show()<jupyter_output><empty_output><jupyter_text>2. Image Blurring* blur = convolution with diff kernels<jupyter_code>blur = cv2.blur(img,(5,5))

plt.subplot(121),plt.imshow(img, cmap = 'gray', interpolation = 'bicubic'),plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(blur, cmap = 'gray', interpolation = 'bicubic'),plt.title('Blurring')
plt.xticks([]), plt.yticks([])
plt.show()<jupyter_output><empty_output><jupyter_text>3. Gaussian Filtering<jupyter_code>blur = cv2.GaussianBlur(img,(5,5),0)
plt.subplot(121),plt.imshow(img, cmap = 'gray', interpolation = 'bicubic'),plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(blur, cmap = 'gray', interpolation = 'bicubic'),plt.title('Gaussian')
plt.xticks([]), plt.yticks([])
plt.show()<jupyter_output><empty_output><jupyter_text>4. Median Filtering<jupyter_code>median = cv2.medianBlur(img,5)
plt.subplot(121),plt.imshow(img, cmap = 'gray', interpolation = 'bicubic'),plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(median, cmap = 'gray', interpolation = 'bicubic'),plt.title('Median')
plt.xticks([]), plt.yticks([])
plt.show()<jupyter_output><empty_output><jupyter_text>5. Bilateral Filtering* highly effective at noise removal while preserving edges<jupyter_code>blur = cv2.bilateralFilter(img,9,75,75)
plt.subplot(121),plt.imshow(img, cmap = 'gray', interpolation = 'bicubic'),plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(blur, cmap = 'gray', interpolation = 'bicubic'),plt.title('Bilateral')
plt.xticks([]), plt.yticks([])
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19043624161073824, 'fraction_numerical': 0.027684563758389263, 'mean_word_length': 8.280155642023347, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '457014', 'license': 'MIT', 'n_tokens_mistral': 997, 'n_tokens_neox': 897, 'n_words': 147, 'path': 'image_process/opencv/pre_process/smooth.ipynb', 'repo_name': 'ybdesire/machinelearning', 'size': '2384'}