按照50%重合区域,在横纵方向上截多幅图组成二维图像数组
2016-10-09 08:30
211 查看
// 使用ROI来截图 // 左上点是原点 // #include "stdafx.h" #include "highgui.h" #include "cv.h" #include "cxcore.h" #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { IplImage* src = cvLoadImage("Penguins.jpg"); cout<<"please input the number of the x-axis partiton: "; int parx(0);cin>>parx; cout<<"please input the number of the y-axis partiton: "; int pary(0);cin>>pary; cout<<endl; int width = src->width; int height = src->height; int half_width = width/(parx+1); int full_width = 2*half_width; int half_height = height/(pary+1); int full_height =2*half_height; CvRect rect; int count(0); char pa[50] = {NULL}; for(int j=0;j<pary;j++) { for(int i=0;i<parx;i++) { rect = cvRect( i*half_width, j*half_height, full_width, full_height); cvSetImageROI(src,rect); sprintf(pa,"%d.jpg",1+i+j*parx); cvSaveImage(pa,src); count++; } } cvResetImageROI(src); cvReleaseImage(&src); cout<<"finished!total number of sub_pictures is"<<count<<endl; return 0; }
说明:
将一副图划分为几幅等大小的小图
相关文章推荐
- php 二维 数组 按照某一字段排序
- poj 2155 Matrix(二维树状数组,好题)中等难度题目,更新区域,查询单点
- 把一个二维实型数组a按照第0列的元素进行排序(由小到大排序,用气泡法)
- PHP排序之二维数组的按照字母排序实现代码
- POJ2155 二维树状数组求区域和
- PHP排序之二维数组的按照字母排序方法
- Python中二维列表如何获取子区域元素的组成
- PHP排序之二维数组的按照字母排序方法
- vtk提取二维bmp图像某区域
- POJ - 2352 Stars解题报告(树状数组求二维区域和)
- 把图像数据写进一个txt文本中,然后整成二维数组初始化的形式,复制到CCS中
- 二维数组分组:按照一个键值,按照多个键值
- PHP排序之二维数组的按照字母排序实现代码
- PHP排序之二维数组的按照字母排序方法
- 【二维树状数组】poj 1195 Mobile phones
- C++ : 用proxy Class实现简单的二维数组。
- 二维字符串数组全局变量保存问题
- NYOJ 92 图像有用区域(BFS)
- 数字图像处理—图像分割—串行区域(区域生长)(分裂合并)
- 算法模板——线段树6(二维线段树:区域加法+区域求和)(求助phile)