Örnekler
import math
def findDistance(x,y):
return math.sqrt((x[0]-y[0])**2+(x[1]-y[1])**2)
def findDistance(x,y):
return math.sqrt((x[0]-y[0])**2+(x[1]-y[1])**2)
d=findDistance([3,0],[0,4])
d
_____________________
d
_____________________
5.0
______________________
from scipy import ndimage
from scipy import misc
f=misc.face()
import matplotlib.pyplot as plt
plt.imshow(f)
plt.show()
from scipy import misc
f=misc.face()
import matplotlib.pyplot as plt
plt.imshow(f)
plt.show()
f.ndim
_______________________
_______________________
3
______________________
f.shape
_____________________
_____________________
(768, 1024, 3)
________________
type(f)
____________________
____________________
numpy.ndarray
f[:,:,2]=0
plt.imshow(f)
plt.show()
plt.imshow(f)
plt.show()
f.shape
________________________
________________________
(768, 1024, 3)
___________________
type(f.shape)
________________________
________________________
tuple
___________________
im_size=f.shape
im_size[0]
im_size[0]
________________________
768
__________________
center=[im_size[0]/2,im_size[1]/2]
center
_______________________
center
_______________________
[384.0, 512.0]
__________________
from scipy import ndimage
from scipy import misc
f=misc.face()
for i in range(im_size[0]):
for j in range(im_size[1]):
if findDistance([i,j],center)>384:
f[i,j,:]=0
from scipy import misc
f=misc.face()
for i in range(im_size[0]):
for j in range(im_size[1]):
if findDistance([i,j],center)>384:
f[i,j,:]=0
plt.imshow(f)
plt.show()
plt.show()
Yorumlar
Yorum Gönder