Examples of image reading, cutting and cropping functions implemented in Python using matplotlib

不言
Release: 2018-04-28 09:49:36
Original
4426 people have browsed it

This article mainly introduces the image reading, cutting and cropping functions implemented by Python using matplotlib. It analyzes the loading, reading, coordinate control and cropping related operation skills of Python based on matplotlib in the form of examples. Friends who need it can Refer to the following

The example of this article describes the image reading, cutting and cropping functions implemented by Python using matplotlib. Share it with everyone for your reference, the details are as follows:

# -*- coding:utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import matplotlib.pylab as plt
# 加载图像
im = plt.imread("C:/4.png")
print(im.shape)
# (y轴像素点数, x轴像素点数,图像通道数)
def plti(im, **kwargs):
  """
  画图的辅助函数
  """
  plt.imshow(im, interpolation="none", **kwargs)
  plt.axis('off') # 去掉坐标轴
  plt.show() # 弹窗显示图像
im = im[50:380,:250,:] # 直接切片对图像进行裁剪
plti(im)
Copy after login

Image before processing:

Run The final effect:

Related recommendations:

Python uses the email module to encode and decode emails

How to use Beanstalkd for asynchronous task processing in Python

Detailed steps for using unittest test interface in python

The above is the detailed content of Examples of image reading, cutting and cropping functions implemented in Python using matplotlib. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!