#灰度图片的颜色反转
#0-255 ,255-当前灰度值
import cv2
import numpy as np
img = cv2.imread('ruonan.jpg',1)
Info = img.shape
height = Info[0]
width = Info[1]
dst = np.zeros((height,width,1),np.uint8)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
for i in range(0,height):
for j in range(0,width):
grayPixel = gray[i,j]
dst[i,j] = 255-grayPixel
cv2.imshow('dstImg',dst)
#彩色图片的颜色反转
#0-255 ,255-当前灰度值
import cv2
import numpy as np
img = cv2.imread('ruonan.jpg',1)
Info = img.shape
height = Info[0]
width = Info[1]
dst = np.zeros((height,width,3),np.uint8)
#gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
for i in range(0,height):
for j in range(0,width):
(b,g,r) = img[i,j]
dst[i,j] = (255-b,255-g,255-r)
cv2.imshow('dstImg',dst)
cv2.waitKey(0)
21_颜色反转
原创wx5c808bf9b561a ©著作权
©著作权归作者所有:来自51CTO博客作者wx5c808bf9b561a的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Python获取颜色RGB值
Python获取颜色RGB值
Python 图像处理 屏幕截图 -
有趣的css - 颜色滑动切换按钮
当鼠标悬浮在按钮上方时,按钮背景色从左往右滑动变化一个变化切换按钮。
css动画 动效设计 交互设计 用户体验 按钮 -
python笔记21_函数作用域
主要内容:命名空间,作用域,LEGB;
python 作用域 命名空间 global LEGB -
Java学习篇21_异常、线程
上一篇博客:目录异常异常介绍异常的处理自定义异常多线程并发与并
多线程 java 编程语言 抛出异常 System -
检索数据_21_处理空值的排序
处理空值的排序需求描述需求:查询雇员表emp里的员工编号、员工名、奖金
sql oracle mysql 数据库 SQL -
Canvas 颜色反转
Canvas 颜色翻转
Canvas教程 Canvas