Image Utilities (IU)
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Groups Pages
Data Structures | Public Types | Public Member Functions | Protected Attributes
iu::ImageGpu< PixelType, Allocator > Class Template Reference

Device 2D image class (pitched memory). More...

#include <image_gpu.h>

Inheritance diagram for iu::ImageGpu< PixelType, Allocator >:
iu::Image

Data Structures

struct  KernelData
 Struct pointer KernelData that can be used in CUDA kernels. More...
 

Public Types

typedef PixelType pixel_type
 

Public Member Functions

 ImageGpu ()
 
virtual ~ImageGpu ()
 
 ImageGpu (unsigned int _width, unsigned int _height)
 
 ImageGpu (const iu::Size< 2 > &size)
 
 ImageGpu (PixelType *_data, unsigned int _width, unsigned int _height, size_t _pitch, bool ext_data_pointer=false)
 
PixelType getPixel (unsigned int x, unsigned int y)
 
virtual size_t bytes () const
 
virtual size_t pitch () const
 
virtual size_t stride () const
 
virtual unsigned int bitDepth () const
 
virtual bool onDevice () const
 
PixelType * data (int ox=0, int oy=0)
 
const PixelType * data (int ox=0, int oy=0) const
 
thrust::device_ptr< PixelType > begin (void)
 
thrust::device_ptr< PixelType > end (void)
 
void prepareTexture (cudaTextureReadMode readMode=cudaReadModeElementType, cudaTextureFilterMode filterMode=cudaFilterModeLinear, cudaTextureAddressMode addressMode=cudaAddressModeClamp)
 
cudaTextureObject_t getTexture ()
 
cudaTextureObject_t getTexture () const
 
ndarray_ref< PixelType, 2 > ref () const
 
 ImageGpu (const ndarray_ref< PixelType, 2 > &x)
 
- Public Member Functions inherited from iu::Image
 Image ()
 
virtual ~Image ()
 
 Image (unsigned int width, unsigned int height)
 
 Image (const iu::Size< 2 > &size)
 
iu::Size< 2 > size () const
 
unsigned int width () const
 
unsigned int height () const
 
bool sameType (const Image &from)
 
size_t numel () const
 

Protected Attributes

PixelType * data_
 
size_t pitch_
 
bool ext_data_pointer_
 
cudaTextureObject_t texture_
 
- Protected Attributes inherited from iu::Image
iu::Size< 2 > size_
 

Detailed Description

template<typename PixelType, class Allocator>
class iu::ImageGpu< PixelType, Allocator >

Device 2D image class (pitched memory).

Member Typedef Documentation

template<typename PixelType, class Allocator>
typedef PixelType iu::ImageGpu< PixelType, Allocator >::pixel_type

Define the current pixel type.

Constructor & Destructor Documentation

template<typename PixelType, class Allocator>
iu::ImageGpu< PixelType, Allocator >::ImageGpu ( )
inline

Constructor.

template<typename PixelType, class Allocator>
virtual iu::ImageGpu< PixelType, Allocator >::~ImageGpu ( )
inlinevirtual

Destructor.

template<typename PixelType, class Allocator>
iu::ImageGpu< PixelType, Allocator >::ImageGpu ( unsigned int  _width,
unsigned int  _height 
)
inline

Special constructor.

Parameters
_widthWidth of the Image
_heightHeight of the Image
template<typename PixelType, class Allocator>
iu::ImageGpu< PixelType, Allocator >::ImageGpu ( const iu::Size< 2 > &  size)
inline

Special constructor.

Parameters
sizeSize of the Image
template<typename PixelType, class Allocator>
iu::ImageGpu< PixelType, Allocator >::ImageGpu ( PixelType *  _data,
unsigned int  _width,
unsigned int  _height,
size_t  _pitch,
bool  ext_data_pointer = false 
)
inline

Special constructor.

Parameters
_dataDevice data pointer
_widthWidth of the Image
_heightHeight of the Image
_pitchDistance in bytes between starts of consecutive rows.
ext_data_pointerUse external data pointer as internal data pointer
template<typename PixelType, class Allocator>
iu::ImageGpu< PixelType, Allocator >::ImageGpu ( const ndarray_ref< PixelType, 2 > &  x)

construct from ndarray_ref – include ndarray/ndarray_iu.h

Member Function Documentation

template<typename PixelType, class Allocator>
thrust::device_ptr<PixelType> iu::ImageGpu< PixelType, Allocator >::begin ( void  )
inline

Returns a thrust pointer that can be used in custom operators

Returns
Thrust pointer of the begin of the device memory
template<typename PixelType, class Allocator>
virtual unsigned int iu::ImageGpu< PixelType, Allocator >::bitDepth ( ) const
inlinevirtual

Returns the bit depth of the data pointer.

Reimplemented from iu::Image.

template<typename PixelType, class Allocator>
virtual size_t iu::ImageGpu< PixelType, Allocator >::bytes ( ) const
inlinevirtual

Returns the total amount of bytes saved in the data buffer.

Reimplemented from iu::Image.

template<typename PixelType, class Allocator>
PixelType* iu::ImageGpu< PixelType, Allocator >::data ( int  ox = 0,
int  oy = 0 
)
inline

Returns a pointer to the pixel data. The pointer can be offset to position (ox/oy).

Parameters
oxHorizontal offset of the pointer array.
oyVertical offset of the pointer array.
Returns
Pointer to the pixel array.
template<typename PixelType, class Allocator>
const PixelType* iu::ImageGpu< PixelType, Allocator >::data ( int  ox = 0,
int  oy = 0 
) const
inline

Returns a const pointer to the pixel data. The pointer can be offset to position (ox/oy).

Parameters
oxHorizontal offset of the pointer array.
oyVertical offset of the pointer array.
Returns
Const pointer to the pixel array.
template<typename PixelType, class Allocator>
thrust::device_ptr<PixelType> iu::ImageGpu< PixelType, Allocator >::end ( void  )
inline

Returns a thrust pointer that can be used in custom operators

Returns
Thrust pointer of the end of the device memory
template<typename PixelType, class Allocator>
PixelType iu::ImageGpu< PixelType, Allocator >::getPixel ( unsigned int  x,
unsigned int  y 
)
inline

Get Pixel value at position x,y.

template<typename PixelType, class Allocator>
cudaTextureObject_t iu::ImageGpu< PixelType, Allocator >::getTexture ( )
inline

Get CUDA texture object

template<typename PixelType, class Allocator>
cudaTextureObject_t iu::ImageGpu< PixelType, Allocator >::getTexture ( ) const
inline

Get CUDA texture object

Note
Use case: ImageGPU is passed as const into a function and the method getTexture() is used as a parameter in a cuda kernel call. In that case the user has to explicitly call prepareTexture() in advance such that the texture object exists, because an implicit call to prepareTexture() here would obviously violate method constness.
template<typename PixelType, class Allocator>
virtual bool iu::ImageGpu< PixelType, Allocator >::onDevice ( ) const
inlinevirtual

Returns flag if the image data resides on the device/GPU (TRUE) or host/GPU (FALSE)

Reimplemented from iu::Image.

template<typename PixelType, class Allocator>
virtual size_t iu::ImageGpu< PixelType, Allocator >::pitch ( ) const
inlinevirtual

Returns the distance in bytes between starts of consecutive rows.

Reimplemented from iu::Image.

template<typename PixelType, class Allocator>
void iu::ImageGpu< PixelType, Allocator >::prepareTexture ( cudaTextureReadMode  readMode = cudaReadModeElementType,
cudaTextureFilterMode  filterMode = cudaFilterModeLinear,
cudaTextureAddressMode  addressMode = cudaAddressModeClamp 
)
inline

Prepare CUDA texture

Parameters
readModeCUDA texture read mode
filterModeCUDA texture filter mode
addressModeCUDA texture address mode
template<typename PixelType, class Allocator>
ndarray_ref<PixelType,2> iu::ImageGpu< PixelType, Allocator >::ref ( ) const

convert to ndarray_ref – include ndarray/ndarray_iu.h

template<typename PixelType, class Allocator>
virtual size_t iu::ImageGpu< PixelType, Allocator >::stride ( ) const
inlinevirtual

Returns the distance in pixels between starts of consecutive rows.

Todo:
: returned value is invalid if sizeof(PixelType) == 3, e.g. for *_C3 images. Use pitch in this case to calculate memory addresses by hand.

Reimplemented from iu::Image.

Field Documentation

template<typename PixelType, class Allocator>
PixelType* iu::ImageGpu< PixelType, Allocator >::data_
protected

Pointer to device buffer.

template<typename PixelType, class Allocator>
bool iu::ImageGpu< PixelType, Allocator >::ext_data_pointer_
protected

Flag if data pointer is handled outside the image class.

template<typename PixelType, class Allocator>
size_t iu::ImageGpu< PixelType, Allocator >::pitch_
protected

Distance in bytes between starts of consecutive rows.

template<typename PixelType, class Allocator>
cudaTextureObject_t iu::ImageGpu< PixelType, Allocator >::texture_
protected

CUDA texture object


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