您的位置:首页 > 文旅 > 旅游 > 网站推广模板_武汉seo网站优化运营_微信推广文案_泰州百度seo

网站推广模板_武汉seo网站优化运营_微信推广文案_泰州百度seo

2024/12/28 14:10:48 来源:https://blog.csdn.net/weixin_42917352/article/details/118685894  浏览:    关键词:网站推广模板_武汉seo网站优化运营_微信推广文案_泰州百度seo
网站推广模板_武汉seo网站优化运营_微信推广文案_泰州百度seo
  • 加法减法操作
import cv2 as cv
import numpy as npx = np.uint8([250])
y = np.uint8([10])x_1 = np.uint8([10])
y_1 = np.uint8([20])# 加法,相加最大只能为255
print(cv.add(x,y))# 减法,相互减最小值只能为0
print(cv.subtract(x_1,y_1))
  • 图像加法
    在这里插入图片描述
import cv2 as cv
import numpy as npimg1 = cv.imread("./images/1.jpg")img2 = cv.imread("./images/1_test.jpg")img = cv.add(img1,img2)cv.imshow("pic",img)
cv.waitKey(0)

在这里插入图片描述

  • 图像权重相加,因为我使用的都是同一张图片
import cv2 as cv
import numpy as npimg1 = cv.imread("./images/1.jpg")img2 = cv.imread("./images/1_test.jpg")# img = cv.add(img1,img2)
img = cv.addWeighted(img1,0.5,img2,0.8,gamma=0)
cv.imshow("pic",img)
cv.waitKey(0)

在这里插入图片描述

  • 按位与操作
import cv2 as cv
import numpy as npimg1 = cv.imread("./images/1.jpg")img2 = cv.imread("./images/1_test.jpg")# img = cv.add(img1,img2)
# img = cv.addWeighted(img1,0.5,img2,0.8,gamma=0)
rows,cols,channels = img2.shape
roi = img1[0:rows,0:cols]
img2gray = cv.cvtColor(img2,cv.COLOR_BGR2GRAY)
ret,mask = cv.threshold(img2gray,10,255,cv.THRESH_BINARY|cv.THRESH_OTSU)
mask_inv = cv.bitwise_not(mask)img1_bg = cv.bitwise_and(roi,roi,mask=mask_inv)
cv.imshow("img1_bg",img1_bg)
cv.waitKey(0)

在这里插入图片描述

  • 按位取反操作
import cv2 as cv
import numpy as npimg1 = cv.imread("./images/1.jpg")img2 = cv.imread("./images/1_test.jpg")# img = cv.add(img1,img2)
# img = cv.addWeighted(img1,0.5,img2,0.8,gamma=0)
rows,cols,channels = img2.shape
roi = img1[0:rows,0:cols]
img2gray = cv.cvtColor(img2,cv.COLOR_BGR2GRAY)
ret,mask = cv.threshold(img2gray,10,255,cv.THRESH_BINARY|cv.THRESH_OTSU)
mask_inv = cv.bitwise_not(mask)img1_bg = cv.bitwise_not(roi,roi,mask=mask_inv)
cv.imshow("img1_bg",img1_bg)
cv.waitKey(0)

在这里插入图片描述

  • 按位或

import cv2 as cv
import numpy as npimg1 = cv.imread("./images/1.jpg")img2 = cv.imread("./images/1_test.jpg")# img = cv.add(img1,img2)
# img = cv.addWeighted(img1,0.5,img2,0.8,gamma=0)
rows,cols,channels = img2.shape
roi = img1[0:rows,0:cols]
img2gray = cv.cvtColor(img2,cv.COLOR_BGR2GRAY)
ret,mask = cv.threshold(img2gray,10,255,cv.THRESH_BINARY|cv.THRESH_OTSU)
cv.imshow("img3",roi)
cv.imshow("img1",mask)
mask_inv = cv.bitwise_not(mask)img1_bg = cv.bitwise_or(roi,roi,mask=mask_inv)
cv.imshow("img1_bg",img1_bg)
cv.waitKey(0)

在这里插入图片描述

  • 按位异或
import cv2 as cv
import numpy as npimg1 = cv.imread("./images/1.jpg")img2 = cv.imread("./images/1_test.jpg")# img = cv.add(img1,img2)
# img = cv.addWeighted(img1,0.5,img2,0.8,gamma=0)
rows,cols,channels = img2.shape
roi = img1[0:rows,0:cols]
img2gray = cv.cvtColor(img2,cv.COLOR_BGR2GRAY)
ret,mask = cv.threshold(img2gray,10,255,cv.THRESH_BINARY|cv.THRESH_OTSU)
cv.imshow("img3",roi)
cv.imshow("img1",mask)
mask_inv = cv.bitwise_xor(mask,mask)img1_bg = cv.bitwise_or(roi,roi,mask=mask_inv)
cv.imshow("img1_bg",img1_bg)
cv.waitKey(0)

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com