Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | List of all members
drwnImageInPainter Class Reference

Performs exemplar-based image inpainting. More...

Public Member Functions

 drwnImageInPainter (unsigned _patchRadius=DEFAULT_RADIUS, bool _bAllowFromFilled=false)
 construct an image inpainter object
 
virtual ~drwnImageInPainter ()
 destructor
 
cv::Mat fill (const cv::Mat &image, const cv::Mat &fillMask) const
 inpaint the pixels within fillMask
 
cv::Mat fill (const cv::Mat &image, const cv::Mat &fillMask, const cv::Mat &copyMask) const
 inpaint the pixels within fillMask using only pixels from copyMask
 
cv::Mat fill (const cv::Mat &image, const cv::Mat &fillMask, const cv::Mat &copyMask, const cv::Mat &ignoreMask) const
 inpaint the pixels within fillMask using only pixels from copyMask and ignoring matching against pixels in ignoreMask
 
virtual void monitor (const cv::Mat &image, const cv::Mat &mask) const
 monitor function called each iteration (can be used to show progress)
 

Public Attributes

unsigned patchRadius
 size of the patch (2 * radius + 1) for comparison
 
bool bAllowFromFilled
 allow copying from already infilled regions
 
double alphaBlend
 alpha-blend with un-masked region
 
bool bVisualize
 show progress using the monitor function
 

Static Public Attributes

static unsigned DEFAULT_RADIUS = 3
 default patch radius
 
static unsigned UPDATE_STEPS = 10
 patch match update steps between inpaints
 
static bool PIXELWISE = false
 pixelwise update versus patch update
 
static bool PRIORITY_FILLING = false
 use priority filling scheme versus onion peeling
 

Protected Member Functions

virtual cv::Mat featurizeImage (const cv::Mat &image) const
 compute pixelwise features for matching
 
double computePixelPriority (const cv::Point &p, const cv::Mat &image, const cv::Mat &mask) const
 compute pixel priority
 

Static Protected Member Functions

static cv::Mat extractMaskBoundary (const cv::Mat &mask)
 extract pixels within the mask adjacent to the boundary
 
static void blendMaskedImage (cv::Mat img, const cv::Mat &src, const cv::Mat &mask, double alpha)
 alpha-blend images on masked area
 

Detailed Description

Performs exemplar-based image inpainting.

Completes a masked part of an image with patches copied from other regions in the image. Motivated by the image completion algorithm of Criminisi et al., IEEE TIP, 2004 using the PatchMatch algorithm of Barnes et al. for finding patch candidates. An example code snippet is provided below:

cv::Mat img = cv::imread(imageFilename, CV_LOAD_IMAGE_COLOR);
DRWN_ASSERT_MSG(img.data, "could not read image from " << imageFilename);
cv::Mat mask = cv::Mat::zeros(img.rows, img.cols, CV_8UC1);
cv::rectangle(mask, cv::Point(img.cols / 4, img.rows / 4),
cv::Point(3 * img.cols / 4, 3 * img.rows / 4), cv::Scalar(0xff), -1);
drwnImageInPainter inpainter(3);
inpainter.bVisualize = true;
cv::Mat output = inpainter.fill(img, mask);
cv::imwrite(outputFilename, output);

The documentation for this class was generated from the following files: