#include <iostream>
#include <stdlib.h>
{
cout << endl;
cout << "克隆模块" << endl;
cout << "---------------" << endl;
cout << "选项: " << endl;
cout << endl;
cout << "1) 普通克隆 " << endl;
cout << "2) 混合克隆 " << endl;
cout << "3) 单色转移 " << endl;
cout << "4) 局部颜色变化 " << endl;
cout << "5) 局部照明变化 " << endl;
cout << "6) 纹理平滑 " << endl;
cout << endl;
cout << "按数字 1-6 从以上技术中选择: ";
int num = 1;
cin >> num;
cout << endl;
if(num == 1)
{
string folder = "cloning/Normal_Cloning/";
string original_path1 = folder + "source1.png";
string original_path2 = folder + "destination1.png";
string original_path3 = folder + "mask.png";
Mat source = imread(original_path1, IMREAD_COLOR);
Mat destination = imread(original_path2, IMREAD_COLOR);
Mat mask = imread(original_path3, IMREAD_COLOR);
{
cout << "无法加载源图像 " << original_path1 << endl;
exit(0);
}
{
cout << "无法加载目标图像 " << original_path2 << endl;
exit(0);
}
if(mask.empty())
{
cout << "无法加载掩码图像 " << original_path3 << endl;
exit(0);
}
seamlessClone(source, destination, mask, p, result, 1);
imshow("输出",result);
imwrite(folder + "cloned.png", result);
}
else if(num == 2)
{
string folder = "cloning/Mixed_Cloning/";
string original_path1 = folder + "source1.png";
string original_path2 = folder + "destination1.png";
string original_path3 = folder + "mask.png";
Mat source = imread(original_path1, IMREAD_COLOR);
Mat destination = imread(original_path2, IMREAD_COLOR);
Mat mask = imread(original_path3, IMREAD_COLOR);
{
cout << "无法加载源图像 " << original_path1 << endl;
exit(0);
}
{
cout << "无法加载目标图像 " << original_path2 << endl;
exit(0);
}
if(mask.empty())
{
cout << "无法加载掩码图像 " << original_path3 << endl;
exit(0);
}
p.
x = destination.
size().width/2;
p.
y = destination.
size().height/2;
seamlessClone(source, destination, mask, p, result, 2);
imshow("输出",result);
imwrite(folder + "cloned.png", result);
}
else if(num == 3)
{
string folder = "cloning/Monochrome_Transfer/";
string original_path1 = folder + "source1.png";
string original_path2 = folder + "destination1.png";
string original_path3 = folder + "mask.png";
Mat source = imread(original_path1, IMREAD_COLOR);
Mat destination = imread(original_path2, IMREAD_COLOR);
Mat mask = imread(original_path3, IMREAD_COLOR);
{
cout << "无法加载源图像 " << original_path1 << endl;
exit(0);
}
{
cout << "无法加载目标图像 " << original_path2 << endl;
exit(0);
}
if(mask.empty())
{
cout << "无法加载掩码图像 " << original_path3 << endl;
exit(0);
}
p.
x = destination.
size().width/2;
p.
y = destination.
size().height/2;
seamlessClone(source, destination, mask, p, result, 3);
imshow("输出",result);
imwrite(folder + "cloned.png", result);
}
else if(num == 4)
{
string folder = "cloning/Color_Change/";
string original_path1 = folder + "source1.png";
string original_path2 = folder + "mask.png";
Mat source = imread(original_path1, IMREAD_COLOR);
Mat mask = imread(original_path2, IMREAD_COLOR);
{
cout << "无法加载源图像 " << original_path1 << endl;
exit(0);
}
if(mask.empty())
{
cout << "无法加载掩码图像 " << original_path2 << endl;
exit(0);
}
colorChange(source, mask, result, 1.5, .5, .5);
imshow("输出",result);
imwrite(folder + "cloned.png", result);
}
else if(num == 5)
{
string folder = "cloning/Illumination_Change/";
string original_path1 = folder + "source1.png";
string original_path2 = folder + "mask.png";
Mat source = imread(original_path1, IMREAD_COLOR);
Mat mask = imread(original_path2, IMREAD_COLOR);
{
cout << "无法加载源图像 " << original_path1 << endl;
exit(0);
}
if(mask.empty())
{
cout << "无法加载掩码图像 " << original_path2 << endl;
exit(0);
}
illuminationChange(source, mask, result, 0.2f, 0.4f);
imshow("输出",result);
imwrite(folder + "cloned.png", result);
}
else if(num == 6)
{
string folder = "cloning/Texture_Flattening/";
string original_path1 = folder + "source1.png";
string original_path2 = folder + "mask.png";
Mat source = imread(original_path1, IMREAD_COLOR);
Mat mask = imread(original_path2, IMREAD_COLOR);
{
cout << "无法加载源图像 " << original_path1 << endl;
exit(0);
}
if(mask.empty())
{
cout << "无法加载掩码图像 " << original_path2 << endl;
exit(0);
}
textureFlattening(source, mask, result, 30, 45, 3);
imshow("输出",result);
imwrite(folder + "cloned.png", result);
}
waitKey(0);
}
MatSize size
定义 mat.hpp:2160
bool empty() const
如果数组没有元素,则返回 true。
_Tp y
点的 y 坐标
定义 types.hpp:202
_Tp x
点的 x 坐标
定义 types.hpp:201
int main(int argc, char *argv[])
定义 highgui_qt.cpp:3
与磁盘上的文件关联的文件存储的“黑盒”表示。
定义 core.hpp:102