Python uses OpenCV to read an example of a picture

Source: Internet
Author: User
Here's a small piece to bring you an example of Python using OpenCV to read pictures. Small series feel very good, now share to everyone, also for everyone to make a reference. Let's take a look at it with a little knitting.

After installing the environment, start the first Hello Word example, how to read the picture, save the artwork

Import CV2 Import NumPy as NP import Matplotlib.pyplot as PLT  #读取图片代码 img = cv2.imread (' test.jpg ', Cv2. Imread_grayscale) #IMREAD_COLOR = 1 #IMREAD_UNCHANGED = 1 #展示图片 cv2.imshow (' Image ', img) cv2.waitkey (0) Cv2.destroyallwindows () #使用matplotlib分析图片 #plt. Imshow (img,cmap= ' Gray ', interpolation= ' bicubic ') #plt. Plot ([50,100] , [80,100], ' C ', linewidth=5) #plt. Show () #把图片保存为png格式的灰色文件. Cv2.imwrite (' Testgray.png ', IMG)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.