当前位置:网站首页>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 插值
边栏推荐
- ECCV2022 Workshop | Multi-Object Tracking and Segmentation in Complex Environments
- Parse the bootargs from the device tree (dtb format data)
- July Bootcamp (Day 31) - Status Compression
- 【密码学/密码分析】基于TMTO的密码分析方法
- 设备树的树形结构到底是怎样体现的?
- What practical projects can machine learning beginners learn?
- MYSQL transactions
- Handwritten binary search tree and test
- SC7A20 (Silan Micro-Accelerometer) Example
- 软考高级系统架构设计师系列之:信息系统基础知识
猜你喜欢
Beijing suddenly announced that yuan universe big news
Solve the problem that Excel opens very slowly after installing MySQL
Academicians of the two academies speak bluntly: Don't be superstitious about academicians
RTL8762DK PWM(七)
Compiled on unbutu with wiringPi library and run on Raspberry Pi
MYSQL two-phase commit
How to get started with YOLO?How to implement your own training set?
Super like the keyboard made from zero, IT people love it
Key Points Estimation and Point Instance
声称AI存在意识,谷歌工程师遭解雇:违反保密协议
随机推荐
Beijing suddenly announced that yuan universe big news
Ordinary users cannot access HGFS directory
MYSQL master-slave replication
【密码学/密码分析】基于TMTO的密码分析方法
链式编程、包、访问权限
Basic use of vim - command mode
Cmake introductory study notes
RTL8762DK WDG (six)
Luogu P3373: Segment tree
gateway gateway cross domain
RTL8762DK PWM(七)
七月集训(第31天) —— 状态压缩
Game Security 03: A Simple Explanation of Buffer Overflow Attacks
ARM cross compilation
【Cryptography/Cryptanalysis】Cryptanalysis method based on TMTO
北京突然宣布,元宇宙重大消息
/usr/sbin/vmware-authdlauncher: error while loading shared libraries: libssl.so.1.0.2*Solution
SC7A20 (Silan Micro-Accelerometer) Example
Data Middle Office Construction (VII): Data Asset Management
RTL8762DK uses DebugAnalyzer (four)