Python 计算机视觉
from PIL import Image # Image是PIL中比较重要的一个 模块
im=Image.open(‘F:\Desktop\今日须看\代码\Python-master\back_image.bmp’)
imshow(im)
from PIL import Image # Image是PIL中比较重要的一个 模块
im=Image.open(‘F:\Desktop\今日须看\代码\Python-master\back_image.bmp’)
imshow(im)
box = (100,100,400,400)
region = pil_im.crop(box) # 复制大小
out = pil_im.resize((128,128)) # 调整尺寸
out = pil_im.rotate(360) # 旋转
imshow(out)
x = [100,100,400,400]
y = [200,500,200,500]
title(‘hello world’)
plot(x,y)
axis(‘off’) # 是否打开坐标轴
axis(‘on’)
2.numpy相关知识
im = array(Image.open(‘F:\Desktop\今日须看\代码\Python-master\back_image.bmp’))
print(im.shape, im.dtype)# 查看像素大小和内存大小
imshow(im)
from PIL import Image
from numpy import *
im = array(Image.open(‘F:\Desktop\今日须看\代码\Python-master\back_image.bmp’).convert(‘L’))
im2 = 255 - im # 对图像进行反相处理
imshow(im)
figure()
imshow(im2)
figure()
im3 = (100.0/255) * im + 100# 将图像像素值变换到100…200 区间
imshow(im3)
figure()
im4 = 255.0 * (im/255.0)**2 # 对图像像素值求平方后得到的图像
imshow(im4)