Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import matplotlib.image as pli
- from skimage.filters import threshold_otsu as otsu
- from PIL import Image
- cnh_cinza = Image.open("cnh.jpg").convert('L')
- cnh_cinza.save('cnhcinza.jpg')
- img = pli.imread('cnhcinza.jpg')
- imagem = Image.open('cnhcinza.jpg')
- limiar = otsu(img)
- mask = img < limiar
- msk = Image.fromarray(mask,'L')
- caixa = msk.getbbox()
- corte = imagem.crop(caixa)
- _,ax = plt.subplots (1,3)
- ax[0].imshow (img,cmap='gray')
- ax[1].imshow (mask,cmap='gray')
- ax[2].imshow (corte,cmap='gray')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement