Python-图像拼接神器-stitching

多幅图像的拼接

采用这个包,图像拼接结果很好~

代码只需要三四行

python 复制代码
import stitching
import cv2


imgs = ["data/test02/1Hill.jpg","data/test02/2Hill.jpg","data/test02/3Hill.jpg",]
stitcher = stitching.Stitcher()
panorma = stitcher.stitch(imgs)
cv2.imshow("after",panorma)
cv2.waitKey(0)

测试图片

图片1

图片2

图片3

拼接后的效果图

图像拼接的效果图:

其他优点说明

比如:你想将这三张图片拼接在一起,但是在这里面有混入了一张无关的照片,他还是会拼接的很好;

什么意思呢

具体来说:

我把这四张图片放在一起进行拼接

图片1

图片2

图片3

图片4

将以上四张图片一起拼接会发生什么呢?

这个就是图片拼接后的结果。

代码优化

python 复制代码
# 代码优化
#当你有很多图片要读取时,一个个的在img的列表中写文件名称时,比较繁琐
#因此作出此优化改进

import stitching
import cv2
import glob

def read_images(image_paths):
    images = []
    for image_path in image_paths:
        image = cv2.imread(image_path)
        images.append(image)
    return images

# 图片路径列表
image_paths = glob.glob("data/test01/*.jpg")

# 读取图片
images = read_images(image_paths)

# imgs = ["data/test01/1Hill.jpg","data/test01/1.jpg","data/test01/2.jpg","data/test01/3.jpg"]
stitcher = stitching.Stitcher()
panorma = stitcher.stitch(images)
cv2.imshow("after",panorma)
cv2.waitKey(0)
```python

# 完结撒花
![在这里插入图片描述](https://img-blog.csdnimg.cn/80318465378840cc99aa4777f66bcf3d.png)
相关推荐
apocelipes13 小时前
常用编程语言和库的正则表达式性能对比
c语言·c++·python·性能优化·golang·开发工具和环境
用户83562907805115 小时前
使用 Python 在 PDF 中创建与管理书签
后端·python
MeixianAgent19 小时前
Python 回测数据入口怎么验?历史 K 线入库前先做 5 个检查
后端·python
咕白m6251 天前
用 Python 实现一键批量查找与替换 Excel 数据
后端·python
SelectDB2 天前
Apache Doris Python UDF:让 SQL 直接调用 Python 生态,支撑 Agent 时代复杂业务逻辑
大数据·数据库·python
荣码2 天前
GraphRAG:普通RAG只能回答"点"的问题,我踩了4个坑才搞懂
java·python
金銀銅鐵2 天前
[Python] 基于欧几里得算法,实现分数约分计算器
python·数学
Lyn_Li2 天前
Kaggle Top 5 | 198只股票、200条数据的金融预测——BattleFin高分方案从零复现
python·kaggle·比赛复盘·金融预测
小九九的爸爸3 天前
前端想要入门Agent开发,要具备哪些Python基础?
python·agent·ai编程
阿耶同学3 天前
手把手教你用 LangGraph 搭建三层嵌套 Agent 架构
python·程序员