In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how opencv realizes picture zooming and mirroring. The introduction in this article is very detailed and has certain reference value. Interested friends must read it!
An exercise code to zoom and then mirror an image:
import cv2
import numpy as np
#Open the original
img = cv2.imread("src.jpg", 1)
cv2.imshow("src",img)
#Get original information
imgInfo = img.shape
height = imgInfo[0]
width = imgInfo[1]
deep = imgInfo[2]
#The picture is too big, and the screen is not fully displayed after mirroring. Zoom here first.
matScale = np.float32([[0.8,0,0], [0,0.8,0]])
scale = cv2.warpAffine(img, matScale, (int(width*0.8), int(height*0.8)))
cv2.imshow("scale", scale)
#Re-capture the height and width of the zoomed image
imgInfo = scale.shape
height = imgInfo[0]
width = imgInfo[1]
#Image information mirrored
newImgInfo = (height * 2, width, deep)
dest = np.zeros(newImgInfo, np.uint8)
#Mirrors
for i in range(0, height):
for j in range(0, width):
dest[i,j] = scale[i,j]
dest[height*2 - i -1, j] = scale[i, j]
#Draw a mirror image of the original dividing line
for i in range(0, width):
dest[height, i] = (0,0,255)
cv2.imshow("dst", dest)
cv2.waitKey(0)
After the program runs, the effect is as follows:
The above is "opencv how to achieve image scaling and mirroring" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.