HsvImageSegmentation.h
Go to the documentation of this file.
1 #ifndef HSVIMAGESEGMENTATION_H
2 #define HSVIMAGESEGMENTATION_H
3 
4 
5 // ivt
6 #include <Image/ImageProcessor.h>
7 
9 
10 namespace armarx
11 {
12 
13  /**
14  * @brief The HsvImageSegmentation class
15  *
16  * Allows for HSV color segmentation of images (e.g. in an image processor).
17  *
18  * Pointer ownership: All memory for images is allocated and freed by this class.
19  * You may not and need not to allocate or delete memory for images.
20  *
21  * All color images are of CByteImage::eRGB24 type.
22  * All grey images are of CByteImage::eGrayScale type.
23  */
25  {
26  public:
27 
28  /**
29  * @brief No-initialization constructor.
30  * Does not allocate any space. Overwrite an initialized object
31  * by overwriting it with a non-initalized object.
32  */
34 
35  /**
36  * @brief Construct from the given image parameters.
37  * Allocates space for the given number of images of given width and height.
38  *
39  * @param numImages number of images
40  * @param width image width
41  * @param height image height
42  *
43  * @throws std::invalid_argument if numImages <= 0
44  */
45  HsvImageSegmentation(int numImages, int width, int height, CByteImage::ImageType colorType);
46  /**
47  * @brief Shortcut constructor for usage from an image processor.
48  * @param imageProviderInfo the image provider info
49  *
50  * @throws std::invalid_argument if imageProviderInfo.numberImages <= 0
51  */
52  HsvImageSegmentation(const visionx::ImageProviderInfo& imageProviderInfo);
53 
54  /**
55  * Frees all allocated memory.
56  */
58 
59 
60  /// move constructor
62 
64 
65 
66  /**
67  * @brief Get the input images (RGB) (buffer).
68  * Write into this buffer to set new input images.
69  * @return input images RGB (buffer)
70  */
71  CByteImage** getInputImagesRgb() const;
72  /**
73  * @brief Get the input images in HSV.
74  * Only valid after calling processInputImages().
75  * @return the input images in HSV
76  */
77  CByteImage** getInputImagesHsv() const;
78  /**
79  * @brief Get input visualization images.
80  * Only valid after calling processInputImages().
81  * These are the same as input images, but may be modified
82  * for visualization without affecting the input images.
83  * @return modifiable input images for visualization
84  */
85  CByteImage** getInputVisuImages() const;
86  /**
87  * @brief Get the output images in gray scale.
88  * Only valid after calling processInputImages().
89  * @return the output images (Gray)
90  */
91  CByteImage** getOutputImagesGray() const;
92  /**
93  * @brief Get the output images in RGB (from gray scale).
94  * Only valid after calling processInputImages().
95  * @return the output images RGB
96  */
97  CByteImage** getOutputImagesRgb() const;
98 
99  /**
100  * @return the number of images
101  */
102  int getNumImages() const;
103 
104  /**
105  * @brief Processes the current input images.
106  * Copies input RGB images to input visu images.
107  * Converts input RGB images to input HSV images.
108  * Performs segmentation on HSV image.
109  * Converts output grey image to output RGB image.
110  */
111  void processInputImages(int hue, int hueTol, int satMin, int satMax, int valMin, int valMax);
112 
113 
114  private:
115 
116  /// Allocates image buffers from the given image provider info.
117  void allocate(const visionx::ImageProviderInfo& imageProviderInfo);
118  /// If allocated, frees the image buffers.
119  void deallocate();
120  /// Steals state and image buffers from other and resets other.
121  void moveFrom(HsvImageSegmentation& other);
122 
123 
124  /// Number of images.
125  int numImages = 0;
126  /// Width of each image.
127  int width = 0;
128  /// Height of each image.
129  int height = 0;
130 
131  /// Input images (RGB24)
132  CByteImage** inputImagesRgb = nullptr;
133  /// Input images with stuff drawn on them (RGB24)
134  CByteImage** inputVisuImages = nullptr;
135 
136  /// Input images in HSV space (RGB24, but HSV values)
137  CByteImage** inputImagesHsv = nullptr;
138 
139  /// Output images (GrayScale)
140  CByteImage** outputImagesGray = nullptr;
141  /// Output images for visualization (RGB24)
142  CByteImage** outputImagesRgb = nullptr;
143 
144 
145  };
146 
147 }
148 
149 #endif // HSVIMAGESEGMENTATION_H
armarx::HsvImageSegmentation::processInputImages
void processInputImages(int hue, int hueTol, int satMin, int satMax, int valMin, int valMax)
Processes the current input images.
Definition: HsvImageSegmentation.cpp:81
armarx::HsvImageSegmentation::getInputImagesHsv
CByteImage ** getInputImagesHsv() const
Get the input images in HSV.
Definition: HsvImageSegmentation.cpp:56
armarx::HsvImageSegmentation::HsvImageSegmentation
HsvImageSegmentation()
No-initialization constructor.
Definition: HsvImageSegmentation.cpp:9
armarx::HsvImageSegmentation
The HsvImageSegmentation class.
Definition: HsvImageSegmentation.h:24
visionx::ImageProviderInfo
Definition: ImageProcessor.h:466
ImageProcessor.h
armarx::HsvImageSegmentation::getNumImages
int getNumImages() const
Definition: HsvImageSegmentation.cpp:76
armarx::HsvImageSegmentation::getOutputImagesRgb
CByteImage ** getOutputImagesRgb() const
Get the output images in RGB (from gray scale).
Definition: HsvImageSegmentation.cpp:71
armarx::HsvImageSegmentation::getInputVisuImages
CByteImage ** getInputVisuImages() const
Get input visualization images.
Definition: HsvImageSegmentation.cpp:61
armarx::HsvImageSegmentation::getInputImagesRgb
CByteImage ** getInputImagesRgb() const
Get the input images (RGB) (buffer).
Definition: HsvImageSegmentation.cpp:51
armarx::HsvImageSegmentation::operator=
HsvImageSegmentation & operator=(HsvImageSegmentation &&other)
Definition: HsvImageSegmentation.cpp:41
armarx::HsvImageSegmentation::~HsvImageSegmentation
~HsvImageSegmentation()
Frees all allocated memory.
Definition: HsvImageSegmentation.cpp:31
armarx::HsvImageSegmentation::getOutputImagesGray
CByteImage ** getOutputImagesGray() const
Get the output images in gray scale.
Definition: HsvImageSegmentation.cpp:66
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28