最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python Pillow Image Invert

 更新時間:2019年01月22日 09:44:55   作者:_John_Tian_  
今天小編就為大家分享一篇關(guān)于Python Pillow Image Invert,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧

本文主要是利用Python的第三方庫Pillow,實現(xiàn)單通道灰度圖像的顏色翻轉(zhuǎn)功能。

# -*- encoding:utf-8 -*-
import os
import sys
from PIL import Image
from PIL import ImageOps
def img_gray_invert(img_path):
  """
  invert input image.
  """
  if not os.path.isfile(img_path):
    print "Error for input file path."
    return
  image = Image.open(img_path)
  image = image.convert("L")
  inverted_image = ImageOps.invert(image)
  return inverted_image
if __name__ == '__main__':
  argv = sys.argv
  if len(argv) != 3:
    print """Example:
    python gray_invert.py test/htc.png test/htc_inv.png
    """
  else:
    img_file_path = argv[1]
    invert_image = img_gray_invert(img_file_path)
    img_file_out = argv[2]
    invert_image.save(img_file_out)

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接

相關(guān)文章

最新評論

宁津县| 常德市| 紫金县| 九江县| 江都市| 阜平县| 吉木萨尔县| 宣汉县| 贵溪市| 城固县| 孟州市| 奎屯市| 浏阳市| 敖汉旗| 台州市| 白银市| 樟树市| 昌吉市| 巴里| 遂溪县| 屯留县| 徐州市| 都匀市| 黄骅市| 上饶县| 宾阳县| 江津市| 耿马| 丰县| 乌拉特中旗| 靖西县| 舟山市| 临海市| 双城市| 新余市| 鹤岗市| 富川| 贡嘎县| 弥勒县| 班玛县| 百色市|