直接上代碼,根據需求注釋選擇相應修改?
from PIL import Image import os import os.path rootdir = r ' G:\jianfeng\project\rubblish_det\faster_rcnn\rubbish_voc_xml\rubbish_pic_forTest\4396 ' # 指明被遍歷的文件夾 for parent, dirnames, filenames in os.walk(rootdir): for filename in filenames: print ( ' parent is : ' + parent) print ( ' filename is : ' + filename) currentPath = os.path.join(parent, filename) print ( ' the fulll name of the file is : ' + currentPath) im = Image.open(currentPath) # 進行上下顛倒 out = im.transpose(Image.FLIP_TOP_BOTTOM) # 進行左右顛倒 out = out.transpose(Image.FLIP_LEFT_RIGHT) # 進行旋轉90 out = im.transpose(Image.ROTATE_90) # 進行旋轉180 out = im.transpose(Image.ROTATE_180) # 進行旋轉270 out = im.transpose(Image.ROTATE_270) # 將圖片重新設置尺寸 out= out.resize((1280,720 )) newname = r " G:\jianfeng\project\rubblish_det\faster_rcnn\rubbish_voc_xml\rubbish_pic_forTest\4396_720 " + ' \\ ' + " 10t " + filename out.save(newname)
?
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
