This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
# erosion of a img with a structuring element | |
def erosion(img, struct_element): | |
# get the image and structuring element dimensions | |
x_img, y_img = img.shape | |
x_struct, y_struct = struct_element.shape | |
struct_center = (x_struct // 2, y_struct // 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
def convolve2D(image, kernel): | |
# Flip the kernel | |
kernel = np.flipud(np.fliplr(kernel)) | |
# Get the image and kernel dimensions | |
x_kern, y_kern = kernel.shape |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
import matplotlib.pyplot as plt | |
def histogram(img): | |
hist = np.zeros(256) | |
for i in range(img.shape[0]): | |
for j in range(img.shape[1]): | |
hist[img[i, j]] += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
import matplotlib.pyplot as plt | |
def linear_transform(img, i1, i2, k1: int, k2: int): | |
new_img = np.zeros(img.shape, dtype=np.uint8) | |
rows, cols = img.shape | |
for row in range(rows): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Função do laboratório 4 | |
def f1(x): | |
return 7*(x - 1) | |
def f2(x): | |
return 7 * 256 * (x - 1) | |
def f3(x): |