OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
| 3 * |
| 4 * This program is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU General Public License |
| 6 * as published by the Free Software Foundation; either version 2 |
| 7 * of the License, or (at your option) any later version. |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software Foundation, |
| 16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 * |
| 18 * The Original Code is Copyright (C) 2010 Blender Foundation. |
| 19 * All rights reserved. |
| 20 * |
| 21 * The Original Code is: all of this file. |
| 22 * |
| 23 * Contributor(s): none yet. |
| 24 * |
| 25 * ***** END GPL LICENSE BLOCK ***** |
| 26 */ |
| 27 |
| 28 #ifndef __FREESTYLE_STEERABLE_VIEW_MAP_H__ |
| 29 #define __FREESTYLE_STEERABLE_VIEW_MAP_H__ |
| 30 |
| 31 /** \file blender/freestyle/intern/view_map/SteerbaleViewMap.h |
| 32 * \ingroup freestyle |
| 33 * \brief Convenient access to the steerable ViewMap to which any element of th
e ViewMap belongs to. |
| 34 * \author Stephane Grabli |
| 35 * \date 01/07/2003 |
| 36 */ |
| 37 |
| 38 #include <map> |
| 39 |
| 40 #include "../geometry/Geom.h" |
| 41 |
| 42 #include "../system/FreestyleConfig.h" |
| 43 |
| 44 using namespace Geometry; |
| 45 |
| 46 using namespace std; |
| 47 |
| 48 class FEdge; |
| 49 class ImagePyramid; |
| 50 class GrayImage; |
| 51 |
| 52 /*! This class checks for every FEdge in which steerable it belongs and stores t
he mapping allowing to retrieve· |
| 53 * this information from the FEdge Id. |
| 54 */ |
| 55 class LIB_VIEW_MAP_EXPORT SteerableViewMap |
| 56 { |
| 57 protected: |
| 58 // for each vector the list of nbOrientations weigths corresponding to i
ts contributions |
| 59 // to the nbOrientations directional maps |
| 60 map<unsigned int, double*> _mapping; |
| 61 unsigned _nbOrientations; |
| 62 ImagePyramid **_imagesPyramids; // the pyramids of images storing the di
fferent SVM |
| 63 |
| 64 // internal |
| 65 double _bound; // cos(Pi/N) |
| 66 vector<Vec2d> _directions; |
| 67 |
| 68 public: |
| 69 SteerableViewMap(unsigned int nbOrientations = 4); |
| 70 SteerableViewMap(const SteerableViewMap& iBrother); |
| 71 virtual ~SteerableViewMap(); |
| 72 |
| 73 /*! Resets everything */ |
| 74 virtual void Reset(); |
| 75 |
| 76 /*! Adds a FEdge to steerable VM. |
| 77 * Returns the nbOrientations weigths corresponding to the FEdge contri
butions to the nbOrientations |
| 78 * directional maps. |
| 79 */ |
| 80 double *AddFEdge(FEdge *iFEdge); |
| 81 |
| 82 /*! Compute the weight of direction dir for orientation iNOrientation */ |
| 83 double ComputeWeight(const Vec2d& dir, unsigned iNOrientation); |
| 84 |
| 85 /*! Returns the number of the SVM to which a direction belongs to. |
| 86 * \param dir |
| 87 * The direction |
| 88 */ |
| 89 unsigned getSVMNumber(const Vec2f& dir); |
| 90 |
| 91 /*! Returns the number of the SVM to which a FEdge belongs most. |
| 92 * \param id |
| 93 * The First element of the Id struct of the FEdge we're intersted in
. |
| 94 */ |
| 95 unsigned getSVMNumber(unsigned id); |
| 96 |
| 97 /*! Builds _nbOrientations+1 pyramids of images from the _nbOrientations
+1 base images of the steerable viewmap. |
| 98 * \param steerableBases |
| 99 * The _nbOrientations+1 images constituing the basis for the steerab
le pyramid. |
| 100 * \param copy |
| 101 * If false, the data is not duplicated, and Canvas deals with the me
mory management of these |
| 102 * _nbOrientations+1 images. If true, data is copied, and it's up to
the caller to delete the images. |
| 103 * \params iNbLevels |
| 104 * The number of levels desired for each pyramid. |
| 105 * If iNbLevels == 0, the complete pyramid is built. |
| 106 * \param iSigma |
| 107 * The sigma that will be used for the gaussian blur |
| 108 */ |
| 109 void buildImagesPyramids(GrayImage **steerableBases, bool copy = false,
unsigned iNbLevels = 4, |
| 110 float iSigma = 1.0f); |
| 111 |
| 112 /*! Reads a pixel value in one of the VewMap density steerable pyramids. |
| 113 * Returns a value between 0 and 1. |
| 114 * \param iOrientation |
| 115 * the number telling which orientation we need to check. |
| 116 * There are _nbOrientations+1 oriented ViewMaps: |
| 117 * 0 -> the ViewMap containing every horizontal lines |
| 118 * 1 -> the ViewMap containing every lines whose orientation is aroun
d PI/4 |
| 119 * 2 -> the ViewMap containing every vertical lines |
| 120 * 3 -> the ViewMap containing every lines whose orientation is aroun
d 3PI/4 |
| 121 * 4 -> the complete ViewMap |
| 122 * \param iLevel |
| 123 * The level of the pyramid we want to read |
| 124 * \param x |
| 125 * The abscissa of the desired pixel specified in level0 coordinate s
ystem. The origin is the lower left corner. |
| 126 * \param y |
| 127 * The ordinate of the desired pixel specified in level0 coordinate s
ystem. The origin is the lower left corner. |
| 128 */ |
| 129 float readSteerableViewMapPixel(unsigned iOrientation, int iLevel, int x
, int y); |
| 130 |
| 131 /*! Reads a pixel in the one of the level of the pyramid containing the
images of the complete ViewMap. |
| 132 * Returns a value between 0 and 1. |
| 133 * Equivalent to : readSteerableViewMapPixel(nbOrientations, x, y) |
| 134 */ |
| 135 float readCompleteViewMapPixel(int iLevel, int x, int y); |
| 136 |
| 137 /*! Returns the number of levels in the pyramids */ |
| 138 unsigned int getNumberOfPyramidLevels() const; |
| 139 |
| 140 /*! Returns the number of orientations */ |
| 141 unsigned int getNumberOfOrientations() const |
| 142 { |
| 143 return _nbOrientations; |
| 144 } |
| 145 |
| 146 /*! for debug purposes */ |
| 147 void saveSteerableViewMap() const; |
| 148 |
| 149 protected: |
| 150 void Clear(); |
| 151 void Build(); |
| 152 }; |
| 153 |
| 154 #endif // __FREESTYLE_STEERABLE_VIEW_MAP_H__ |
OLD | NEW |