openCV实现将图像切成m*n块,供大家参考,具体内容如下
一、代码部分:
#include "stdafx.h"
#include
#include
#include
#include
#include
#include
using namespace std;
using namespace cv;
//Cut an image into m*n patch
void Cut_img(Mat src_img, int m, int n, vector 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;
//String concatenation
ostringstream oss;
string str, str1, str2;
Point p1, p2;
for (int i = 0; i
{
for (int j = 0; j
{
Rect rect(j*ceil_width, i*ceil_height, ceil_width, ceil_height);
src_img(rect).copyTo(roi_img);
ceil_img.pus