Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drwnPatchMatchUtils.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: drwnPatchMatchUtils.h
9 ** AUTHOR(S): Stephen Gould <stephen.gould@anu.edu.au>
10 **
11 *****************************************************************************/
12 
13 #pragma once
14 
15 #include <cstdlib>
16 #include <cassert>
17 #include <set>
18 
19 #include "drwnBase.h"
20 #include "drwnIO.h"
21 #include "drwnVision.h"
22 
23 #include "drwnPatchMatch.h"
24 
25 using namespace std;
26 
27 // drwnPatchMatchUtils -------------------------------------------------------
28 
29 namespace drwnPatchMatchUtils {
30 
32  inline cv::Point transformPixel(const cv::Point& srcPixel,
33  const cv::Size& srcSize, const cv::Size& dstSize)
34  {
35  return cv::Point(srcPixel.x * dstSize.width / srcSize.width,
36  srcPixel.y * dstSize.height / dstSize.height);
37  }
38 
40  inline cv::Rect transformRect(const cv::Rect& srcRect,
41  const cv::Size& srcSize, const cv::Size& dstSize)
42  {
43  cv::Rect dstRect;
44 
45  dstRect.x = srcRect.x * dstSize.width / srcSize.width;
46  dstRect.y = srcRect.y * dstSize.height / srcSize.height;
47  dstRect.width = srcRect.width * dstSize.width / srcSize.width;
48  dstRect.height = srcRect.height * dstSize.height / srcSize.height;
49 
50  return dstRect;
51  }
52 
54  void loadLabels(const set<string>& baseNames, map<string, MatrixXi>& labels);
55 
57  vector<cv::Point> sortPixelsByVariance(const cv::Mat& img, const cv::Size& patchSize);
58 
60  size_t countMatchablePixels(const drwnPatchMatchGraph& graph);
61 
63  double overlap(const drwnPatchMatchEdgeList& edgesA,
64  const drwnPatchMatchEdgeList& edgesB);
65 
67  bool isValidNode(const drwnPatchMatchGraph& graph, const drwnPatchMatchNode& node);
68 };
Represents a node in the drwnPatchMatchGraph.
Definition: drwnPatchMatch.h:66
Each image maintains a W-by-H-by-K array of match records referencing the (approximate) best K matche...
Definition: drwnPatchMatch.h:323