Path Sampling

This code snippet shows how to retrieve and store the pixel values along a given path together with the corresponding pixel coordinates.

C++

#include <eVision/EasyImage/EasyImage.h>
using namespace eVision;
// Image constructor
EImageBW8 srcImage;
// ...
// Vector constructor
EBW8PathVector path;
// Path definition
path.Empty();
for (int i = 0; i < 100; i++)
{
  EBW8Path p;
  p.X = i;
  p.Y = i;
  p.Pixel = 128;
  path.AddElement(p);
}
// Get the image data along the path
EasyImage::ImageToPath(&srcImage, &path);

C#

using eVision;
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// ...
// Vector constructor
EBW8PathVector path = new EBW8PathVector();
EBW8 bw8 = new EBW8(128);
// Path definition
path.Empty();
for (int i = 0; i < 100; i++)
{
  EBW8Path p;
  p.X = (short)i;
  p.Y = (short)i;
  p.Pixel = bw8;
  path.AddElement(p);
}
// Get the image data along the path
EasyImage.ImageToPath(srcImage, path);
int pixel = path.GetElement(20).Pixel.Value;

Python

import eVision
# Image constructor
src_image = eVision.EImageBW8()
# ...
# Vector constructor
path = eVision.EBW8PathVector()
bw8 = eVision.EBW8(128)
# Path definition
path.Empty()
for i in range(100):
    p = eVision.EBW8Path()
    p.X = i
    p.Y = i
    p.Pixel = bw8
    path.AddElement(p)
# Get the image data along the path
eVision.EasyImage.ImageToPath(src_image, path)
pixel = path.GetElement(20).Pixel.Value