2021-12-16 09:11:50 +00:00
|
|
|
#include "ImageApplySplit.h"
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
CImageApplySplit::CImageApplySplit()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CImageApplySplit::~CImageApplySplit(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-14 02:30:19 +00:00
|
|
|
std::vector<cv::Mat> CImageApplySplit::apply(cv::Mat& pDib,int side)
|
2021-12-16 09:11:50 +00:00
|
|
|
{
|
|
|
|
if (pDib.empty())
|
|
|
|
return std::vector<cv::Mat>();
|
|
|
|
std::vector<cv::Mat> retMats;
|
|
|
|
int heigth = pDib.rows;
|
|
|
|
int width = pDib.cols;
|
2022-02-14 02:30:19 +00:00
|
|
|
cv::Mat matF,matB,temp;
|
2021-12-16 09:11:50 +00:00
|
|
|
if (heigth > width)
|
|
|
|
{
|
2022-02-14 02:30:19 +00:00
|
|
|
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)));
|
2021-12-16 09:11:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-14 02:30:19 +00:00
|
|
|
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));
|
2021-12-16 09:11:50 +00:00
|
|
|
}
|
2022-02-14 02:30:19 +00:00
|
|
|
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);
|
|
|
|
//
|
|
|
|
//}
|
2021-12-16 09:11:50 +00:00
|
|
|
return retMats;
|
|
|
|
}
|
|
|
|
|