1- 正常克隆 2- 混合克隆 3- 单色转移? 4-颜色变化 5- 照明变化 6-纹理展平
Normal Cloning
泊松融合融合seamlessClone()
3种融合模式flags: NORMAL_CLONE = 1, MIXED_CLONE? = 2, MONOCHROME_TRANSFER = 3
string original_path1 = "source1.png";
string original_path2 = "destination1.png";
string original_path3 = "mask.png";
Mat source = imread(original_path1, IMREAD_COLOR);
Mat destination = imread(original_path2, IMREAD_COLOR);
Mat mask = imread(original_path3, IMREAD_COLOR);
if (source.empty())
{
cout << "Could not load source image " << original_path1 << endl;
exit(0);
}
if (destination.empty())
{
cout << "Could not load destination image " << original_path2 << endl;
exit(0);
}
if (mask.empty())
{
cout << "Could not load mask image " << original_path3 << endl;
exit(0);
}
Mat result;
Point p;
p.x = 400;
p.y = 100;
seamlessClone(source, destination, mask, p, result, 1);
imshow("Output", result);
cv::waitKey();
Mixed Cloning?
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);
if(source.empty())
{
cout << "Could not load source image " << original_path1 << endl;
exit(0);
}
if(destination.empty())
{
cout << "Could not load destination image " << original_path2 << endl;
exit(0);
}
if(mask.empty())
{
cout << "Could not load mask image " << original_path3 << endl;
exit(0);
}
Mat result;
Point p;
p.x = destination.size().width/2;
p.y = destination.size().height/2;
seamlessClone(source, destination, mask, p, result, 2);
Monochrome Transfer
seamlessClone(source, destination, mask, p, result, 3);
Color Change
调试颜色colorChange()
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);
if(source.empty())
{
cout << "Could not load source image " << original_path1 << endl;
exit(0);
}
if(mask.empty())
{
cout << "Could not load mask image " << original_path2 << endl;
exit(0);
}
Mat result;
colorChange(source, mask, result, 1.5, .5, .5);
Illumination change
消除高亮illuminationChange()
?alpha,beta两个参数共同决定消除高光后图像的模糊程度(范围0~2,0比较清晰,2比较模糊)
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);
if(source.empty())
{
cout << "Could not load source image " << original_path1 << endl;
exit(0);
}
if(mask.empty())
{
cout << "Could not load mask image " << original_path2 << endl;
exit(0);
}
Mat result;
illuminationChange(source, mask, result, 0.2f, 0.4f);
Texture Flattening?
纹理扁平化textureFlattening()
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);
if(source.empty())
{
cout << "Could not load source image " << original_path1 << endl;
exit(0);
}
if(mask.empty())
{
cout << "Could not load mask image " << original_path2 << endl;
exit(0);
}
Mat result;
textureFlattening(source, mask, result, 30, 45, 3);
纹理扁平化,边缘检测器选取的边缘越少(选择性越强),边缘映射就越稀疏,扁平化效果就越明显。textureFlattening()函数的使用。
?
|