Python-使用Matplotlib处理PNG图片
Matplotlib是Python中令人惊叹的可视化库,用于数组的二维图。Matplotlib是一个基于NumPy数组的多平台数据可视化库,旨在与更广泛的SciPy堆栈配合使用。
示例
#applying pseudocolor
# importing pyplot and image from matplotlib
import matplotlib.pyplot as plt
import matplotlib.image as img
# reading png image
im = img.imread('imR.png')
# applying pseudocolor
# default value of colormap is used.
lum = im[:, :, 0]
# show image
plt.imshow(lum)
#colorbar
# importing pyplot and image from matplotlib
import matplotlib.pyplot as plt
import matplotlib.image as img
# reading png image
im = img.imread('imR.png')
lum = im[:, :, 0]
# setting colormap as hot
plt.imshow(lum, cmap ='hot')
plt.colorbar()
#interpolation
# importing PIL and matplotlib
from PIL import Image
import matplotlib.pyplot as plt
# reading png image file
img = Image.open('imR.png')
# resizing the image
img.thumbnail((50, 50), Image.ANTIALIAS)
imgplot = plt.imshow(img)
#bicubic value for interpolation
# importing pyplot from matplotlib
import matplotlib.pyplot as plt
# importing image from PIL
from PIL import Image
# reading image
img = Image.open('imR.png')
img.thumbnail((30, 30), Image.ANTIALIAS)
# bicubic used for interpolation
imgplot = plt.imshow(img, interpolation ='bicubic')#sinc value for interpolation
# sinc value for interpolation
# importing PIL and matplotlib
from PIL import Image
import matplotlib.pyplot as plt
# reading image
img = Image.open('imR.png')
img.thumbnail((30, 30), Image.ANTIALIAS)
# sinc used for interpolation
imgplot = plt.imshow(img, interpolation ='sinc')热门推荐
1 祝福语简短七夕
10 贺卡文字同事祝福语简短
11 妈妈生日祝福语简短温暖
12 送给同桌的祝福语简短
13 生日祝福语简短独特格式
14 恋爱祝福语大全简短搞笑
15 对别人新年祝福语简短
16 给男生的简短祝福语
17 简短有力的结婚祝福语
18 酒店客人祝福语简短