Python枕头图像反

  

本文主要是利用Python的第三方库枕头,实现单通道灰度图像的颜色翻转功能。

        # - * -编码:utf - 8 - *   进口操作系统   导入系统   从公益诉讼导入图像   从公益诉讼进口ImageOps   def img_gray_invert (img_path):   ”“”   反转输入图像。   ”“”   如果不是os.path.isfile (img_path):   打印”为输入文件路径错误。”   返回   形象=Image.open (img_path)   形象=image.convert (“L”)   inverted_image=ImageOps.invert(图片)   返回inverted_image   if __name__==癬_main__”:   argv=sys.argv   如果len (argv) !=3:   打印”“”的例子:   python gray_invert。py测试/htc。png测试/htc_inv.png   ”“”   其他:   img_file_path=argv [1]   invert_image=img_gray_invert (img_file_path)   img_file_out=argv [2]   invert_image.save (img_file_out)      

<强>总结

  

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接

Python枕头图像反