Homography(透视变换)

Homography is a transformation ( a 3×3 matrix ) that maps the points in one image to the corresponding points in the other image.

就是两幅图的对应点的变换关系(是一个矩阵),对应点以上图,四个不同颜色点为例。

以红色点为例(x1,y1)<-->(x2,y2),有如下变换关系

利用单应性进行图像匹配(配准)

全景:透视应用

在前一节中,我们知道,如果两个图像之间的单应性已知,我们可以将一个图像扭曲到另一个图像上。然而,有一个大的警告。图像必须包含一个平面(一本书的顶部),只有平面部分被正确对齐。事实证明,如果你拍第一张照片,任何场景(不只是一个平面),然后通过旋转相机拍了第二图像,两图像将被联系通过单应性。

计算透视变换矩阵

为了计算两幅图像之间的单应性,需要知道两幅图像之间至少有4点对应。如果你有4个以上的对应点,那就更好了。OpenCV将稳健估计单应性,最适合所有对应点。通常,这些点对应是通过匹配图像之间的SIFT或SURF等特征自动发现的。

C++

1

2

3

4

5

6

7

8

9

10

// pts_src and pts_dst are vectors of points in source

// and destination images. They are of type vector<Point2f>.

// We need at least 4 corresponding points.

Mat h = findHomography(pts_src, pts_dst);

// The calculated homography can be used to warp

// the source image to destination. im_src and im_dst are

// of type Mat. Size is the size (width,height) of im_dst.

warpPerspective(im_src, im_dst, h, size);

Python

1

2

3

4

5

6

7

8

9

10

11

12

13

14

'''

pts_src and pts_dst are numpy arrays of points

in source and destination images. We need at least

4 corresponding points.

'''

h, status = cv2.findHomography(pts_src, pts_dst)

'''

The calculated homography can be used to warp

the source image to destination. Size is the

size (width,height) of im_dst

'''

im_dst = cv2.warpPerspective(im_src, h, size)

OpenCV的C++单应性实例

在图2中的图像。可以使用下面的C++代码生成。下面的代码显示了如何在两幅图像中获取四个对应点,并将扭曲图像带到另一个图像上。

#include "opencv2/opencv.hpp" using namespace cv;
using namespace std;int main( int argc, char** argv)
{// Read source image.Mat im_src = imread("book2.jpg");// Four corners of the book in source imagevector<Point2f> pts_src;pts_src.push_back(Point2f(141, 131));pts_src.push_back(Point2f(480, 159));pts_src.push_back(Point2f(493, 630));pts_src.push_back(Point2f(64, 601));// Read destination image.Mat im_dst = imread("book1.jpg");// Four corners of the book in destination image.vector<Point2f> pts_dst;pts_dst.push_back(Point2f(318, 256));pts_dst.push_back(Point2f(534, 372));pts_dst.push_back(Point2f(316, 670));pts_dst.push_back(Point2f(73, 473));// Calculate HomographyMat h = findHomography(pts_src, pts_dst);// Output imageMat im_out;// Warp source image to destination based on homographywarpPerspective(im_src, im_out, h, im_dst.size());// Display imagesimshow("Source Image", im_src);imshow("Destination Image", im_dst);imshow("Warped Source Image", im_out);waitKey(0);
}

python

#!/usr/bin/env pythonimport cv2
import numpy as npif __name__ == '__main__' :# Read source image.im_src = cv2.imread('book2.jpg')# Four corners of the book in source imagepts_src = np.array([[141, 131], [480, 159], [493, 630],[64, 601]])# Read destination image.im_dst = cv2.imread('book1.jpg')# Four corners of the book in destination image.pts_dst = np.array([[318, 256],[534, 372],[316, 670],[73, 473]])# Calculate Homographyh, status = cv2.findHomography(pts_src, pts_dst)# Warp source image to destination based on homographyim_out = cv2.warpPerspective(im_src, h, (im_dst.shape[1],im_dst.shape[0]))# Display imagescv2.imshow("Source Image", im_src)cv2.imshow("Destination Image", im_dst)cv2.imshow("Warped Source Image", im_out)cv2.waitKey(0)

图像拼接技术的入门术语相关推荐

  1. kafka分区与分组原理_大数据技术-Kafka入门

    在大数据学习当中,主要的学习重点就是大数据技术框架,针对于大数据处理的不同环节,需要不同的技术框架来解决问题.以Kafka来说,主要就是针对于实时消息处理,在大数据平台当中的应用也很广泛.大数据学习一 ...

  2. Kubernetes技术极速入门(一)---- 初次见面,请多多关照

    1.Kubernetes是什么? Kubernetes是一个开源的,用于管理云平台中多个主机上的容器化的应用,Kubernetes的目标是让部署容器化的应用简单并且高效,Kubernetes提供了应用 ...

  3. 电脑黑客技术新手入门,自学黑客技术入门教程

    最近经常有小伙伴联系我说要学黑客技术,当然目的各种各样,有的就是觉得黑客很酷,单纯想要学技术,还有的就是想找人帮忙攻击赌博网站或者监听别人的电话(以女朋友的电话居多),对于想要单纯学技术的朋友我很欢迎 ...

  4. 智能合约和区块链技术:入门指南

    链客,专为开发者而生,有问必答! 此文章来自区块链技术社区,未经允许拒绝转载. 智能合约和区块链技术:入门指南 多年前,在没有数字合约和区块链技术存在的情况下,双方的合约往往以传统的方式进行.在加密货 ...

  5. ASP.NET WebApi技术从入门到实战演练

    一.课程介绍 曾经有一位不知名的讲师说过这么一句名言: 一门RPC技术不会,那么千万万门RPC技术将都不会!在今天移动互联网的时代,作为攻城师的我们,谁不想着只写一套API就可以让我们的Web, An ...

  6. 【入门须知】学DIV CSS技术如何入门?

    [入门须知]学DIV CSS技术如何入门? 引言: 引用一本书中的一段文字:"当我第一次开始学习汉语时,我的家庭老师老王给了我一本汉英字典.一本汉语语法书和一本初级教程.但是,他将这些书放 ...

  7. 编程大讲坛、坛坛是佳酿--编程大讲坛:C#核心开发技术从入门到精通

    [书名]编程大讲坛:C#核心开发技术从入门到精通 [作者]管西京 [ISBN] 978-7-121-09043-1 [出版社]电子工业出版社 [出版日期]2009年9月 [定  价]79.80元(含光 ...

  8. 编程大讲坛、坛坛是佳酿--编程大讲坛:Visual Basic核心开发技术从入门到精通...

    [书名]编程大讲坛:Visual Basic核心开发技术从入门到精通 [作者]薛小龙 [ISBN]978-7-121-09057-8 [出版社]电子工业出版社 [出版日期]2009年9月 [定  价] ...

  9. 容器编排技术 -- Kubernetes入门概述

    容器编排技术 -- Kubernetes入门概述 简介 Kubernetes是一个开源的,用于管理云平台中多个主机上的容器化的应用,Kubernetes的目标是让部署容器化的应用简单并且高效(powe ...

最新文章

  1. 阿里云飞天论文获国际架构顶会 ATC 2021最佳论文:全球仅三篇
  2. react当中子组件改变父组件的状态
  3. MySQL 使用Navicat连接MySQL8出现1251错误
  4. Display Substring
  5. 16重新安装HA0.63
  6. 如何测试连接MsSQL数据库-------UDL文件
  7. (14)System Verilog 常量const详解
  8. linux resin 自动启动不了,linux下开机启动nginx+resin
  9. WEB三大攻击之—SQL注入攻击与防护
  10. Ubuntu20.04 安装wine QQ
  11. html 新浪微博分享申请,新浪微博API申请流程详解
  12. 怎样把IPv4转换成IPv6?
  13. 微信小程序 多标签选择和添加标签
  14. Java 找水仙花数
  15. XAVIER CMDS
  16. 什么是加密?什么是md5加密算法?
  17. android 背景描边,Android告别使用shape标签,自定义实现圆角、背景色、描边Button...
  18. 后端 php mysql_搭建并部署PHP + MySQL后端环境
  19. python DEA: 基于非径向距离NDDF的Malmquist-Luenberger 指数及其分解
  20. 说句心里话python怎么写_说句心里话作文

热门文章

  1. linux停止network服务命令是,Linux系统服务启动和停止
  2. IDEA使用注释技巧
  3. 【Vue入门实践3】不调后端接口==>el-table单纯前端实现查询和重置功能==>【el-table组件使用】表格静态前端筛选、查询重置功能
  4. Stacking 集成学习在多因子选股中的应用
  5. python - 内存管理
  6. 微服务调用链追踪方案
  7. 前沿对话 | 深育大讲堂之深入云原生时代微服务架构
  8. linux中睡眠命令,Linux 休眠命令
  9. gcc编译多文件项目(包含静态库和动态库)
  10. JQuery获取元素的方法总结