









Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Prepare-se para as provas
Estude fácil! Tem muito documento disponível na Docsity
Prepare-se para as provas com trabalhos de outros alunos como você, aqui na Docsity
Encontra documentos específicos para os exames da tua universidade
Prepare-se com as videoaulas e exercícios resolvidos criados a partir da grade da sua Universidade
Responda perguntas de provas passadas e avalie sua preparação.
Ganhe pontos para baixar
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Processamento de imagens em python
Tipologia: Esquemas
1 / 15
Esta página não é visível na pré-visualização
Não perca as partes importantes!










1 # testando os pacotes 2 3 import numpy 4 x = numpy. arange (1 ,10) 5 print ( x ) 6 7 import numpy as np 8 x = np. arange (1 ,11) 9 print ( x ) 10 11 from numpy import arange 12 x = arange (1 ,9) 13 print ( x ) 14 15 from matplotlib import pyplot as plt 16 plt. plot ( x ) 17 plt. show () 18
19 from scipy import signal 20 janela = signal. hann (51) 21 plt. plot ( janela ) 22 plt. show ()
1 from PIL import Image 2 3 img = Image. open ( ' images / profile. jpg ') 4 5 # Resize 6 smaller_img = img. resize ((150 ,150) ) 7 smaller_img. show () 8 9 # Crop 10 box = (100 ,100 ,400 ,400) 11 region = img. crop ( box ) 12 region. show () 13 14 # Rotation 15 rotated_img = img. rotate (45) 16 rotated_img. show ()
(a) (b)
(c)
1 import numpy as np 2 import matplotlib. pyplot as plt 3 4 A = plt. imread ( ' images / profile. jpg ') 5 # print ( A ) 6 print ( np. shape ( A ) ) 7 print ( type ( A ) ) 8 print ( A. dtype ) 9 plt. imshow ( A ) 10 plt. show ()
(a)
(b)
1 from PIL import Image 2 from pylab import * 3 4 im = array ( Image. open ( ' images / profile. jpg ') ) 5 imshow ( im ) 6 7 x = [100 ,150 ,300 ,400 , 600] 8 y = [50 ,500 ,200 ,500 , 700] 9 10 plot (x ,y , ' r * ') 11
1 from PIL import Image 2 # import numpy as np 3 from pylab import * 4 import matplotlib. pyplot as plt 5 from matplotlib import cm 6 7 im = array ( Image. open ( ' images / profile. jpg '). convert ( 'L ') ) 8 thres = np. zeros ( shape ( im ) ). astype ( ' uint8 ') 9 threshold = 150 10 thres [ im < threshold ] = 0 11 thres [ im >= threshold ] = 255 12 13 plt. imshow ( thres , cmap = cm. gray ) 14 plt. show ()
1 x = " Ola , mundo !" 2 print ( x ) 3 4 a = 10 5 b = 11 6 7 if b == ( a +1) : 8 # identacao 9 print (" Condicao verdadeira !")
1 num_int = 10 2 print ( num_int ) 3 4 num_float = 9. 5 print ( num_float ) 6 7 num_float2 = float (8) 8 print ( num_float2 )
1 lista = [] 2 lista. append (8) 3 lista. append (9) 4 lista. append (10) 5 print ( lista [0]) 6 print ( lista ) 7 8 for x in lista : 9 print ( x )
1 num = 1+ 2 3 num = num *
21 if country in countries : 22 print (" Country found !")
1 # Example 1 : Print 1... 2 print (" Example 1 result :") 3 4 numbers = [0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8] 5 6 for num in numbers : 7 print ( num ) 8 9 # Example 2 : Prints the numbers 0 ,1 ,2 ,3 , 10 print (" Example 2 result :") 11 12 for x in range (5) : 13 print ( x ) 14 15 # Example 3 : Prints the numbers 3 ,4 , 16 print (" Example 3 result :") 17 18 for x in range (3 ,6) : 19 print ( x ) 20 21 # Example 4 : Prints the numbers 3 ,5 , 22 print (" Example 4 result :") 23 24 for x in range (3 ,8 ,2) : 25 print ( x ) 26 27 # Example 5 : Prints the numbers 0... 28 print (" Example 5 result :") 29 30 num = 31 while num <5: 32 print ( num ) 33 num += 34 35 # Example 6 : 36 print (" Example 6 result :") 37 count = 38 while True : 39 print ( count ) 40 count += 41 if count >=10: 42 break 43
44 # Example 7 : Skip even numbers 45 print (" Example 7 result :") 46 47 for x in range (10) : 48 if x %2==0: 49 continue 50 print ( x )
1 # Example 1 : Simple function 2 3 def simple_function () : 4 print (" This is a simple function ") 5 6 7 # Example 2 : Function with arguments 8 9 def country_info ( country , capital ) : 10 print (" The capital of % s is % s "%( country , capital ) ) 11 12 13 # Example 3 : Function with a rrturn value 14 15 def add_this (a , b ) : 16 return a + b
1 # Example 1: Creating a dictionary 2 print (" Example 1: ") 3 4 ages = {} 5 ages [" Tom "] = 6 ages [" Dick "] = 30 7 ages [" Harry "] = 19 8 9 print ( ages ) 10 11 # Example 1: Different way of Initialization 12 print (" Example 2: ") 13 14 postcodes ={ 15 " Sheperd ' s Bush " : 8992 , 16 " Earls Court " : 4112 , 17 " Barbican " : 9087 18 }