Skip to content

Instantly share code, notes, and snippets.

View Klusmo's full-sized avatar
🏠
Working from home

Augusto Figueiredo Klusmo

🏠
Working from home
  • Itabira, MG
View GitHub Profile
@Klusmo
Klusmo / morphologic_filter.py
Created December 13, 2022 23:01
Filtros morfologicos para imagens
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)
@Klusmo
Klusmo / 2d_convolve.py
Created December 13, 2022 18:00
Script para convolução de imagens.
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
@Klusmo
Klusmo / hist_equalization.py
Created December 10, 2022 17:50
Metodo de equalização de imagens com o uso de histogramas.
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
@Klusmo
Klusmo / lt_image.py
Created December 10, 2022 17:32
O Codigo apresenta uma função de transformação linear para imagens, e 3 operações que utilizam dessa tranformação.
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):
@Klusmo
Klusmo / delay.py
Created May 31, 2022 01:56
Calcula os valores de VAR1, VAR2 e VAR3 para delay, baseado no numero de instruções executadas por um codigo assembly
# Função do laboratório 4
def f1(x):
return 7*(x - 1)
def f2(x):
return 7 * 256 * (x - 1)
def f3(x):