28 #include "../geometry/Geom.h"
30 #include "../image/Image.h"
31 #include "../image/ImagePyramid.h"
45 _nbOrientations = nbOrientations;
46 _bound =
cos(
M_PI / (
float)_nbOrientations);
47 for (
unsigned int i = 0; i < _nbOrientations; ++i) {
48 _directions.emplace_back(
cos((
float)i *
M_PI / (
float)_nbOrientations),
49 sin((
float)i *
M_PI / (
float)_nbOrientations));
58 memset((_imagesPyramids), 0, (_nbOrientations + 1) *
sizeof(
ImagePyramid *));
70 for (i = 0; i <= _nbOrientations; ++i) {
84 if (_imagesPyramids) {
85 for (i = 0; i <= _nbOrientations; ++i) {
86 if (_imagesPyramids[i]) {
87 delete (_imagesPyramids)[i];
90 delete[] _imagesPyramids;
91 _imagesPyramids =
nullptr;
93 if (!_mapping.empty()) {
94 for (map<unsigned int, double *>::iterator m = _mapping.begin(), mend = _mapping.end();
111 double dotp =
fabs(dir * _directions[i]);
119 return cos((
float)_nbOrientations / 2.0 *
acos(dotp));
126 map<unsigned int, double *>::iterator o = _mapping.find(
id);
127 if (o != _mapping.end()) {
130 double *res =
new double[_nbOrientations];
131 for (i = 0; i < _nbOrientations; ++i) {
135 Vec2r o2d2(o2d3.
x(), o2d3.
y());
142 for (i = 0; i < _nbOrientations; ++i) {
143 res[i] = ComputeWeight(o2d2, i);
154 return _nbOrientations + 1;
158 unsigned winner = _nbOrientations + 1;
159 for (
unsigned int i = 0; i < _nbOrientations; ++i) {
160 double w = ComputeWeight(dir, i);
171 map<unsigned int, double *>::iterator o = _mapping.find(
id);
172 if (o != _mapping.end()) {
173 double *wvalues = (*o).second;
175 unsigned winner = _nbOrientations + 1;
176 for (
unsigned i = 0; i < _nbOrientations; ++i) {
177 double w = wvalues[i];
185 return _nbOrientations + 1;
193 for (
unsigned int i = 0; i <= _nbOrientations; ++i) {
202 _imagesPyramids[i] = svm;
211 cout <<
"Warning: this steerable ViewMap level doesn't exist" << endl;
215 if ((
x < 0) || (
x >= pyramid->
width()) || (
y < 0) || (
y >= pyramid->
height())) {
223 float v = pyramid->
pixel(
x, pyramid->
height() - 1 -
y, iLevel) / 32.0f;
229 return readSteerableViewMapPixel(_nbOrientations, iLevel,
x,
y);
234 if (_imagesPyramids[0]) {
235 return _imagesPyramids[0]->getNumberOfLevels();
242 for (
unsigned int i = 0; i <= _nbOrientations; ++i) {
243 if (_imagesPyramids[i] ==
nullptr) {
244 cerr <<
"SteerableViewMap warning: orientation " << i
245 <<
" of steerable View Map whas not been computed yet" << endl;
248 int ow = _imagesPyramids[i]->width(0);
249 int oh = _imagesPyramids[i]->height(0);
252 string base(
"SteerableViewMap");
253 stringstream filename;
255 for (
int j = 0; j < _imagesPyramids[i]->getNumberOfLevels(); ++j) {
259 int rowbytes = ow * 4;
262 for (
int y = 0;
y < oh; ++
y) {
263 for (
int x = 0;
x < ow; ++
x) {
264 int c = (int)(coeff * _imagesPyramids[i]->pixel(
x,
y, j));
271 pix = (
char *)ibuf->
rect +
y * rowbytes +
x * 4;
272 pix[0] = pix[1] = pix[2] =
c;
278 filename << i <<
"-" << j <<
".png";
280 IMB_saveiff(ibuf,
const_cast<char *
>(filename.str().c_str()), 0);
283 QString base(
"SteerableViewMap");
284 for (
unsigned j = 0; j < _imagesPyramids[i]->getNumberOfLevels(); ++j) {
285 GrayImage *img = _imagesPyramids[i]->getLevel(j);
286 int ow = img->
width();
289 QImage qtmp(ow, oh, 32);
290 for (
unsigned int y = 0;
y < oh; ++
y) {
291 for (
unsigned int x = 0;
x < ow; ++
x) {
292 int c = (int)(coeff * img->
pixel(
x,
y));
297 qtmp.setPixel(
x,
y, qRgb(
c,
c,
c));
300 qtmp.save(base + QString::number(i) +
"-" + QString::number(j) +
".png",
"PNG");
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags)
Contains defines and structs used throughout the imbuf module.
Classes to define a silhouette structure.
Convenient access to the steerable ViewMap to which any element of the ViewMap belongs to.
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
Vec3r orientation2d() const
float pixel(unsigned x, unsigned y) const
virtual float pixel(int x, int y, int level=0)
virtual int height(int level=0)
virtual int width(int level=0)
float readSteerableViewMapPixel(unsigned iOrientation, int iLevel, int x, int y)
unsigned getSVMNumber(Vec2f dir)
double * AddFEdge(FEdge *iFEdge)
float readCompleteViewMapPixel(int iLevel, int x, int y)
void buildImagesPyramids(GrayImage **steerableBases, bool copy=false, unsigned iNbLevels=4, float iSigma=1.0f)
SteerableViewMap(unsigned int nbOrientations=4)
double ComputeWeight(const Vec2d &dir, unsigned iNOrientation)
unsigned int getNumberOfPyramidLevels() const
vector< Vec2d > _directions
map< unsigned int, double * > _mapping
virtual ~SteerableViewMap()
void saveSteerableViewMap() const
ImagePyramid ** _imagesPyramids
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
INLINE Rall1d< T, V, S > acos(const Rall1d< T, V, S > &x)
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
static void copy(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node)
ccl_device_inline float2 fabs(const float2 &a)