Python'da Görüntü İşleme: Resmi içten çember ile çevirme kodu

import math

#Distance - Mesafe bulma
def findDistance(x,y):
    return math.sqrt((x[0]-y[0])**2+(x[1]-y[1])**2)


d=findDistance([3,0],[0,4])

from scipy import ndimage
from scipy import misc
f=misc.face()
import matplotlib.pyplot as plt
plt.imshow(f)
plt.show()



f.ndim

f.shape

type(f)


#Renk değiştirme
f[:,:,2]=0
#Rakunu gösterme
plt.imshow(f)
plt.show()





f.shape

type(f.shape)

im_size=f.shape
im_size[0]

center=[im_size[0]/2,im_size[1]/2]

from scipy import ndimage
from scipy import misc
f=misc.face()

#Resmin sınırının içine çember çizip resim ile çember arasındaki RGB değerleri 0 yapma
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()



Kaynakça:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.misc.face.html#scipy.misc.face


Yorumlar

Bu blogdaki popüler yayınlar

Python'da Liste İçin Varyans, Standart Sapma, Ortalama, Minimum bulma, Maksimum bulma

Veritabanı Yönetim Sistemleri

Python'da Görüntü İşleme - Resmi Siyah Beyaz Yapma