zoukankan      html  css  js  c++  java
  • python图片处理(二)

    未经允许,请勿转载!!!!

    这次打算先写处理图片的方法,然后再调用方法来运行

    下面先写的是处理图片的方法:

    # -*- coding: utf-8 -*-
    
    import os
    import matplotlib.pyplot as plt
    import pytesseract
    from PIL import Image
    
    def picture_operation_copy(path_filename):
        image = Image.open(path_filename)
        image.save(path_filename)
    
    def picture_operation_delete(path_filename):
        image = Image.open(path_filename)
        os.remove(path_filename)
    
    def picture_operation_save(path_filename, save_path_filename):
        image = Image.open(path_filename)
        image.save(save_path_filename)
    
    def picture_operation_show(path_filename):
        image = Image.open(path_filename)
        image.show()
    
    def picture_operation_close(path_filename):
        plt.close()
    
    #调整图像大小:
    def picture_operation_changeSize(path_filename):
        image = Image.open(path_filename)
        new_image = image.resize((128, 128), Image.BILINEAR)
        new_image.show()
    
    #旋转图像:
    def picture_operation_rotate(path_filename):
        image = Image.open(path_filename)
        rotate_image = image.rotate(45)
        rotate_image.show()

    然后再来调用上面的方法:

    # -*- coding: utf-8 -*-
    
    from method.picture import *
    import time
    
    picture_operation_copy('C:\Users\chenjia\Desktop\Untitled.jpg')
    
    picture_operation_save('C:\Users\chenjia\Desktop\Untitled.jpg', 'C:\Users\chenjia\Desktop\11111111111111111.jpg')
    
    picture_operation_show('C:\Users\chenjia\Desktop\11111111111111111.jpg')
    time.sleep(3)
    #picture_operation_close('C:\Users\chenjia\Desktop\11111111111111111.jpg')
    #picture_operation_delete('C:\Users\chenjia\Desktop\11111111111111111.jpg')
    picture_operation_rotate('C:\Users\chenjia\Desktop\11111111111111111.jpg')
    time.sleep(3)
    picture_operation_changeSize('C:\Users\chenjia\Desktop\11111111111111111.jpg')
    print "well done!!!!!!!!!!"

    下面是这两个文件在我的框架里面的位置

  • 相关阅读:
    Java异常处理
    冒泡排序法
    21个项目-MNIST机器学习入门
    Hadoop集群搭建中ssh免密登录
    利用奇异值分解简化数据
    数据集中空值替换成对应特征的平均值
    PCA降维处理
    使用FP-growth算法高效发现频繁项集
    原生js---ajax---post方法传数据
    原生js---ajax---get方法传数据
  • 原文地址:https://www.cnblogs.com/111testing/p/6503508.html
Copyright © 2011-2022 走看看