Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drwnImageInPainter.h
1 /******************************************************************************
2 ** DARWIN: A FRAMEWORK FOR MACHINE LEARNING RESEARCH AND DEVELOPMENT
3 ** Distributed under the terms of the BSD license (see the LICENSE file)
4 ** Copyright (c) 2007-2015, Stephen Gould
5 ** All rights reserved.
6 **
7 ******************************************************************************
8 ** FILENAME: drwnImageInPainter.h
9 ** AUTHOR(S): Robin Liang <robin.gnail@gmail.com>
10 ** Stephen Gould <stephen.gould@anu.edu.au>
11 **
12 *****************************************************************************/
13 
14 #pragma once
15 
16 // c++ standard headers
17 #include <cstdlib>
18 #include <cstdio>
19 
20 // opencv library headers
21 #include "cv.h"
22 
23 // darwin library headers
24 #include "drwnBase.h"
25 #include "drwnIO.h"
26 #include "drwnVision.h"
27 
28 using namespace std;
29 using namespace Eigen;
30 
31 // drwnImageInPainter --------------------------------------------------------
54 
56 public:
57  static unsigned DEFAULT_RADIUS;
58  static unsigned UPDATE_STEPS;
59  static bool PIXELWISE;
60  static bool PRIORITY_FILLING;
61 
62 public:
63  unsigned patchRadius;
65  double alphaBlend;
66  bool bVisualize;
67 
68 public:
70  drwnImageInPainter(unsigned _patchRadius = DEFAULT_RADIUS, bool _bAllowFromFilled = false) :
71  patchRadius(_patchRadius), bAllowFromFilled(_bAllowFromFilled),
72  alphaBlend(0.125), bVisualize(false) {
73  // do nothing
74  }
76  virtual ~drwnImageInPainter() { /* do nothing */ }
77 
79  cv::Mat fill(const cv::Mat& image, const cv::Mat& fillMask) const {
80  return fill(image, fillMask, fillMask == 0);
81  }
83  cv::Mat fill(const cv::Mat& image, const cv::Mat& fillMask, const cv::Mat& copyMask) const {
84  return fill(image, fillMask, copyMask, fillMask);
85  }
88  cv::Mat fill(const cv::Mat& image, const cv::Mat& fillMask, const cv::Mat& copyMask,
89  const cv::Mat& ignoreMask) const;
90 
92  virtual void monitor(const cv::Mat& image, const cv::Mat& mask) const;
93 
94 protected:
96  virtual cv::Mat featurizeImage(const cv::Mat& image) const;
98  double computePixelPriority(const cv::Point& p, const cv::Mat& image, const cv::Mat& mask) const;
100  static cv::Mat extractMaskBoundary(const cv::Mat& mask);
102  static void blendMaskedImage(cv::Mat img, const cv::Mat& src, const cv::Mat& mask, double alpha);
103 };
static unsigned DEFAULT_RADIUS
default patch radius
Definition: drwnImageInPainter.h:57
Performs exemplar-based image inpainting.
Definition: drwnImageInPainter.h:55
bool bVisualize
show progress using the monitor function
Definition: drwnImageInPainter.h:66
static unsigned UPDATE_STEPS
patch match update steps between inpaints
Definition: drwnImageInPainter.h:58
bool bAllowFromFilled
allow copying from already infilled regions
Definition: drwnImageInPainter.h:64
virtual ~drwnImageInPainter()
destructor
Definition: drwnImageInPainter.h:76
static bool PIXELWISE
pixelwise update versus patch update
Definition: drwnImageInPainter.h:59
unsigned patchRadius
size of the patch (2 * radius + 1) for comparison
Definition: drwnImageInPainter.h:63
drwnImageInPainter(unsigned _patchRadius=DEFAULT_RADIUS, bool _bAllowFromFilled=false)
construct an image inpainter object
Definition: drwnImageInPainter.h:70
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
Definition: drwnImageInPainter.h:83
static bool PRIORITY_FILLING
use priority filling scheme versus onion peeling
Definition: drwnImageInPainter.h:60
double alphaBlend
alpha-blend with un-masked region
Definition: drwnImageInPainter.h:65
cv::Mat fill(const cv::Mat &image, const cv::Mat &fillMask) const
inpaint the pixels within fillMask
Definition: drwnImageInPainter.h:79