API
 
Loading...
Searching...
No Matches
pixaccess.hpp
Go to the documentation of this file.
1
2
3///\todo document this file
4
5#ifndef pixaccess_h
6#define pixaccess_h
7
8#include "ImageStruct.hpp"
9
10///Function to cast the data type to float.
11/** Accesses the imdata pointer at linear position idx, and then casts the result to float.
12 *
13 * \returns the value of the image at linear position idx cast to float
14 *
15 * \tparam dataT the type of the image data.
16 */
17template<typename returnT, typename dataT>
18returnT getPix( void *imdata, ///< [in] Pointer to the image data
19 size_t idx ///< [in] Linear position of the pixel in the imdata
20 )
21{
22 return (returnT) ((dataT*) imdata)[idx];
23}
24
25///Get the function pointer for getPix for the type
26template<typename returnT, int imageStructDataT>
27returnT (*getPixPointer())(void*, size_t)
28{
29 return &getPix<returnT, typename imageStructDataType<imageStructDataT>::type>;
30}
31
32template<typename returnT>
33returnT (*getPixPointer(int imageStructDataT))(void*, size_t)
34{
35 switch(imageStructDataT)
36 {
38 return getPixPointer<returnT, IMAGESTRUCT_UINT8>();
40 return getPixPointer<returnT, IMAGESTRUCT_INT8>();
42 return getPixPointer<returnT, IMAGESTRUCT_UINT16>();
43 break;
45 return getPixPointer<returnT, IMAGESTRUCT_INT16>();
47 return getPixPointer<returnT, IMAGESTRUCT_UINT32>();
49 return getPixPointer<returnT, IMAGESTRUCT_INT32>();
51 return getPixPointer<returnT, IMAGESTRUCT_UINT64>();
53 return getPixPointer<returnT, IMAGESTRUCT_INT64>();
55 return getPixPointer<returnT, IMAGESTRUCT_FLOAT>();
57 return getPixPointer<returnT, IMAGESTRUCT_DOUBLE>();
58 default:
59 std::cerr << "getPixPointer: Unknown or unsupported data type. " << __FILE__ << " " << __LINE__ << "\n";
60 return nullptr;
61 }
62}
63#endif
64
65
66
#define IMAGESTRUCT_UINT16
#define IMAGESTRUCT_INT64
#define IMAGESTRUCT_FLOAT
#define IMAGESTRUCT_INT32
#define IMAGESTRUCT_UINT32
#define IMAGESTRUCT_INT8
#define IMAGESTRUCT_DOUBLE
#define IMAGESTRUCT_UINT8
#define IMAGESTRUCT_INT16
#define IMAGESTRUCT_UINT64
returnT getPix(void *imdata, size_t idx)
Function to cast the data type to float.
Definition pixaccess.hpp:18
returnT(*)(void *, size_t) getPixPointer()
Get the function pointer for getPix for the type.
Definition pixaccess.hpp:27