BlockImageAccessT.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * NICE-Core - efficient algebra and computer vision methods
  3. * - libimage - An image library
  4. * See file License for license information.
  5. */
  6. #ifndef _LIMUN_BLOCKIMAGET_H
  7. #define _LIMUN_BLOCKIMAGET_H
  8. #include <core/image/GrayColorImageCommonImplementationT.h>
  9. #include <core/image/ImageAccessT.h>
  10. #include <core/image/pointerArithmetic.h>
  11. namespace NICE {
  12. /**
  13. * An image with a defined memory layout, but no own memory management.
  14. * The class cannot be reasonable instantiated (use ImageT e.g.),
  15. * but provides an interface to access the pixels.
  16. * In addition to ImageAccessT, there are functions for high performance
  17. * pointer arithmetic access.
  18. *
  19. * The memory layout is defined as follows: there is a constant distance
  20. * of columnStepsize() bytes (NOT pixels!) between two columns
  21. * and a constant distance of rowStepsize() bytes between two rows of the image.
  22. *
  23. * @author Ferid Bajramovic
  24. */
  25. template <class P>
  26. class BlockImageAccessT : public GrayColorImageCommonImplementationT<P>, public ImageAccessT<P> {
  27. public:
  28. virtual int width() const;
  29. virtual int height() const;
  30. virtual P getPixelT(int x, int y) const;
  31. virtual void setPixelT(int x, int y, P pixel);
  32. virtual int channels() const {
  33. return 1;
  34. }
  35. inline P getPixelQuick(int x, int y) const {
  36. return *this->getPixelPointerXY(x, y);
  37. }
  38. inline void setPixelQuick(int x, int y, P pixel) {
  39. *this->getPixelPointerXY(x, y) = pixel;
  40. }
  41. inline P* getPixelPointerXY(int x, int y) {
  42. return pointerToPixelEx(this->getPixelPointer(), x, y, this->rowStepsize(), this->columnStepsize());
  43. }
  44. inline const P* getPixelPointerXY(int x, int y) const {
  45. return pointerToPixelEx(this->getPixelPointer(), x, y, this->rowStepsize(), this->columnStepsize());
  46. }
  47. BlockImageAccessT(void) {};
  48. /**
  49. * Sets all pixel to the specified value
  50. * @param value pixel value
  51. */
  52. void set(const P& value);
  53. };
  54. } // namespace
  55. //#ifdef __GNUC__
  56. #include "core/image/BlockImageAccessT.tcc"
  57. //#endif
  58. #endif