当前位置:网站首页>Which interpolation is better for opencv to zoom in and out??
Which interpolation is better for opencv to zoom in and out??
2022-08-01 02:08:00 【The child YanRe water】
If you are enlarging the image, you should prefer to use INTER_LINEAR or INTER_CUBIC interpolation. If you are shrinkingstrong> 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.
To overcome this problem,You should find out the new dimensions of a given image that can be interpolated.And copy the interpolated sample image on the target image, such as:
# create target image and copy sample image into it(wt, ht) = imgSize # target image size(h, w) = img.shape # given image sizefx = w/wtfy = h/htf = 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 interpolationtarget = np.ones([ht, wt]) * 255 # shape=(64,800)target[0:newSize[1], 0:newSize[0]] = img
About each interpolationAs a result, cv2 resize interpolation methods- Chadrick's Blog
One
Some possible possibilities in openCVThe interpolation is:
- INTER_NEAREST – nearest neighbor interpolation
- INTER_LINEAR – Bilinear interpolation (used by default)
- INTER_AREA – Resampling using pixel area relation.It may be the preferred method for image decimation as it provides moiré-free results.But when the image is scaled, it is similar to the INTER_NEAREST method.
- INTER_CUBIC – Bicubic interpolation of 4×4 pixel neighborhood
- INTER_LANCZOS4 – Lanczos Interpolation of 8x8 Pixel Neighborhood
边栏推荐
- IDEA debugging
- RTL8762DK UART (two)
- [cellular automata] based on matlab interface aggregation cellular automata simulation [including Matlab source code 2004]
- gateway gateway cross domain
- MYSQL transactions
- STK8321 I2C (Shengjia-accelerometer) example
- RTL8762DK PWM(七)
- Rasa 3.x Study Series - Rasa - Issues 4898 Study Notes
- Academicians of the two academies speak bluntly: Don't be superstitious about academicians
- MYSQL Index Analysis
猜你喜欢
随机推荐
How to get started with YOLO?How to implement your own training set?
GDB source code analysis series of articles five: dynamic library delay breakpoint implementation mechanism
Simple vim configuration
The kernel of the decompression process steps
数据中台建设(七):数据资产管理
Super like the keyboard made from zero, IT people love it
从设备树(dtb格式数据)中解析出bootargs
初出茅庐的小李第114篇博客项目笔记之机智云智能浇花器实战(3)-基础Demo实现
RTL8762DK uses DebugAnalyzer (four)
Flink 部署和提交job
初出茅庐的小李第112篇博客项目笔记之机智云智能浇花器实战(1)-基础Demo实现
在打开MYSQL表时,有的可以显示编辑,有的没有,如何设置。
被 CSDN,伤透了心
MYSQL logical architecture
高维高斯分布基础
YOLO怎么入门?怎么实现自己的训练集?
WebApi 打个Attribute 统一处理异常
C字符串数组反转
Google engineer fired for claiming AI awareness: breach of nondisclosure agreement
手写二叉查找树及测试