python通過pil將圖片轉換成黑白效果

pycct 9年前發布 | 2K 次閱讀 Python

pil功能強大,convert方法可以輕易的將圖片轉換,下面的代碼可以將圖片轉換成黑白效果

from PIL import Image
image_file = Image.open("convert_image.png") # open colour image
image_file = image_file.convert('1') # convert image to black and white
image_file.save('result.png')

 本文由用戶 pycct 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!