OpenCV实现图像切割功能

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 ceil_img ;
  Cut_img(img, m, n, ceil_img);
  cvWaitKey(0);
  return 0;
}

二、程序运行结果:

(1)原图像:

OpenCV实现图像切割功能_第1张图片

(2)切割后图像:

OpenCV实现图像切割功能_第2张图片

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

你可能感兴趣的:(OpenCV实现图像切割功能)