OpenCV 4.10.0-dev
Open Source Computer Vision
Loading...
Searching...
No Matches

Detailed Description

Useful links:

https://www.learnopencv.com/seamless-cloning-using-opencv-python-cpp

Enumerations

enum  cv::SeamlessCloneFlags {
  cv::NORMAL_CLONE = 1 ,
  cv::MIXED_CLONE = 2 ,
  cv::MONOCHROME_TRANSFER = 3 ,
  cv::NORMAL_CLONE_WIDE = 9 ,
  cv::MIXED_CLONE_WIDE = 10 ,
  cv::MONOCHROME_TRANSFER_WIDE = 11
}
 Flags for the seamlessClone algorithm. More...
 

Functions

void cv::colorChange (InputArray src, InputArray mask, OutputArray dst, float red_mul=1.0f, float green_mul=1.0f, float blue_mul=1.0f)
 Given an original color image, two differently colored versions of this image can be mixed seamlessly.
 
void cv::illuminationChange (InputArray src, InputArray mask, OutputArray dst, float alpha=0.2f, float beta=0.4f)
 Applying an appropriate non-linear transformation to the gradient field inside the selection and then integrating back with a Poisson solver, modifies locally the apparent illumination of an image.
 
void cv::seamlessClone (InputArray src, InputArray dst, InputArray mask, Point p, OutputArray blend, int flags)
 Performs seamless cloning to blend a region from a source image into a destination image. This function is designed for local image editing, allowing changes restricted to a region (manually selected as the ROI) to be applied effortlessly and seamlessly. These changes can range from slight distortions to complete replacement by novel content [215].
 
void cv::textureFlattening (InputArray src, InputArray mask, OutputArray dst, float low_threshold=30, float high_threshold=45, int kernel_size=3)
 By retaining only the gradients at edge locations, before integrating with the Poisson solver, one washes out the texture of the selected region, giving its contents a flat aspect. Here Canny Edge Detector is used.
 

Enumeration Type Documentation

◆ SeamlessCloneFlags

#include <opencv2/photo.hpp>

Flags for the seamlessClone algorithm.

Enumerator
NORMAL_CLONE 
Python: cv.NORMAL_CLONE

Normal seamless cloning. This method is ideal for inserting objects with complex outlines into a new background. It preserves the original appearance and lighting of the inserted object, ensuring a natural blend.

MIXED_CLONE 
Python: cv.MIXED_CLONE

Mixed seamless cloning. This method addresses cases where simple color-based selection or alpha masking is time-consuming and may result in undesirable halos. By combining structure from the source and texture from the destination, mixed seamless cloning is highly effective, even with loosely defined selections.

MONOCHROME_TRANSFER 
Python: cv.MONOCHROME_TRANSFER

Monochrome transfer cloning. This method allows users to replace specific features of an object, such as grayscale textures or patterns, with alternative features. It is particularly useful for artistic effects or targeted object modifications.

NORMAL_CLONE_WIDE 
Python: cv.NORMAL_CLONE_WIDE

Enhanced normal seamless cloning. Similar to NORMAL_CLONE, but with an advanced approach to ROI (Region of Interest) calculation. This mode processes a larger source region by considering the entire mask area instead of only the bounding rectangle of non-zero pixels.

MIXED_CLONE_WIDE 
Python: cv.MIXED_CLONE_WIDE

Enhanced mixed seamless cloning. Similar to MIXED_CLONE, but with an advanced approach to ROI (Region of Interest) calculation. This mode processes a larger source region by considering the entire mask area instead of only the bounding rectangle of non-zero pixels.

MONOCHROME_TRANSFER_WIDE 
Python: cv.MONOCHROME_TRANSFER_WIDE

Enhanced monochrome transfer cloning. Similar to MONOCHROME_TRANSFER, but with an advanced approach to ROI (Region of Interest) calculation. This mode processes a larger source region by considering the entire mask area instead of only the bounding rectangle of non-zero pixels.

Function Documentation

◆ colorChange()

void cv::colorChange ( InputArray src,
InputArray mask,
OutputArray dst,
float red_mul = 1.0f,
float green_mul = 1.0f,
float blue_mul = 1.0f )
Python:
cv.colorChange(src, mask[, dst[, red_mul[, green_mul[, blue_mul]]]]) -> dst

#include <opencv2/photo.hpp>

Given an original color image, two differently colored versions of this image can be mixed seamlessly.

Parameters
srcInput 8-bit 3-channel image.
maskInput 8-bit 1 or 3-channel image.
dstOutput image with the same size and type as src .
red_mulR-channel multiply factor.
green_mulG-channel multiply factor.
blue_mulB-channel multiply factor.

Multiplication factor is between .5 to 2.5.

◆ illuminationChange()

void cv::illuminationChange ( InputArray src,
InputArray mask,
OutputArray dst,
float alpha = 0.2f,
float beta = 0.4f )
Python:
cv.illuminationChange(src, mask[, dst[, alpha[, beta]]]) -> dst

#include <opencv2/photo.hpp>

Applying an appropriate non-linear transformation to the gradient field inside the selection and then integrating back with a Poisson solver, modifies locally the apparent illumination of an image.

Parameters
srcInput 8-bit 3-channel image.
maskInput 8-bit 1 or 3-channel image.
dstOutput image with the same size and type as src.
alphaValue ranges between 0-2.
betaValue ranges between 0-2.

This is useful to highlight under-exposed foreground objects or to reduce specular reflections.

◆ seamlessClone()

void cv::seamlessClone ( InputArray src,
InputArray dst,
InputArray mask,
Point p,
OutputArray blend,
int flags )
Python:
cv.seamlessClone(src, dst, mask, p, flags[, blend]) -> blend

#include <opencv2/photo.hpp>

Performs seamless cloning to blend a region from a source image into a destination image. This function is designed for local image editing, allowing changes restricted to a region (manually selected as the ROI) to be applied effortlessly and seamlessly. These changes can range from slight distortions to complete replacement by novel content [215].

Parameters
srcThe source image (8-bit 3-channel), from which a region will be blended into the destination.
dstThe destination image (8-bit 3-channel), where the src image will be blended.
maskA binary mask (8-bit, 1, 3, or 4-channel) specifying the region in the source image to blend. Non-zero pixels indicate the region to be blended. If an empty Mat is provided, a mask with all non-zero pixels is created internally.
pThe point where the center of the src image is placed in the dst image.
blendThe output image that stores the result of the seamless cloning. It has the same size and type as dst.
flagsFlags that control the type of cloning method, can take values of cv::SeamlessCloneFlags.

◆ textureFlattening()

void cv::textureFlattening ( InputArray src,
InputArray mask,
OutputArray dst,
float low_threshold = 30,
float high_threshold = 45,
int kernel_size = 3 )
Python:
cv.textureFlattening(src, mask[, dst[, low_threshold[, high_threshold[, kernel_size]]]]) -> dst

#include <opencv2/photo.hpp>

By retaining only the gradients at edge locations, before integrating with the Poisson solver, one washes out the texture of the selected region, giving its contents a flat aspect. Here Canny Edge Detector is used.

Parameters
srcInput 8-bit 3-channel image.
maskInput 8-bit 1 or 3-channel image.
dstOutput image with the same size and type as src.
low_thresholdRange from 0 to 100.
high_thresholdValue > 100.
kernel_sizeThe size of the Sobel kernel to be used.
Note
The algorithm assumes that the color of the source image is close to that of the destination. This assumption means that when the colors don't match, the source image color gets tinted toward the color of the destination image.