当前位置:网站首页>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 插值

边栏推荐
- 【Cryptography/Cryptanalysis】Cryptanalysis method based on TMTO
- IDEA修改注释字体
- RTL8762DK 使用DebugAnalyzer(四)
- Replacing the Raspberry Pi Kernel
- Summary of JVM interview questions (continuously updated)
- 北京突然宣布,元宇宙重大消息
- JS时间戳的意义是什么?知道sql会考虑加时间戳,JS的时间戳用于什么场景?
- 普通用户无法访问hgfs目录
- Soft Exam Senior System Architect Series: Basic Knowledge of Information Systems
- 设备树的树形结构到底是怎样体现的?
猜你喜欢

RTL8762DK RTC(五)

Compiled on unbutu with wiringPi library and run on Raspberry Pi

【数据分析】基于matlab GUI学生成绩管理系统【含Matlab源码 1981期】

Modern Enterprise Architecture Framework 1

IDEA 找不到或无法加载主类 或 Module “*“ must not contain source root “*“ The root already belongs to module “*“

STK8321 I2C (Shengjia-accelerometer) example

Summary of JVM interview questions (continuously updated)

ARM cross compilation

【Cryptography/Cryptanalysis】Cryptanalysis method based on TMTO

RTL8762DK PWM(七)
随机推荐
The kernel of the decompression process steps
Lua introductory case of actual combat 1234 custom function and the standard library function
GDB 源码分析系列文章五:动态库延迟断点实现机制
北京突然宣布,元宇宙重大消息
YOLO怎么入门?怎么实现自己的训练集?
OSD读取SAP CRM One Order应用日志的优化方式
MYSQL logical architecture
Luogu P3373: Segment tree
RTL8762DK uses DebugAnalyzer (four)
MYSQL Index Analysis
SC7A20(士兰微-加速度传感器)示例
Raspberry pie arm version of GCC installed configuration and environment variables
MYSQL master-slave replication
元宇宙改变人类工作模式的四种方式
IDEA 找不到或无法加载主类 或 Module “*“ must not contain source root “*“ The root already belongs to module “*“
RTL8762DK WDG (six)
Beijing suddenly announced that yuan universe big news
IDEA modifies the annotation font
High dimensional Gaussian distribution basics
【 】 today in history: on July 31, "brains in vats" the birth of the participant;The father of wi-fi was born;USB 3.1 standard