当前位置:网站首页>[opencv learning] [image pyramid]
[opencv learning] [image pyramid]
2022-07-02 12:52:00 【A sea of stars】
Today, learn about the image pyramid , To put it bluntly, some methods of image zooming in and out , But it is in equal proportion .
import cv2
import numpy as np
# Show the image , Encapsulate as a function
def cv_show_image(name, img):
cv2.imshow(name, img)
cv2.waitKey(0) # Waiting time , In milliseconds ,0 Represents any key termination
cv2.destroyAllWindows()
# Image pyramid , above size Small , Below size Big
# For example, an image shape yes (H,W)
# Then the upper layer of the pyramid is (1/2 * H, 1/2 * W)
# Then the upper layer of the pyramid is (1/4 * H, 1/4 * W)
# Then the upper layer of the pyramid is (1/8 * H, 1/8 * W)
# Then the upper layer of the pyramid is (1/16 * H, 1/16 * W)
# This is a shrinking process , The way is , First, convolute with Gaussian kernel , Let each pixel contain some information of adjacent pixels , Then remove all even rows and columns
# This process is called down sampling , Shrunk
# Same thing , Upsampling means that the image becomes larger .
# Then the next floor of the pyramid is (2*H, 2*W)
# Then the next level of the pyramid is (4*H, 4*W)
# Then the next level of the pyramid is (8*H, 8*W)
# For example, expand twice [[10, 20], [30, 40]] ===>>> [[10, 0, 20, 0],[0, 0, 0, 0],[30, 0, 40, 0],[0, 0, 0, 0]]
img = cv2.imread('images/saoge.jpg', cv2.IMREAD_GRAYSCALE)
print(img.shape) # (337, 600)
up = cv2.pyrUp(img)
print(up.shape) # (674, 1200)
cv_show_image('up', up)
down = cv2.pyrDown(img)
print(down.shape) # (169, 300)
cv_show_image('down', down)
边栏推荐
- Five best software architecture patterns that architects must understand
- spfa AcWing 852. SPFA judgement negative ring
- JS10day(api 阶段性完结,正则表达式简介,自定义属性,过滤敏感词案例,注册模块验证案例)
- Floyd AcWing 854. Floyd finds the shortest path
- C#运算符
- Mui WebView down refresh pull-up load implementation
- [ybtoj advanced training guide] similar string [string] [simulation]
- Window10 upgrade encountered a big hole error code: 0xc000000e perfect solution
- js3day(数组操作,js冒泡排序,函数,调试窗口,作用域及作用域链,匿名函数,对象,Math对象)
- JSON序列化 与 解析
猜你喜欢

包管理工具

Js5day (event monitoring, function assignment to variables, callback function, environment object this, select all, invert selection cases, tab column cases)

Linear DP acwing 897 Longest common subsequence

Linear DP acwing 896 Longest ascending subsequence II

Direct control PTZ PTZ PTZ PTZ camera debugging (c)

三面阿里,有惊无险成功拿到offer定级P7,只能说是真的难

BOM DOM

Anti shake throttle

Mobile layout (flow layout)

spfa AcWing 852. spfa判断负环
随机推荐
bellman-ford AcWing 853. 有边数限制的最短路
BOM DOM
堆 AcWing 838. 堆排序
Interview with meituan, a 34 year old programmer, was rejected: only those under the age of 30 who work hard and earn little overtime
Js8day (rolling event (scroll family), offset family, client family, carousel map case (to be done))
2.7 binary tree, post order traversal - [FBI tree]
Package management tools
正确遍历EntryList方法
Typora+docsify quick start
Dijkstra AcWing 850. Dijkstra求最短路 II
百款拿来就能用的网页特效,不来看看吗?
Js7day (event object, event flow, event capture and bubble, prevent event flow, event delegation, student information table cases)
Use MySQL events to regularly perform post seven world line tasks
包管理工具
Hash table acwing 840 Simulated hash table
Heap acwing 839 Simulated reactor
Analog to digital converter (ADC) ade7913ariz is specially designed for three-phase energy metering applications
Ntmfs4c05nt1g N-ch 30V 11.9a MOS tube, pdf
Browser node event loop
软件测试面试题-2022年大厂面试题合集