import cv2
import numpy as np

def MySmooth(img):
    rows, columns = np.shape(img)
    Ismooth = np.zeros((rows+2, columns+2), dtype=np.uint8)
    Ismooth[1:rows+1, 1:columns+1] = img
    for r in range(1,rows+1):
        for c in range(1, columns+1):
            avg = np.sum(Ismooth[r-1:r+2:1, c-1:c+2:1])/9
            Ismooth[r, c] = avg
    return Ismooth
I = cv2.imread(r'C:\Program Files\MATLAB\R2021a\toolbox\images\imdata\bag.png', cv2.IMREAD_ANYDEPTH)
cv2.imshow('figure1', I)
Ismooth = MySmooth(I)
cv2.imshow('figure1-smooth', Ismooth)
Ismooth = MySmooth(Ismooth)
cv2.imshow('figure1-smooth2', Ismooth)
cv2.waitKey(0)


bfc692a8a2c6d6c41e1a273f7e9285be7b23a7e0
<mask token>


def MySmooth(img):
    rows, columns = np.shape(img)
    Ismooth = np.zeros((rows + 2, columns + 2), dtype=np.uint8)
    Ismooth[1:rows + 1, 1:columns + 1] = img
    for r in range(1, rows + 1):
        for c in range(1, columns + 1):
            avg = np.sum(Ismooth[r - 1:r + 2:1, c - 1:c + 2:1]) / 9
            Ismooth[r, c] = avg
    return Ismooth


<mask token>

<mask token>


def MySmooth(img):
    rows, columns = np.shape(img)
    Ismooth = np.zeros((rows + 2, columns + 2), dtype=np.uint8)
    Ismooth[1:rows + 1, 1:columns + 1] = img
    for r in range(1, rows + 1):
        for c in range(1, columns + 1):
            avg = np.sum(Ismooth[r - 1:r + 2:1, c - 1:c + 2:1]) / 9
            Ismooth[r, c] = avg
    return Ismooth


<mask token>
cv2.imshow('figure1', I)
<mask token>
cv2.imshow('figure1-smooth', Ismooth)
<mask token>
cv2.imshow('figure1-smooth2', Ismooth)
cv2.waitKey(0)

<mask token>


def MySmooth(img):
    rows, columns = np.shape(img)
    Ismooth = np.zeros((rows + 2, columns + 2), dtype=np.uint8)
    Ismooth[1:rows + 1, 1:columns + 1] = img
    for r in range(1, rows + 1):
        for c in range(1, columns + 1):
            avg = np.sum(Ismooth[r - 1:r + 2:1, c - 1:c + 2:1]) / 9
            Ismooth[r, c] = avg
    return Ismooth


I = cv2.imread(
    'C:\\Program Files\\MATLAB\\R2021a\\toolbox\\images\\imdata\\bag.png',
    cv2.IMREAD_ANYDEPTH)
cv2.imshow('figure1', I)
Ismooth = MySmooth(I)
cv2.imshow('figure1-smooth', Ismooth)
Ismooth = MySmooth(Ismooth)
cv2.imshow('figure1-smooth2', Ismooth)
cv2.waitKey(0)

import cv2
import numpy as np


def MySmooth(img):
    rows, columns = np.shape(img)
    Ismooth = np.zeros((rows + 2, columns + 2), dtype=np.uint8)
    Ismooth[1:rows + 1, 1:columns + 1] = img
    for r in range(1, rows + 1):
        for c in range(1, columns + 1):
            avg = np.sum(Ismooth[r - 1:r + 2:1, c - 1:c + 2:1]) / 9
            Ismooth[r, c] = avg
    return Ismooth


I = cv2.imread(
    'C:\\Program Files\\MATLAB\\R2021a\\toolbox\\images\\imdata\\bag.png',
    cv2.IMREAD_ANYDEPTH)
cv2.imshow('figure1', I)
Ismooth = MySmooth(I)
cv2.imshow('figure1-smooth', Ismooth)
Ismooth = MySmooth(Ismooth)
cv2.imshow('figure1-smooth2', Ismooth)
cv2.waitKey(0)

import cv2
import numpy as np

def MySmooth(img):
    rows, columns = np.shape(img)
    Ismooth = np.zeros((rows+2, columns+2), dtype=np.uint8)
    Ismooth[1:rows+1, 1:columns+1] = img
    for r in range(1,rows+1):
        for c in range(1, columns+1):
            avg = np.sum(Ismooth[r-1:r+2:1, c-1:c+2:1])/9
            Ismooth[r, c] = avg
    return Ismooth
I = cv2.imread(r'C:\Program Files\MATLAB\R2021a\toolbox\images\imdata\bag.png', cv2.IMREAD_ANYDEPTH)
cv2.imshow('figure1', I)
Ismooth = MySmooth(I)
cv2.imshow('figure1-smooth', Ismooth)
Ismooth = MySmooth(Ismooth)
cv2.imshow('figure1-smooth2', Ismooth)
cv2.waitKey(0)

