import numpy as np
pwd
# 'C:\\Users\\ezgi'
ls *.jpg
img_1=plt.imread("test10.jpeg")
img_1.ndim
img_1.shape
# (1536, 2730, 3)
plt.imshow(img_1)
plt.show()
img_2=img_1[1:768:2,1:1024:2] #resim kırpma işlemi
img_2.ndim, img_1.shape
plt.imshow(img_2)
plt.show()
img_3=np.zeros((img_2.shape[0:2]))
img_3.shape
# (384, 512)
img_4=np.zeros((img_2.shape[0:2]))
img_4.shape
# (384, 512)
threshold=80
for i in range(img_2.shape[0]): #384
for j in range(img_2.shape[1]): #512
n=img_2[i,j,0]/3+img_2[i,j,1]/3+img_2[i,j,2]/3 img_3[i,j]=n
if n>threshold:
img_4[i,j]=255 else: img_4[i,j]=0
plt.subplot(1,3,1),plt.imshow(img_2)
plt.subplot(1,3,2),plt.imshow(img_3,plt.cm.gray) plt.subplot(1,3,3),plt.imshow(img_4,plt.cm.binary)
plt.imshow(img_4,plt.cm.binary) plt.show()
# RGB Gray Level BW (Black White)
Hiç yorum yok:
Yorum Gönder