不规则ROI
2015-06-28 18:36
232 查看
原文:http://blog.csdn.net/xuelin273/article/details/4336064
A few days ago, a reader asked me about selecting circular ROI using OpenCV. I think such a function for selecting non-rectangular subimage would be useful, so I tried to write one.
OpenCV doesn't provide a function to make non-rectangle ROI, so I use image mask to do the trick. It works like this. say we have two images:
We can extract a region from
Fig 1. Selecting circular ROI and applying some processing on it.
The full listing is shown below. The code loads an image, select circular ROI, and applying some processing on it.
Listing 1: Extract a circular ROI
In the example above, I only invert the subimage to make it simple. Change the line 39 with more complex image processing.
A few days ago, a reader asked me about selecting circular ROI using OpenCV. I think such a function for selecting non-rectangular subimage would be useful, so I tried to write one.
OpenCV doesn't provide a function to make non-rectangle ROI, so I use image mask to do the trick. It works like this. say we have two images:
img- an RGB image.
mask- a black image, with white circle on it.
We can extract a region from
imgby:
res = img & mask
resnow contains a portion from
imgwhere the white circle is located.
Fig 1. Selecting circular ROI and applying some processing on it.
The full listing is shown below. The code loads an image, select circular ROI, and applying some processing on it.
Listing 1: Extract a circular ROI
相关文章推荐
- 斑斓中国BlenderCN项目库
- struts2.1笔记04:struts2优点
- windows 3.2平台编译及其打包
- 递归练习
- const学习总结
- 随笔
- 我开通博客了
- Java编程题每日一练day1
- 转:Delphi各种Socket组件的模式和模型
- 常用排序算法之希尔排序法
- OCP-1Z0-051-2015-25题
- 我的第一个github开源工程libpsd
- 转:RealThinClient LinkedObjects Demo解析
- java 内存泄漏
- 1005--<id>
- 关联引用
- Leetcode 215 Kth Largest Element in an Array
- PHP生成图形化验证码
- 学习笔记:Unity战斗卡牌游戏(一)-----NGUI基础组件使用及代码修改获取
- struts2.1笔记03:AOP编程和拦截器概念的简介