LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Public Attributes | List of all members
lsst::afw::gpu::detail::GpuBuffer2D< PixelT > Class Template Reference

Class for representing an image or 2D array in general) More...

#include <GpuBuffer2D.h>

Public Types

typedef
lsst::afw::image::Image
< PixelT > 
ImageT
 

Public Member Functions

 GpuBuffer2D ()
 
 GpuBuffer2D (const GpuBuffer2D &x)
 
void Init (const ImageT &image)
 
void Init (int width, int height)
 
 GpuBuffer2D (const ImageT &image)
 
 GpuBuffer2D (int width, int height)
 
 ~GpuBuffer2D ()
 
int Size () const
 
PixelT * GetImgLinePtr (int y)
 
const PixelT * GetImgLinePtr (int y) const
 
PixelT & Pixel (int x, int y)
 
const PixelT & Pixel (int x, int y) const
 
void CopyFromBuffer (const GpuBuffer2D< PixelT > &buffer, int startX, int startY)
 
void CopyToImage (ImageT outImage, int startX, int startY)
 

Public Attributes

PixelT * img
 
int width
 
int height
 

Detailed Description

template<typename PixelT>
class lsst::afw::gpu::detail::GpuBuffer2D< PixelT >

Class for representing an image or 2D array in general)

Allocates width*height pixels memory for image. Automatically allocates and releases memory for buffer (this class is the owner of the buffer).

Can be uninitialized. Only uninitialized image buffer can be copied. For copying initialized image buffers, use CopyFromBuffer member function. Provides access to pixels and lines in image Can be copied to and from the Image.

Definition at line 54 of file GpuBuffer2D.h.

Member Typedef Documentation

template<typename PixelT>
typedef lsst::afw::image::Image<PixelT> lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::ImageT

Definition at line 57 of file GpuBuffer2D.h.

Constructor & Destructor Documentation

template<typename PixelT>
lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::GpuBuffer2D ( )
inline

Definition at line 63 of file GpuBuffer2D.h.

63 : img(NULL) {}
template<typename PixelT>
lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::GpuBuffer2D ( const GpuBuffer2D< PixelT > &  x)
inline

Definition at line 66 of file GpuBuffer2D.h.

66  {
67  assert(x.img == NULL);
68  img = NULL;
69  };
double x
template<typename PixelT>
lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::GpuBuffer2D ( const ImageT image)
inline

Definition at line 105 of file GpuBuffer2D.h.

105  {
106  img = NULL;
107  Init(image);
108  }
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
void Init(const ImageT &image)
Definition: GpuBuffer2D.h:71
template<typename PixelT>
lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::GpuBuffer2D ( int  width,
int  height 
)
inline

Definition at line 110 of file GpuBuffer2D.h.

template<typename PixelT>
lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::~GpuBuffer2D ( )
inline

Definition at line 115 of file GpuBuffer2D.h.

115  {
116  delete[] img;
117  }

Member Function Documentation

template<typename PixelT>
void lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::CopyFromBuffer ( const GpuBuffer2D< PixelT > &  buffer,
int  startX,
int  startY 
)
inline

Definition at line 146 of file GpuBuffer2D.h.

147  {
148  assert(img != NULL);
149  for (int i = 0; i < height; ++i) {
150  PixelT* inPtr = startX + buffer.GetImgLinePtr(i + startY);
151  PixelT* outPtr = buffer.GetImgLinePtr(i);
152  for (int j = 0; j < width; j++) {
153  *outPtr = *inPtr;
154  inPtr++;
155  outPtr++;
156  }
157  }
158  }
template<typename PixelT>
void lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::CopyToImage ( ImageT  outImage,
int  startX,
int  startY 
)
inline

Definition at line 160 of file GpuBuffer2D.h.

161  {
162  assert(img != NULL);
163  for (int i = 0; i < height; ++i) {
164  PixelT* outPtrImg = &img[width*i];
165 
166  for (typename ImageT::x_iterator cnvPtr = outImage.x_at(startX, i + startY),
167  cnvEnd = cnvPtr + width; cnvPtr != cnvEnd; ++cnvPtr ) {
168  *cnvPtr = *outPtrImg;
169  ++outPtrImg;
170  }
171  }
172  }
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: Image.h:151
template<typename PixelT>
PixelT* lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::GetImgLinePtr ( int  y)
inline

Definition at line 123 of file GpuBuffer2D.h.

123  {
124  assert(img != NULL);
125  assert(y >= 0 && y < height);
126  return &img[width*y];
127  }
int y
template<typename PixelT>
const PixelT* lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::GetImgLinePtr ( int  y) const
inline

Definition at line 128 of file GpuBuffer2D.h.

128  {
129  assert(img != NULL);
130  assert(y >= 0 && y < height);
131  return &img[width*y];
132  }
int y
template<typename PixelT>
void lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::Init ( const ImageT image)
inline

Definition at line 71 of file GpuBuffer2D.h.

72  {
73  assert(img == NULL);
74  this->width = image.getWidth();
75  this->height = image.getHeight();
76  try {
77  img = new PixelT [width*height];
78  } catch(...) {
79  throw LSST_EXCEPT(pexExcept::MemoryError, "GpuBuffer2D:Init - not enough memory");
80  }
81 
82  //copy input image data to buffer
83  for (int i = 0; i < height; ++i) {
84  typename ImageT::x_iterator inPtr = image.x_at(0, i);
85  PixelT* imageDataPtr = img + i * width;
86 
87  for (typename ImageT::x_iterator cnvEnd = inPtr + width; inPtr != cnvEnd;
88  ++inPtr, ++imageDataPtr) {
89  *imageDataPtr = *inPtr;
90  }
91  }
92  }
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
Definition: Image.h:151
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename PixelT>
void lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::Init ( int  width,
int  height 
)
inline

Definition at line 94 of file GpuBuffer2D.h.

94  {
95  assert(img == NULL);
96  this->width = width;
97  this->height = height;
98  try {
99  img = new PixelT [width*height];
100  } catch(...) {
101  throw LSST_EXCEPT(pexExcept::MemoryError, "GpuBuffer2D:Init - not enough memory");
102  }
103  }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename PixelT>
PixelT& lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::Pixel ( int  x,
int  y 
)
inline

Definition at line 133 of file GpuBuffer2D.h.

133  {
134  assert(img != NULL);
135  assert(x >= 0 && x < width);
136  assert(y >= 0 && y < height);
137  return img[x+ y*width];
138  }
int y
double x
template<typename PixelT>
const PixelT& lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::Pixel ( int  x,
int  y 
) const
inline

Definition at line 139 of file GpuBuffer2D.h.

139  {
140  assert(img != NULL);
141  assert(x >= 0 && x < width);
142  assert(y >= 0 && y < height);
143  return img[x+ y*width];
144  }
int y
double x
template<typename PixelT>
int lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::Size ( ) const
inline

Definition at line 119 of file GpuBuffer2D.h.

Member Data Documentation

template<typename PixelT>
int lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::height

Definition at line 61 of file GpuBuffer2D.h.

template<typename PixelT>
PixelT* lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::img

Definition at line 59 of file GpuBuffer2D.h.

template<typename PixelT>
int lsst::afw::gpu::detail::GpuBuffer2D< PixelT >::width

Definition at line 60 of file GpuBuffer2D.h.


The documentation for this class was generated from the following file: