当前位置:网站首页>[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)
边栏推荐
- About the loading of layer web spring layer components, the position of the layer is centered
- 接口测试面试题目,你都会了吗?
- js4day(DOM开始:获取DOM元素内容,修改元素样式,修改表单元素属性,setInterval定时器,轮播图案例)
- JS7day(事件对象,事件流,事件捕获和冒泡,阻止事件流动,事件委托,学生信息表案例)
- Js1day (syntaxe d'entrée / sortie, type de données, conversion de type de données, Var et let différenciés)
- Js4day (DOM start: get DOM element content, modify element style, modify form element attributes, setinterval timer, carousel Map Case)
- Hash table acwing 840 Simulated hash table
- Typora+docsify quick start
- 8A Synchronous Step-Down regulator tps568230rjer_ Specification information
- spfa AcWing 852. SPFA judgement negative ring
猜你喜欢
Counting class DP acwing 900 Integer partition
Floyd AcWing 854. Floyd finds the shortest path
[ybtoj advanced training guide] similar string [string] [simulation]
Js8day (rolling event (scroll family), offset family, client family, carousel map case (to be done))
线性DP AcWing 896. 最长上升子序列 II
Openssh remote enumeration username vulnerability (cve-2018-15473)
Heap acwing 839 Simulated reactor
js4day(DOM开始:获取DOM元素内容,修改元素样式,修改表单元素属性,setInterval定时器,轮播图案例)
包管理工具
Deep Copy Event bus
随机推荐
哈希表 AcWing 840. 模拟散列表
Apply lnk306gn-tl converter, non isolated power supply
Js6day (search, add and delete DOM nodes. Instantiation time, timestamp, timestamp cases, redrawing and reflow)
ArrayList与LinkedList效率的对比
Redis introduction, scenario and data type
趣味 面试题
Linear DP acwing 898 Number triangle
JS8day(滚动事件(scroll家族),offset家族,client家族,轮播图案例(待做))
Sensor adxl335bcpz-rl7 3-axis accelerometer complies with rohs/weee
js 迭代器 生成器 异步代码处理 promise+生成器 -> await/async
堆 AcWing 839. 模拟堆
Efficiency comparison between ArrayList and LinkedList
Typora+docsify quick start
模数转换器(ADC) ADE7913ARIZ 专为三相电能计量应用而设计
Anti shake throttle
C operator
JS iterator generator asynchronous code processing promise+ generator - > await/async
Ntmfs4c05nt1g N-ch 30V 11.9a MOS tube, pdf
bellman-ford AcWing 853. 有边数限制的最短路
Async/await asynchronous function