当前位置:网站首页>Opencv learning Day2
Opencv learning Day2
2022-07-24 20:34:00 【SKYWALKERS_ two thousand three hundred and ninety-seven】
Border filling
import cv2
img = cv2.imread('sample.jpg')
top_size,bottom_size,left_size,right_size = (50,50,50,50)# Length of padding around the picture
replicate = cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,borderType = cv2.BORDER_REPLICATE)
reflect = cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,borderType = cv2.BORDER_REFLECT)
reflect101 = cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,borderType = cv2.BORDER_REFLECT_101)
wrap = cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,borderType = cv2.BORDER_WRAP)
constant = cv2.copyMakeBorder(img,top_size,bottom_size,left_size,right_size,borderType = cv2.BORDER_CONSTANT,value = 0)
cv2.imshow('Original',img)
cv2.imshow('replicate',replicate)
cv2.imshow('reflect',reflect)
cv2.imshow('reflect101',reflect101)
cv2.imshow('wrap',wrap)
cv2.imshow('constant',constant)
cv2.waitKey(0)
cv2.destroyWindow()
BORDER_REPLICATE: Replication , That is to copy the edge pixels .
BORDER_REFLECT: Reflection , Copy the pixels in the image of interest on both sides
BORDER_REFLECT_101: Reflection , That is, take the most edge pixel as the axis
BORDER_WRAP: The outer packing method , Connect the left boundary and the right boundary of the image , The upper and lower boundaries are connected
BORDER_CONSTANT: Constant method , It needs filling value value ,0 Indicates black box filling
Numerical calculation
import cv2
img = cv2.imread('sample.jpg')
image = cv2.imread('test.jpg')
print(img[0:5,0:5,0])
print(image[0:5,0:5,0])
# Direct addition 10
img1 = img +10
image1 = image + 10
print(img1[0:5,0:5,0])
print(image1[0:5,0:5,0])
# The two images are added directly , The size should be the same
img = cv2.resize(img,(image.shape[1],image.shape[0]))
result1 = img + image
print(result1[0:5,0:5,0])
# adopt cv2.add Add up , The size should be the same
result2 = cv2.add(img,image)
print(result2[0:5,0:5,0])
Image fusion
If you add it directly , Will report a mistake
# Image fusion
import cv2
image = cv2.imread('sample.jpg')
img = cv2.imread('test.jpg')
result = image + img

Adjust the two pictures to the same size and then merge
# Image fusion
import cv2
image = cv2.imread('sample.jpg')
img = cv2.imread('test.jpg')
# Adjust the two pictures to the same size
img = cv2.resize(img,(image.shape[1],image.shape[0]))
result = image + img
cv2.imshow('1',result)
cv2.waitKey(0)
cv2.destroyAllWindows()
Use function fusion
# Image fusion
import cv2
image = cv2.imread('sample.jpg')
img = cv2.imread('test.jpg')
# Adjust the two pictures to the same size
img = cv2.resize(img,(image.shape[1],image.shape[0]))
result = cv2.addWeighted(image, 0.5, img, 0.5, 0)
cv2.imshow('1',result)
cv2.waitKey(0)
cv2.destroyAllWindows()
边栏推荐
- 147 set whether to cache by using the routing meta information - use of include and exclude - use of activated and deactivated
- Valdo2021 - vascular space segmentation in vascular disease detection challenge (2)
- Oracle primary key auto increment setting
- [msp430g2553] graphical development notes (2) system clock and low power consumption mode
- 1. Mx6u-alpha development board (key input experiment)
- Docker builds redis and clusters
- [training Day10] point [enumeration] [bidirectional linked list]
- Inconsistent time
- Apache atlas version 2.2 installation
- Leetcode 146: LRU cache
猜你喜欢

"Hualiu is the top stream"? Share your idea of yyds

Browser local storage webstroage

Valdo2021 - vascular space segmentation in vascular disease detection challenge (I)

The U.S. economy continues to be weak, and Microsoft has frozen recruitment: the cloud business and security software departments have become the hardest hit

vlan技术

Open source demo | release of open source example of arcall applet
![[basic data mining technology] exploratory data analysis](/img/0c/1b73098a589a2af398dd3cd9d62cd7.png)
[basic data mining technology] exploratory data analysis
![[Extension Program - cat scratch 1.0.15 _ online video and audio acquisition artifact _ installation tutorial plus acquisition]](/img/75/5eca7f63758802ecf86a90a1bbdeaf.png)
[Extension Program - cat scratch 1.0.15 _ online video and audio acquisition artifact _ installation tutorial plus acquisition]
![[training Day9] maze [line segment tree]](/img/56/e8458245fe564821740ab94ece37a4.png)
[training Day9] maze [line segment tree]

How to use named slots
随机推荐
[mathematical modeling / mathematical programming model]
[training Day10] linear [mathematics] [thinking]
1. Mx6u-alpha development board (buzzer experiment)
Apache atlas version 2.2 installation
MySQL docker installation master-slave deployment
Docker builds redis and clusters
Mass modify attribute values in objects in JS
[feature selection] several methods of feature selection
How to learn automated testing? Can you teach yourself?
(forward) usage of PostMessage
Easy to use office network optimization tool onedns
whistle ERR_ CERT_ AUTHORITY_ INVALID
Oracle creates table spaces and views table spaces and usage
Home Assistant中接入博联WiFi智能遥控
Safe way -- Analysis of single pipe reverse connection back door
[Extension Program - cat scratch 1.0.15 _ online video and audio acquisition artifact _ installation tutorial plus acquisition]
class file has wrong version 55.0, should be 52.0
vlan技术
Lua environment configuration
Delete remote and local branches