当前位置:网站首页>opencv 缩小放大用哪种插值更好??
opencv 缩小放大用哪种插值更好??
2022-08-01 01:48:00 【子燕若水】
If you are enlarging the image, you should prefer to use INTER_LINEAR or INTER_CUBIC interpolation. If you are shrinking the image, you should prefer to use INTER_AREA interpolation.
Cubic interpolation is computationally more complex, and hence slower than linear interpolation. However, the quality of the resulting image will be higher.
为了克服这个问题,您应该找出可以进行插值的给定图像的新尺寸。并在目标图像上复制插值采样图像,如:
# create target image and copy sample image into it
(wt, ht) = imgSize # target image size
(h, w) = img.shape # given image size
fx = w / wt
fy = h / ht
f = max(fx, fy)
newSize = (max(min(wt, int(w / f)), 1),
max(min(ht, int(h / f)), 1)) # scale according to f (result at least 1 and at most wt or ht)
img = cv2.resize(img, newSize, interpolation=cv2.INTER_CUBIC) #INTER_CUBIC interpolation
target = np.ones([ht, wt]) * 255 # shape=(64,800)
target[0:newSize[1], 0:newSize[0]] = img有关每个插值的结果,cv2 resize interpolation methods - Chadrick's Blog
一
openCV中一些可能的插值是:
- INTER_NEAREST – 最近邻插值
- INTER_LINEAR – 双线性插值(默认使用)
- INTER_AREA – 使用像素区域关系重采样。它可能是图像抽取的首选方法,因为它可以提供无莫尔条纹的结果。但是当图像被缩放时,它类似于 INTER_NEAREST 方法。
- INTER_CUBIC – 4×4 像素邻域的双三次插值
- INTER_LANCZOS4 – 8×8 像素邻域的 Lanczos 插值

边栏推荐
- Summary of JVM interview questions (continuously updated)
- Luogu P3373: 线段树
- MYSQL query interception optimization analysis
- 机器学习应该如何入门?
- 元宇宙改变人类工作模式的四种方式
- 【历史上的今天】7 月 31 日:“缸中之脑”的提出者诞生;Wi-Fi 之父出生;USB 3.1 标准发布
- 2022 CSP-J1 CSP-S1 Round 1 Preliminary Competition Registration Guide
- MYSQL logical architecture
- 【Cryptography/Cryptanalysis】Cryptanalysis method based on TMTO
- Blueprint: Yang Hui's Triangular Arrangement
猜你喜欢

你需要知道的 TCP 四次挥手

IDEA does not recognize the module (there is no blue square in the lower right corner of the module)

Blueprint: Yang Hui's Triangular Arrangement

RTL8762DK Lighting/LED (3)

RTL8762DK RTC(五)

RTL8762DK UART(二)
![leetcode: 1648. Color ball with decreasing sales value [Boundary find by two points]](/img/b9/7bd33bd981ace25e3bbfc7be9117ff.png)
leetcode: 1648. Color ball with decreasing sales value [Boundary find by two points]

IDEA修改注释字体

如何编辑epub电子书的目录

IDEA 找不到或无法加载主类 或 Module “*“ must not contain source root “*“ The root already belongs to module “*“
随机推荐
Basic implementation of vector
Data Middle Office Construction (VII): Data Asset Management
cmake入门学习笔记
IDEA调试
Replacing the Raspberry Pi Kernel
Nmap 操作手册 - 完整版
设备树的树形结构到底是怎样体现的?
500 miles
leetcode: 1562. Find latest grouping of size M [simulation + endpoint record + range merge]
C字符串数组反转
Blueprint: Yang Hui's Triangular Arrangement
ROS2 series of knowledge (4): understand the concept of [service]
By Value or By Reference
Modify Postman installation path
Parse the bootargs from the device tree (dtb format data)
RTL8762DK uses DebugAnalyzer (four)
软考高级系统架构设计师系列之:信息系统基础知识
MYSQL Index Analysis
ARM cross compilation
WAASAP WebClient UI页面标签的决定逻辑介绍