如何利用Python 圖像庫完成各種圖像處理任務(wù)?
我們將使用這個圖像文件,命名為:people.jpg。
img2 = Image.open('people.jpg')
plt.imshow(img2)
圖像被讀取。現(xiàn)在,我們調(diào)整圖像大小。img2.thumbnail((50, 50), Image.ANTIALIAS) # resizes image in-place
imgplot = plt.imshow(img2)
imgplot1 = plt.imshow(img2, interpolation="nearest")
imgplot2 = plt.imshow(img2, interpolation="bicubic")
但是,為什么我們在圖像處理中故意模糊圖像?通常對于模式識別和計算機(jī)視覺算法,如果圖像非常清晰,處理起來就會很困難。因此進(jìn)行模糊處理以使圖像平滑。模糊還可以使圖像中的顏色過渡從一側(cè)到另一側(cè)更加平滑,F(xiàn)在,讓我們驗證我們之前處理過的汽車圖像的尺寸。#some more interesting stuff
file='image1.jpg'
with Image.open(file) as image:
width, height = image.size
#Image width, height is be obtained
這些也是我們之前得到的維度。所以我們可以得出結(jié)論,圖像是320*658。讓我們也嘗試旋轉(zhuǎn)和轉(zhuǎn)置圖像。#Relative Path
img3 = Image.open("image1.jpg")
#Angle given
img_rot= img3.rotate(180)
#Saved in the same relative location
img_rot.save("rotated_picture.jpg")
這是旋轉(zhuǎn)后的圖像。#transposing image
transposed_img = img3.transpose(Image.FLIP_LEFT_RIGHT)
#Saved in the same relative location
transposed_img.save("transposed_img.jpg")
這是轉(zhuǎn)置后的圖像。尾注圖像處理有各種重要的應(yīng)用,隨著時間的推移,方法和過程也會得到改進(jìn)。
請輸入評論內(nèi)容...
請輸入評論/評論長度6~500個字
最新活動更多
推薦專題
- 1 Intel宣布40年來最重大轉(zhuǎn)型:年底前裁員15000人、拋掉2/3房產(chǎn)
- 2 因美封殺TikTok,字節(jié)股價骨折!估值僅Meta1/5
- 3 宏山激光重磅發(fā)布行業(yè)解決方案,助力智能制造產(chǎn)業(yè)新飛躍
- 4 國產(chǎn)AI芯片公司破產(chǎn)!白菜價拍賣
- 5 具身智能火了,但規(guī)模落地還需時間
- 6 三次錯失風(fēng)口!OpenAI前員工殺回AI編程賽道,老東家捧金相助
- 7 國產(chǎn)英偉達(dá)們,抓緊沖刺A股
- 8 英特爾賦能智慧醫(yī)療,共創(chuàng)數(shù)字化未來
- 9 英偉達(dá)的麻煩在后頭?
- 10 將“網(wǎng)紅”變成“商品”,AI“爆改”實力拉滿
- 高級軟件工程師 廣東省/深圳市
- 自動化高級工程師 廣東省/深圳市
- 光器件研發(fā)工程師 福建省/福州市
- 銷售總監(jiān)(光器件) 北京市/海淀區(qū)
- 激光器高級銷售經(jīng)理 上海市/虹口區(qū)
- 光器件物理工程師 北京市/海淀區(qū)
- 激光研發(fā)工程師 北京市/昌平區(qū)
- 技術(shù)專家 廣東省/江門市
- 封裝工程師 北京市/海淀區(qū)
- 結(jié)構(gòu)工程師 廣東省/深圳市