File: tutorial-image-manipulation.cpp

package info (click to toggle)
visp 3.7.0-7
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 166,380 kB
  • sloc: cpp: 392,705; ansic: 224,448; xml: 23,444; python: 13,701; java: 4,792; sh: 206; objc: 145; makefile: 118
file content (33 lines) | stat: -rw-r--r-- 1,120 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*! \example tutorial-image-manipulation.cpp */
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpImage.h>

int main()
{
#ifdef ENABLE_VISP_NAMESPACE
  using namespace VISP_NAMESPACE_NAME;
#endif

  try {
    vpImage<unsigned char> gray_image(240, 320);
    vpImage<vpRGBa> color_image(240, 320);

    gray_image = 128;
    vpRGBa color(255, 0, 0);
    color_image = color;

    unsigned int igray_max = gray_image.getHeight() - 1;
    unsigned int jgray_max = gray_image.getWidth() - 1;
    std::cout << "Gray  image, last pixel intensity: " << static_cast<int>(gray_image[igray_max][jgray_max]) << std::endl;

    unsigned int icolor_max = color_image.getHeight() - 1;
    unsigned int jcolor_max = color_image.getWidth() - 1;
    std::cout << "Color image, last pixel RGB components: "
      << static_cast<int>(color_image[icolor_max][jcolor_max].R) << " "
      << static_cast<int>(color_image[icolor_max][jcolor_max].G) << " "
      << static_cast<int>(color_image[icolor_max][jcolor_max].B) << std::endl;
  }
  catch (const vpException &e) {
    std::cout << "Catch an exception: " << e << std::endl;
  }
}