#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);
}
N维密集数组类
**定义:** mat.hpp:829
MatSize size
**定义:** mat.hpp:2177
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