Skip to content

Instantly share code, notes, and snippets.

View guissalustiano's full-sized avatar
🧙‍♂️
wizard trainee

Guilherme Salustiano guissalustiano

🧙‍♂️
wizard trainee
View GitHub Profile
@guissalustiano
guissalustiano / moodle_redicect_replace.py
Created September 11, 2021 02:58
Replace moodle redirects
import requests
import re
from functools import cache
MOODLE_SESSION = ''
FILENAME = 'readme.md'
@cache
def file_content():
@guissalustiano
guissalustiano / exp2.jl
Last active June 30, 2021 15:43
Calculo do experimento 2 do laboratorio de PME3033
######################################################
# Por: Guilherme S Salustiano #
# Eng da Computação 2020 #
######################################################
using Measurements
temperatura_da_agua_graus = 30 ± 0.5
distancia_tubos_pilot_centros = 5.4e-3
distancia_tubos_pilot_parede_centro = distancia_tubos_pilot_centros/2
import cv2 as cv
import matplotlib.pyplot as plt
import numpy as np
img = cv.imread('passarinho.jpg',0)
sobel = cv.Sobel(img, -1, 1, 1)
fig, ax = plt.subplots(ncols=2,figsize=(15,5))
ax[0].imshow(img, cmap = 'gray')
ax[0].set_title('Original')
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
def rgbToGray(img):
# Baseado em https://pillow.readthedocs.io/en/3.2.x/reference/Image.html#PIL.Image.Image.convert
return np.matmul(img, [0.2989, 0.5870, 0.1140]).astype(np.uint())
def convolution(img: np.ndarray, filt: np.ndarray):
iw, ih = img.shape
def gaussian_kernel(size, sigma=1):
center = size//2
x, y = np.mgrid[-center:center+1, -center:center+1]
return np.exp(-((x**2 + y**2) / (2*sigma**2)))
def convolution(img: np.ndarray, filt: np.ndarray):
iw, ih = img.shape
kw, kh = filt.shape
assert(kw % 2 == 1 and kh % 2 == 1) # Garante que o filtro tenha um centro
kcx, kcy = kw//2, kh//2 # Calcula a posição central
out = np.zeros(img.shape)
for x, y in np.ndindex(*out.shape):
#Pega os pixels que serão usados na operação com o filtro
sub_img = img[max(0, x-kcx): min(iw, x-kcx + (kw)),
max(0, y-kcy): min(ih, y-kcy + (kh))]