訂閱
糾錯
加入自媒體

如何利用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)。



<上一頁  1  2  3  
聲明: 本文由入駐維科號的作者撰寫,觀點僅代表作者本人,不代表OFweek立場。如有侵權(quán)或其他問題,請聯(lián)系舉報。

發(fā)表評論

0條評論,0人參與

請輸入評論內(nèi)容...

請輸入評論/評論長度6~500個字

您提交的評論過于頻繁,請輸入驗證碼繼續(xù)

暫無評論

暫無評論

人工智能 獵頭職位 更多
掃碼關(guān)注公眾號
OFweek人工智能網(wǎng)
獲取更多精彩內(nèi)容
文章糾錯
x
*文字標(biāo)題:
*糾錯內(nèi)容:
聯(lián)系郵箱:
*驗 證 碼:

粵公網(wǎng)安備 44030502002758號