Double Thresholding¶
This code snippet shows how to perform a thresholding operation based on low and high threshold values.
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);
// Double thresholding, low threshold = 50, high threshold = 150,
// pixels below 50 become black, pixels above 150 become white,
// pixels between thresholds become gray
EasyImage::DoubleThreshold(&srcImage, &dstImage, 50, 150, 0, 128, 255);
See also
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);
// Double thresholding, low threshold = 50, high threshold = 150,
// pixels below 50 become black, pixels above 150 become white,
// pixels between thresholds become gray
EasyImage.DoubleThreshold(srcImage, dstImage, 50, 150, 0, 128, 255);
See also
Python¶
import eVision
# Images constructor
src_image = eVision.EImageBW8()
dst_image = eVision.EImageBW8()
# ...
# Source and destination images must have the same size
dst_image.SetSize(src_image)
# Double thresholding, low threshold = 50, high threshold = 150,
# pixels below 50 become black, pixels above 150 become white,
# pixels between thresholds become gray
eVision.EasyImage.DoubleThreshold(src_image, dst_image, 50, 150, 0, 128, 255)
See also