Combine Regions¶
This code snippet shows how to perform a threshold on a combined region in an image.
C++¶
#include <eVision/EasyImage/EasyImage.h>
#include <eVision/Easy/ECircleRegion.h>
#include <eVision/Easy/ERectangleRegion.h>
using namespace eVision;
// Image constructors
EImageBW8 srcImage;
EImageBW8 dstImage;
EPoint center(0, 0);
float radius(5), width(10), height(10), angle(45);
//...
// Create first region
ECircleRegion circleRegion(center, radius);
// Create second region
ERectangleRegion rectangleRegion(center, width, height, angle);
// Combine regions
ERegion combinedRegion = ERegion::Union(circleRegion, rectangleRegion);
// Threshold the image
EasyImage::Threshold(&srcImage, combinedRegion, &dstImage);
C#¶
using eVision;
// Image constructors
EImageBW8 srcImage = new EImageBW8();
EImageBW8 dstImage = new EImageBW8();
EPoint center = new EPoint(0, 0);
int radius = 5, width = 10, height = 10, angle = 45;
//...
// Create first region
ECircleRegion circleRegion = new ECircleRegion(center, radius);
// Create second region
ERectangleRegion rectangleRegion = new ERectangleRegion(center, width, height, angle);
// Combine regions
ERegion combinedRegion = ERegion.Union(circleRegion, rectangleRegion);
// Threshold the image
EasyImage.Threshold(srcImage, combinedRegion, dstImage);
Python¶
import eVision
# Image constructors
src_image = eVision.EImageBW8()
dst_image = eVision.EImageBW8()
center = eVision.EPoint(0, 0)
radius = 5
width = 10
height = 10
angle = 45
#...
# Create first region
circle_region = eVision.ECircleRegion(center, radius)
# Create second region
rectangle_region = eVision.ERectangleRegion(center, width, height, angle)
# Combine regions
combined_region = eVision.ERegion.Union(circle_region, rectangle_region)
# Threshold the image
eVision.EasyImage.Threshold(src_image, combined_region, dst_image)