Documentation Portal      

What are you looking for?

Histogram-Based Single Thresholding

Functional Guide | Reference: Histogram, HistogramThreshold

////////////////////////////////////////////////////////////////
// This code snippet shows how to perform a minimum residue //
// thresholding operation based on an histogram. //
////////////////////////////////////////////////////////////////
// Images constructor
EImageBW8 srcImage;
EImageBW8 dstImage;
// Histogram constructor
EBWHistogramVector histo;
// Variables
unsigned int thresholdValue;
float avgBelowThr, avgAboveThr;
// ...
// Compute the histogram
EasyImage::Histogram(&srcImage, &histo);
// Compute the single threshold (and the average pixel values below and above the threshold)
thresholdValue= EThresholdMode_MinResidue;
EasyImage::HistogramThreshold(&histo, thresholdValue, avgBelowThr, avgAboveThr);
// Source and destination images must have the same size
dstImage.SetSize(&srcImage);
// Perform the single thresholding
EasyImage::Threshold(&srcImage, &dstImage, thresholdValue);
'////////////////////////////////////////////////////////////////
'// This code snippet shows how to perform a minimum residue //
'// thresholding operation based on an histogram. //
'////////////////////////////////////////////////////////////////
' EasyImage context constructor
Dim EasyImage As New EasyImage
' Images constructor
Dim srcImage As New EImageBW8
Dim dstImage As New EImageBW8
' Histogram constructor
Dim histo As New EBWHistogramVector
' Variables
Dim thresholdValue As Long
Dim avgBelowThr As Single
Dim avgAboveThr As Single
' ...
' Compute the histogram
EasyImage.histogram srcImage, histo
' Compute the single threshold (and the average pixel values below and above the threshold)
thresholdValue = EThresholdMode_MinResidue
EasyImage.HistogramThreshold histo, thresholdValue, avgBelowThr, avgAboveThr
' Source and destination images must have the same size
dstImage.SetSize srcImage.Width, srcImage.Height
' Perform the single thresholding
EasyImage.ThresholdBW8LowHigh srcImage, dstImage, thresholdValue
////////////////////////////////////////////////////////////////
// This code snippet shows how to perform a minimum residue //
// thresholding operation based on an histogram. //
////////////////////////////////////////////////////////////////
// Images constructor
EImageBW8 srcImage= new EImageBW8();
EImageBW8 dstImage= new EImageBW8();
// Histogram constructor
EBWHistogramVector histo= new EBWHistogramVector();
// Variables
int thresholdValue= (int)EThresholdMode.MinResidue;
float avgBelowThr, avgAboveThr;
// ...
// Compute the histogram
EasyImage.Histogram(srcImage, histo);
// Compute the single threshold (and the average pixel values below and above the threshold)
EasyImage.HistogramThreshold(histo, ref thresholdValue, out avgBelowThr, out avgAboveThr);
// Source and destination images must have the same size
dstImage.SetSize(srcImage);
// Perform the single thresholding
EasyImage.Threshold(srcImage, dstImage, thresholdValue);

See also in the Functional Guide

See also in the Reference

Histogram

HistogramThreshold

Which API shall we display?

© 2019 EURESYS s.a.  -  About Documentation  -  Open Source Licenses  -  Open eVision 2.10.0.1121