PIL n PIL Image Image Draw Image Enhance
- Slides: 19
PIL n PIL提供了丰富的功能模块: Image, Image. Draw, Image. Enhance, Image. Fil er等等。最常用到的模块是 Image, Image. Draw, Image. Enhance这三个模 块。
Image模块 n n n (2)调整图像大小: import Image img = Image. open("img. jpg") new_img = img. resize((128, 128), Image. BILINEAR) new_img. save("new_img. jpg") Image. BILINEAR指定采用双线性法对像素 点插值。
Image模块 n n n n (3)旋转图像: 现在我们把刚才调整过大小的图像旋转 45度: import Image img = Image. open("img. jpg") new_img = img. resize((128, 128), Image. BILINEAR) rot_img = new_img. rotate(45) rot_img. save("rot_img. jpg")
Image模块 n n n n (5)直方图统计: Image类实例的histogram()方法能够对直方图数据 进行统计,并将结果做为一个列表(list)返回。比 如,我们对上面的旋转后生成的 图像进行直方图 统计: import Image img = Image. open("img. jpg") new_img = img. resize((128, 128), Image. BILINEAR) rot_img = new_img. rotate(45) print rot_img. histogram()
Image. Draw模块 n n n n (1)绘制直线: import Image, Image. Draw img = Image. open("img. jpg") draw = Image. Draw(img) width, height = img. size draw. line(((0, 0), (width-1, height-1)), fill=255) draw. line(((0, height-1), (width-1, 0)), fill=255) img. save("cross_line. jpg")
Image. Draw模块 n n n n (2)绘制圆: import Image, Image. Draw img = Image. open("img. jpg") width, height = img. size draw = Image. Draw(img) draw. arc((0, 0, width-1, height 1), 0, 360, fill=255) img. save("circle. jpg")
Image. Enhance模块 n (1)亮度增强: import Image, Image. Enhance n img = Image. open("img. jpg") n brightness = Image. Enhance. Brightness(img) n bright_img = brightness. enhance(2. 0) n bright_img. save("bright. jpg") n
Image. Enhance模块 说明: n brightness = Image. Enhance. Brightness(img) 这一行 把img传给Brightness类,得到一个 Brightness类实例; n bright_img = brightness. enhance(2. 0) 这一行调用brightness实例的enhance 方法,传入的参数指定将亮度增强 2倍; n
Image. Enhance模块 n n n (2)图像尖锐化: import Image, Image. Enhance img = Image. open("img. jpg") sharpness = Image. Enhance. Sharpness(img) sharp_img = sharpness. enhance(7. 0) sharp_img. save("bright. jpg")
Image. Enhance模块 n n n (3)对比度增强: import Image, Image. Enhance img = Image. open("img. jpg") contrast = Image. Enhance. Contrast(img) contrast_img = contrast. enhance(2. 0) contrast_img. save("contrast. jpg")
原型开发 n n n img=Image. open('T 1. ppm') img 1=img. convert('L') out_image = Image. new(img 1. mode, img 1. size, None) ##新建图片 img 1=img 1. filter(Image. Filter. Median. Filter) imgdata = img 1. load() ##取img每个点的数据, 返回值为列表 imgdata[x, y] outdata = out_image. load() ##取out_image每 个点的数据,返回值为列表。对此列表赋值,即 为对图像out_image 操作。
- Enhance an image
- Enhance an image
- Grammar to enrich and enhance writing
- A particular or unique version of a style is a
- A new backbone that can enhance learning capability of cnn
- Cosmetics are substances that are used to enhance……..
- Nus grading system
- Enhance life
- Salad that stimulates the appetite
- Nnn hypno
- Draw unto me and i will
- How to draw use case diagram in draw.io
- Pil user testing
- Publisko iepirkumu likums
- Penyajian informasi lingkungan
- Hrt gp notebook
- Nernst denklemi kimya
- Pil a confronto
- Jika anda diberi 3 buah pil oleh dokter
- Jika anda diberi 3 buah pil oleh dokter