import cv2
import numpy as np,sys
A = cv2.imread('f1.jpg')
B = cv2.imread('f2.jpg')
cv2.imshow('A',A)
cv2.imshow('B',B)
cv2.waitKey()
cv2.destroyAllWindows()
# generate Gaussian pyramid for A
G = A.copy()
gpA = [G]
for i in xrange(5):
G = cv2.pyrDown(G)
gpA.append(G)
# generate Gaussian pyramid for B
G = B.copy()
gpB = [G]
for i in xrange(5):
G = cv2.pyrDown(G)
gpB.append(G)
# generate Laplacian Pyramid for A
lpA = [gpA[5]]
for i in xrange(5,0,-1):
GE = cv2.pyrUp(gpA[i])
L = cv2.subtract(gpA[i-1],GE)
lpA.append(L)
# generate Laplacian Pyramid for B
lpB = [gpB[5]]
for i in xrange(5,0,-1):
GE = cv2.pyrUp(gpB[i])
L = cv2.subtract(gpB[i-1],GE)
lpB.append(L)
# Now add left and right halves of images in each level
LS = []
for la,lb in zip(lpA,lpB):
rows,cols,dpt = la.shape
ls = np.hstack((la[:,0:cols/2], lb[:,cols/2:]))
LS.append(ls)
# now reconstruct
ls_ = LS[0]
for i in xrange(1,6):
ls_ = cv2.pyrUp(ls_)
ls_ = cv2.add(ls_, LS[i])
# image with direct connecting each half
real = np.hstack((A[:,:cols/2],B[:,cols/2:]))
cv2.imwrite('Pyramid_blending2.jpg',ls_)
cv2.imwrite('Direct_blending.jpg',real)
#Working Of the Algorithm
# 1.Load the two images
# 2.Find the Gaussian Pyramids for images (in this particular example, number of levels is 5)
# 3.From Gaussian Pyramids, find their Laplacian Pyramids
# 4.Now join the left half of apple and right half of image in each levels of Laplacian Pyramids
# 5.Finally from this joint image pyramids, reconstruct the original image.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
One application of Pyramids is Image Blending. For example, in image stitching, you will need to stack two images together, but it may not look good due to discontinuities between images. In that case, image blending with Pyramids gives you seamless blending without leaving much data in the images. One classical example of this is the blending of two fruits, Orange and Apple. See the result now itself to understand what I am saying:
资源推荐
资源详情
资源评论





























收起资源包目录







共 5 条
- 1
资源评论


林当时
- 粉丝: 129
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- BDF薄壁箱体施工工法新.doc
- 八大特殊作业危险告知牌(全套).docx
- 大题冲关滚动练之四——电解质溶液的图表类综合题.ppt
- 云计算在运营商业务系统中的应用研究.docx
- 计算机病毒的预防和杀毒策略的研究.docx
- 区块链视角下我国跨境电商的发展困境及应用路径分析.docx
- 基于云计算的中职教学资源库建设的研究.docx
- 某教学楼毕业设计开题报告.doc
- 挡土墙专项施工方案.doc
- 电话招生技巧与实例.doc
- 无线网络技术的道路运政信息管理应用.doc
- 渤海湾区域性工程地质综合评价.docx
- 中小企业薪酬管理制度最实用版.doc
- 莫邪路地铁车站BIM协同设计.doc
- 公司电话管理规定.doc
- 火灾自动报警系统全套施工安装质量资料.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
