搜索
您的当前位置:首页正文

opencv4 图像平铺实现

来源:吉趣旅游网

本来呢我是不想写这篇博客的,可是!看到别人写的很气。

就比如

不多逼逼,上我的代码

#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char** argv)
{
	Mat img1;
	namedWindow("Example1", WINDOW_AUTOSIZE);

	img1 = imread(argv[1]);
	int rows = 0;
	int cols = 0;
	int new_rows = 5000;
	int new_cols = 5000;

	Mat img2;
	img2.create(new_rows, new_cols, img1.type());
	for (int i = 0; i < new_rows; i++)
	{
		if (rows < img1.rows)
		{
			for (int j = 0; j < new_cols; j++)
			{
				if (cols < img1.cols)
				{
					img2.at<Vec3b>(i, j)[0] = img1.at<Vec3b>(rows, cols)[0];
					img2.at<Vec3b>(i, j)[1] = img1.at<Vec3b>(rows, cols)[1];
	

因篇幅问题不能全部显示,请点此查看更多更全内容

Top