色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術文章
文章詳情頁

python PIL模塊的基本使用

瀏覽:38日期:2022-07-09 14:29:12

PIL基本功能介紹

from PIL import Imagefrom PIL import ImageEnhance img = Image.open(r’E:imgf1.png’)img.show()#圖像二值化img = img.convert(’L’)# 圖像放大img = img.resize((img.width * int(3), img.height * int(4)), Image.ANTIALIAS)# # 對比度增強enh_con = ImageEnhance.Contrast(img)contrast = 2img_contrasted = enh_con.enhance(contrast)# 亮度增強enh_bri = ImageEnhance.Brightness(img_contrasted)brightness = 2.5image_brightened = enh_bri.enhance(brightness)#色度增強enh_col = ImageEnhance.Color(img)color = 50image_colored = enh_col.enhance(color)# # 銳度增強enh_sha = ImageEnhance.Sharpness(img)sharpness = 2image_sharped = enh_sha.enhance(sharpness)image_sharped.save(r’E:imgf22.png’, dpi=(300, 300), quality=95)# image_sharped.save(r’E:imgf22.png’) # 圖片漢字識別img2 = Image.open(r’E:imgf22.png’)code2 = pytesseract.image_to_string(img2, lang=’chi_sim’)# print(code2)# 圖片裁剪image_cro = Image.open(r’E:imgf24.png’)image_cropped = image_cro.crop(res)image_cropped.save(u’E:imgf25.png’) 

對圖片進行黑白化處理

img_main = Image.open(u’E:/login1.png’)img_main = img_main.convert(’L’)threshold1 = 138table1 = []for i in range(256): if i < threshold1: table1.append(0) else: table1.append(1)img_main = img_main.point(table1, '1')img_main.save(u’E:/login3.png’)

計算小圖在大圖的坐標

def get_screenxy_from_bmp(main_bmp, son_bmp): # 獲取屏幕上匹配指定截圖的坐標->(x,y,width,height) img_main = Image.open(main_bmp) img_main = img_main.convert(’L’) threshold1 = 138 table1 = [] for i in range(256): if i < threshold1: table1.append(0) else: table1.append(1) img_main = img_main.point(table1, '1') img_son = Image.open(son_bmp) img_son = img_son.convert(’L’) threshold2 = 138 table2 = [] for i in range(256): if i < threshold2: table2.append(0) else: table2.append(1) img_son = img_son.point(table2, '1') datas_a = list(img_main.getdata()) datas_b = list(img_son.getdata()) for i, item in enumerate(datas_a): if datas_b[0] == item and datas_a[i + 1] == datas_b[1]: yx = divmod(i, img_main.size[0]) main_start_pos = yx[1] + yx[0] * img_main.size[0] match_test = True for n in range(img_son.size[1]):main_pos = main_start_pos + n * img_main.size[0]son_pos = n * img_son.size[0] if datas_b[son_pos:son_pos + img_son.size[0]] != datas_a[main_pos:main_pos + img_son.size[0]]: match_test = False break if match_test:return (yx[1], yx[0], img_son.size[0], img_son.size[1]) return False

ImageGrab實現屏幕截圖

im = ImageGrab.grab()im.save(’D:/as1.png’) # # # # 參數說明# # # # 第一個參數 開始截圖的x坐標# # # # 第二個參數 開始截圖的y坐標# # # # 第三個參數 結束截圖的x坐標# # # # 第四個參數 結束截圖的y坐標bbox = (897, 131, 930, 148)im = ImageGrab.grab(bbox)im.save(’D:/as2.png’)

以上就是python PIL模塊的基本使用的詳細內容,更多關于python PIL模塊的資料請關注好吧啦網其它相關文章!

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 亚洲国产成人麻豆精品 | 国产在线精品成人一区二区三区 | 成人在线91| 欧美在线一级毛片观看 | 国产精品久久久久国产精品三级 | 亚洲国产高清在线 | 国产福利不卡一区二区三区 | 久章草视频 | 欧美精品三级在线 | 亚洲三级网 | 毛片激情永久免费 | 亚洲一级黄色毛片 | 日本三级网站在线线观看 | 狠狠五月深爱婷婷网 | 国产日韩精品欧美一区喷 | 亚洲网站视频在线观看 | 亚洲偷自拍另类图片二区 | 欧美性猛交xxxxxxxx软件 | 日本三级2021最新理论在线观看 | 免费人成黄页网站在线观看 | 91香蕉国产 | 中文字幕亚洲精品日韩精品 | 久久艹在线 | 国产精品欧美亚洲韩国日本不卡 | 成年人网站免费视频 | 撸久久| 欧美精品区 | 最新中文字幕视频 | 久久亚洲精品中文字幕第一区 | 欧美黄色免费网站 | 精品在线播放视频 | 日本韩国一级片 | 欧美精品aaa久久久影院 | 亚洲国产精品久久综合 | 中文久久 | 亚洲美女综合 | 免费一级美国片在线观看 | 三级精品| 美女动作一级毛片 | 欧美日韩国产在线人成dvd | 在线中文|