twain3.0/huagao/ImageProcess/ImageApplySplit.cpp

41 lines
882 B
C++

#include "ImageApplySplit.h"
#include <vector>
CImageApplySplit::CImageApplySplit()
{
}
CImageApplySplit::~CImageApplySplit(void)
{
}
std::vector<cv::Mat> CImageApplySplit::apply(cv::Mat& pDib,int side)
{
if (pDib.empty())
return std::vector<cv::Mat>();
std::vector<cv::Mat> retMats;
int heigth = pDib.rows;
int width = pDib.cols;
cv::Mat matF,matB,temp;
if (heigth > width)
{
matF = pDib(cv::Rect(0, 0, width, (int)(0.5 * heigth)));
matB = pDib(cv::Rect(0, (int)(0.5 * heigth), width, (int)(0.5 * heigth)));
}
else
{
matF = pDib(cv::Rect(0, 0, (int)(width*0.5), heigth));
matB = pDib(cv::Rect((int)(width*0.5), 0, (int)(width * 0.5), heigth));
}
retMats.push_back(matF);
retMats.push_back(matB);
//for (int i = 0; i < retMats.size(); i++) {
// cv::flip(retMats[i], retMats[i], 0);
// cv::flip(retMats[i], retMats[i], 1);
//
//}
return retMats;
}