// Cut_image.cpp : 定义控制台应用程序的入口点。
//
/***********************************************************************
* OpenCV 2.4.4 测试例程
* 杜健健 提供
***********************************************************************/
#include "Cut_image.h"
//#include "stdafx.h"
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <vector>
using namespace std;
using namespace cv;
//剪切图片为m * n 块
void Cut_img(Mat src_img,int m,int n,Vector<Mat> ceil_img){
int t = m * n;
int height = src_img.rows;
int width = src_img.cols;
int ceil_height = height/m;
int ceil_width = width/n;
Mat roi_img,tmp_img;
Point p1,p2;
for(int i = 0;i<m;i++)
for(int j = 0;j<n;j++){
//p1 =
Rect rect(i+j*ceil_width,j+i*ceil_height,ceil_width,ceil_height);
src_img(rect).copyTo(roi_img);
ceil_img.push_back(roi_img);
imshow("roi_img",roi_img);
//getchar();
waitKey(0);
//rectangle(i+j*ceil_width,j+i*ceil_height,);
}
}
void show_images(Vector<Mat> imgs,int n){
//do something
}
int _tmain(int argc, _TCHAR* argv[])
{
Mat img = imread("F:\\position\\Data\2\\record_2_201704182100\\raw_image_left\\0138.jpg",1);
imshow("src img",img);
int m = 3;
int n = 3;
Vector<Mat> ceil_img = m*n;
Cut_img(img,m,n,ceil_img);
waitKey();
return 0;
}
Cut_image.rar_cut
版权申诉
45 浏览量
2022-09-19
22:51:10
上传
评论
收藏 815B RAR 举报
林当时
- 粉丝: 100
- 资源: 1万+
最新资源
- vscode配置c/c 环境教程
- vscode配置c/c 环境教程
- 基于matlab实现电磁优化计算功能,进行线型规划优化电磁设计.rar
- 基于matlab实现带精英策略的非支配排序遗传算法matlab 源码.rar
- 基于matlab实现差分进化算法,最新的用于替代遗传算法,是以后的主要发展方法.rar
- VSCode配置c/c++环境教程.md
- 基于matlab实现标准合作型协同进化遗传算法matlab源程序
- 七下人教.zip
- 基于matlab实现本份代码能对图像进行gabor滤波处理,结合指纹方向图以及指纹沟壑频率特性,对指纹图像进行增强.rar
- 基于matlab实现RBM神经网络实现了手写数字体识别的GUI程序.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0