twain3.0/huagao/ImageProcess/ImageApplySplit.cpp

37 lines
798 B
C++
Raw Normal View History

2021-12-16 09:11:50 +00:00
#include "ImageApplySplit.h"
#include <vector>
CImageApplySplit::CImageApplySplit()
{
}
CImageApplySplit::~CImageApplySplit(void)
{
}
std::vector<cv::Mat> CImageApplySplit::apply(cv::Mat& pDib)
{
if (pDib.empty())
return std::vector<cv::Mat>();
std::vector<cv::Mat> retMats;
int heigth = pDib.rows;
int width = pDib.cols;
if (heigth > width)
{
cv::Mat matF = pDib(cv::Rect(0, 0, width, (int)(0.5 * heigth)));
cv::Mat matB = pDib(cv::Rect(0, (int)(0.5 * heigth), width, (int)(0.5 * heigth)));
retMats.push_back(matF);
retMats.push_back(matB);
}
else
{
cv::Mat matF = pDib(cv::Rect(0, 0, (int)(width*0.5), heigth));
cv::Mat matB = pDib(cv::Rect((int)(width*0.5), 0, (int)(width * 0.5), heigth));
retMats.push_back(matF);
retMats.push_back(matB);
}
return retMats;
}