Single Thresholding¶
This code snippet shows how to perform minimum residue thresholding, absolute thresholding and relative thresholding operations.
C++¶
#include <eVision/EasyImage/EasyImage.h>
using namespace eVision;
// Images constructor
EImageBW8 srcImage;
EImageBW8 dstImage;
// ...
// Source and destination images must have the same size
dstImage.SetSize(&srcImage);
// Minimum residue thresholding (default method)
EasyImage::Threshold(&srcImage, &dstImage);
// Absolute thresholding (threshold = 110)
EasyImage::Threshold(&srcImage, &dstImage, 110);
// Relative thresholding (70% black, 30% white)
EasyImage::Threshold(&srcImage, &dstImage, EThresholdMode_Relative, 0, 255, 0.7f);
See also
EBaseROI::SetSize .NET Python, EasyImage::Threshold .NET Python
C#¶
using eVision;
// Images constructor
EImageBW8 srcImage = new EImageBW8();
EImageBW8 dstImage = new EImageBW8();
// ...
// Source and destination images must have the same size
dstImage.SetSize(srcImage);
// Minimum residue thresholding (default method)
EasyImage.Threshold(srcImage, dstImage);
// Absolute thresholding (threshold = 110)
EasyImage.Threshold(srcImage, dstImage, 110);
// Relative thresholding (70% black, 30% white)
EasyImage.Threshold(srcImage, dstImage, unchecked((uint)EThresholdMode.Relative), 0, 255, 0.7f);
See also
Python¶
import eVision
# Image constructors
src_image = eVision.EImageBW8()
dst_image = eVision.EImageBW8()
# ...
# Source and destination images must have the same size
dst_image.SetSize(src_image)
# Minimum residue thresholding (default method)
eVision.EasyImage.Threshold(src_image, dst_image)
# Absolute thresholding (threshold = 110)
eVision.EasyImage.Threshold(src_image, dst_image, 110)
# Relative thresholding (70% black, 30% white)
eVision.EasyImage.Threshold(src_image, dst_image, eVision.EThresholdMode.Relative, 0, 255, 0.7)
See also