当前位置:网站首页>[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)
边栏推荐
- 包管理工具
- Shutter encapsulated button
- 绕过ObRegisterCallbacks需要驱动签名方法
- The redis development document released by Alibaba covers all redis operations
- Linear DP acwing 896 Longest ascending subsequence II
- 获取文件版权信息
- JS7day(事件对象,事件流,事件捕获和冒泡,阻止事件流动,事件委托,学生信息表案例)
- JS10day(api 阶段性完结,正则表达式简介,自定义属性,过滤敏感词案例,注册模块验证案例)
- Five best software architecture patterns that architects must understand
- Linear DP acwing 899 Edit distance
猜你喜欢
Interesting interview questions
趣味 面试题
Floyd AcWing 854. Floyd finds the shortest path
Hash table acwing 841 String hash
What is the relationship between NFT and metauniverse? How to view the market? The future market trend of NFT
Modular commonjs es module
3 A VTT端接 稳压器 NCP51200MNTXG资料
线性DP AcWing 896. 最长上升子序列 II
Five best software architecture patterns that architects must understand
[ybtoj advanced training guidance] cross the river [BFS]
随机推荐
Explain in detail the process of realizing Chinese text classification by CNN
基于STM32的OLED 屏幕驱动
Js7day (event object, event flow, event capture and bubble, prevent event flow, event delegation, student information table cases)
Rust language document Lite (Part 1) - cargo, output, basic syntax, data type, ownership, structure, enumeration and pattern matching
[ybtoj advanced training guidance] judgment overflow [error]
百款拿来就能用的网页特效,不来看看吗?
js4day(DOM开始:获取DOM元素内容,修改元素样式,修改表单元素属性,setInterval定时器,轮播图案例)
BOM DOM
JDBC 预防sql注入问题与解决方法[PreparedStatement]
软件测试面试题-2022年大厂面试题合集
Rust search server, rust quick service finding tutorial
Traverse entrylist method correctly
Mui WebView down refresh pull-up load implementation
spfa AcWing 852. spfa判断负环
Linear DP acwing 902 Shortest editing distance
Direct control PTZ PTZ PTZ PTZ camera debugging (c)
Js2day (also i++ and ++i, if statements, ternary operators, switch, while statements, for loop statements)
JS7day(事件对象,事件流,事件捕获和冒泡,阻止事件流动,事件委托,学生信息表案例)
Redis bloom filter
染色法判定二分图 AcWing 860. 染色法判定二分图