Python opencv--modifying

Source: Internet
Author: User

Some indexes and modify the image pixel point data and other operations, can print the observation of the running results.

#-*-Coding:utf-8-*-"" "Created on Wed Sep-00:11:07 2016@author:administrator" "" Import cv2import NumPy as np# length , 588;width,468img = Cv2.imread (' cute.jpg ') px = Img[100,100]print (px) # Accessing only blue pixel# remember b,g,rblue = img[ 100,100,0]print (blue) # Modify the pixelimg[100,100] = [255,255,255]# accesing RED valuep_item = Img.item (10,10,2) # Modyfy ing RED valuepp_item = img.itemset ((10,10,2), (+) # length width 3p_shape = img.shape# length*width*3p_size = img.size# dat A typep_dtype = img.dtype# Image roi# copy one area to another area ball = img[280:340,330:390]img[273:333,100:160] = ballcv2.imshow (' Image ', img) k = cv2.waitkey (0) If k = = 27:cv2.destroyallwindows () # Splitting and merging Image channelsb,g,r = Cv2.split (img  # costlyimg = Cv2.merge ((b,g,r)) b = img[:,:,0] # blue# make all the  red pixels to zeroimg[:,:,0] = 0

  

Python opencv--modifying

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.