21 #ifndef LIBMV_IMAGE_ARRAY_ND_H
22 #define LIBMV_IMAGE_ARRAY_ND_H
35 template <
typename T,
int N>
55 std::memcpy(
Data(),
b.Data(),
sizeof(
T) *
Size());
80 std::memcpy(
Data(),
b.Data(),
sizeof(
T) *
Size());
96 for (
int i =
N - 1; i > 0; --i) {
108 template <
typename D>
125 int shape[
N] = {s0, s1};
126 for (
int i = 2; i <
N; ++i) {
138 int shape[] = {s0, s1, s2};
142 template <
typename D>
146 const D* other_data = other.
Data();
147 for (
int i = 0; i <
Size(); ++i) {
148 data[i] =
T(other_data[i]);
153 for (
int i = 0; i <
Size(); ++i) {
160 for (
int i = 0; i <
Size(); ++i) {
177 for (
int i = 0; i <
N; ++i)
194 for (
int i = 0; i <
N; ++i)
228 assert(0 <= i0 && i0 <
Shape(0));
235 assert(0 <= i0 && i0 <
Shape(0));
237 assert(0 <= i2 && i2 <
Shape(2));
251 assert(0 <= i0 && i0 <
Shape(0));
263 for (
int i = 0; i <
N; ++i)
264 if (index(i) < 0 || index(i) >=
Shape(i))
279 return 0 <= i0 && i0 <
Shape(0) && 0 <=
i1 &&
i1 <
Shape(1) && 0 <= i2 &&
288 for (
int i = 0; i <
Size(); ++i) {
289 if (this->
Data()[i] != other.
Data()[i])
296 return !(*
this == other);
303 for (
int i = 0; i < res.
Size(); ++i) {
324 template <
typename T>
352 assert(0 <= i0 && i0 <
Height());
357 assert(0 <= i0 && i0 <
Height());
384 bool automatic_range_detection =
false);
390 template <
typename AArrayType,
typename BArrayType,
typename CArrayType>
395 assert(
a.Shape() ==
b.Shape());
400 typename CArrayType::Index index;
403 const typename CArrayType::Index& cShape =
c->Shape();
405 index(i) = cShape(i) - 1;
412 while (index(0) >= 0) {
413 (*c)(index) =
a(index) *
b(index);
416 index(dimension) = index(dimension) - 1;
417 while (dimension > 0 && index(dimension) < 0) {
418 index(dimension) = cShape(dimension) - 1;
419 index(dimension - 1) = index(dimension - 1) - 1;
425 template <
typename TA,
typename TB,
typename TC>
431 assert(
a.Shape(0) ==
b.Shape(0));
432 assert(
a.Shape(1) ==
b.Shape(1));
433 assert(
a.Shape(2) ==
b.Shape(2));
434 for (
int i = 0; i <
a.Shape(0); ++i) {
435 for (
int j = 0; j <
a.Shape(1); ++j) {
436 for (
int k = 0; k <
a.Shape(2); ++k) {
437 (*c)(i, j, k) = TC(
a(i, j, k) *
b(i, j, k));
443 template <
typename TA,
typename TB,
typename TC>
449 assert(
a.Shape(0) ==
b.Shape(0));
450 assert(
a.Shape(1) ==
b.Shape(1));
451 assert(
a.Shape(2) ==
b.Shape(2));
452 for (
int i = 0; i <
a.Shape(0); ++i) {
453 for (
int j = 0; j <
a.Shape(1); ++j) {
454 for (
int k = 0; k <
a.Shape(2); ++k) {
455 (*c)(i, j, k) = TC(
a(i, j, k) *
b(i, j, k));
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint i1
_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 GLsizei width
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
3D array (row, column, channel).
void Resize(int height, int width, int depth=1)
T & operator()(int i0, int i1, int i2=0)
Enable accessing with 2 indices for grayscale images.
Array3D(int height, int width, int depth=1)
Array3D(T *data, int height, int width, int depth=1)
const T & operator()(int i0, int i1, int i2=0) const
A multidimensional array class.
ArrayND(int *shape)
Create an array with the specified shape.
const T & operator()(int i0, int i1, int i2) const
3D specialization.
bool own_data_
Flag if this Array either own or reference the data.
void resize(int rows, int cols)
void Resize(const Index &new_shape)
Create an array of shape s.
const T * Data() const
Constant pointer to the first element of the array.
T * data_
Pointer to the first element of the array.
ArrayND()
Create an empty array.
const T & operator()(int i0) const
1D specialization.
ArrayND(const ArrayND< T, N > &b)
Copy constructor.
T & operator()(int i0, int i1, int i2)
3D specialization.
void ResizeLike(const ArrayND< D, N > &other)
int MemorySizeInBytes() const
Return the total amount of memory used by the array.
bool Contains(int i0, int i1) const
2D specialization.
void CopyFrom(const ArrayND< D, N > &other)
~ArrayND()
Destructor deletes pixel data.
ArrayND(T *data, int s0, int s1, int s2)
void Resize(const int *new_shape_array)
Resizes the array to shape s. All data is lost.
const T & operator()(int i0, int i1) const
2D specialization.
void Resize(int s0, int s1)
Resize a 2D array to shape (s0,s1).
ArrayND & operator=(const ArrayND< T, N > &b)
Assignation copies pixel data.
void Resize(int s0, int s1, int s2)
Resize a 3D array to shape (s0,s1,s2).
T & operator()(int i0)
1D specialization.
const Index & Shape() const
Return a tuple containing the length of each axis.
void Resize(int s0)
Resize a 1D array to length s0.
Tuple< int, N > Index
Type for the multidimensional indices.
const T & operator()(const Index &index) const
Return a constant reference to the element at position index.
T & operator()(const Index &index)
Return a reference to the element at position index.
const Index & Strides() const
int Shape(int axis) const
Return the length of an axis.
ArrayND(int s0, int s1, int s2)
bool operator==(const ArrayND< T, N > &other) const
bool operator!=(const ArrayND< T, N > &other) const
ArrayND< T, N > operator*(const ArrayND< T, N > &other) const
T & operator()(int i0, int i1)
2D specialization.
const Index & Shapes() const
bool Contains(const Index &index) const
True if index is inside array.
int Offset(const Index &index) const
Distance between the first element and the element at position index.
int Offset(int i0, int i1, int i2) const
3D specialization.
int Stride(int axis) const
Return the distance between neighboring elements along axis.
bool Contains(int i0) const
1D specialization.
int Size() const
Return the number of elements of the array.
bool Contains(int i0, int i1, int i2) const
3D specialization.
Index strides_
How to jump to neighbors in each dimension.
int Offset(int i0, int i1) const
2D specialization.
int Offset(int i0) const
1D specialization.
T * Data()
Pointer to the first element of the array.
ArrayND(const Index &shape)
Create an array with the specified shape.
Index shape_
The number of element in each dimension.
void Reset(const Tuple< D, N > &b)
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
ccl_global KernelShaderEvalInput * input
void SplitChannels(const Array3Df &input, Array3Df *channel0, Array3Df *channel1, Array3Df *channel2)
void ByteArrayToScaledFloatArray(const Array3Du &byte_array, Array3Df *float_array)
Convert a byte array into a float array by dividing values by 255.
Array3D< unsigned char > Array3Du
void PrintArray(const Array3Df &array)
Array3D< unsigned int > Array3Dui
Array3D< float > Array3Df
Array3D< short > Array3Ds
void FloatArrayToScaledByteArray(const Array3Df &float_array, Array3Du *byte_array, bool automatic_range_detection)
void MultiplyElements(const AArrayType &a, const BArrayType &b, CArrayType *c)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)