Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
tutorial-image-manipulation.cpp
1 
2 #include <visp3/core/vpConfig.h>
3 #include <visp3/core/vpImage.h>
4 
5 int main()
6 {
7 #ifdef ENABLE_VISP_NAMESPACE
8  using namespace VISP_NAMESPACE_NAME;
9 #endif
10 
11  try {
12  vpImage<unsigned char> gray_image(240, 320);
13  vpImage<vpRGBa> color_image(240, 320);
14 
15  gray_image = 128;
16  vpRGBa color(255, 0, 0);
17  color_image = color;
18 
19  unsigned int igray_max = gray_image.getHeight() - 1;
20  unsigned int jgray_max = gray_image.getWidth() - 1;
21  std::cout << "Gray image, last pixel intensity: " << (int)gray_image[igray_max][jgray_max] << std::endl;
22 
23  unsigned int icolor_max = color_image.getHeight() - 1;
24  unsigned int jcolor_max = color_image.getWidth() - 1;
25  std::cout << "Color image, last pixel RGB components: " << (int)color_image[icolor_max][jcolor_max].R << " "
26  << (int)color_image[icolor_max][jcolor_max].G << " " << (int)color_image[icolor_max][jcolor_max].B
27  << std::endl;
28  }
29  catch (const vpException &e) {
30  std::cout << "Catch an exception: " << e << std::endl;
31  }
32 }
error that can be emitted by ViSP classes.
Definition: vpException.h:60
Definition: vpRGBa.h:65