首页 > 代码库 > Python OpenCV —— Modifying
Python OpenCV —— Modifying
一些索引和修改图像像素点数据等的操作,可打印观察运行结果。
# -*- coding: utf-8 -*-"""Created on Wed Sep 28 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)# modyfying RED valuepp_item = img.itemset((10,10,2),100)# length width 3p_shape = img.shape# length*width*3p_size = img.size# data typep_dtype = img.dtype# Image ROI# 将一块区域复制到另一区域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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。