on
laravel
- Get link
- Other Apps
from PIL import Image
import numpy as np
f = r"files/home.png"
image = Image.open(f)
# image.show()
# print(image.size)
arr = np.array(image)
rows = arr.shape[0]
columns = arr.shape[1]
white_ = np.array([255,255,255,255])
for row in range(rows):
for column in range(columns):
check_ = np.array_equal(arr[row,column],white_)
if check_:
arr[row,column] = 0,0,0,0
img = Image.fromarray(arr)
img.show()
img.save('files/new.png')
Comments
Post a Comment
If you any doubt of any topic then you can comment me.