首页 > 其他 > 详细

OpenCV像素值取反

时间:2020-02-25 15:56:46      阅读:105      评论:0      收藏:0      [点我收藏+]

转自:https://blog.csdn.net/water_Popcorn/article/details/101534108

 

方法一:

import  cv2  as cv
import numpy as np
# 像素取反
def get_img_info(img):
    height = img.shape[0]  #
    width = img.shape[1]     #
    channels = img.shape[2]  #通道数
    #将图像的每个像素点进行反选操作
    for row in range(height):
        for col in range(width):
            for c in range(channels):
                pv = img[row, col, c]
                img[row, col, c] = 255 - pv
    cv.imshow("reserve", img)
    cv.waitKey()
     cv.destroyAllWindows()

 

方法二:

# 像素取反
def get_img_reserve(img):
#直接调用反选函数
   dst = cv.bitwise_not(img)
   cv.imshow("reserve",dst)
   cv.waitKey()
   cv.destroyAllWindows()

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1

 

OpenCV像素值取反

原文:https://www.cnblogs.com/Manuel/p/12361948.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!