EasyObject - Analyzing Blobs¶
Objects and holes found by the EasyObject library.¶
Purpose¶
EasyObject is the blob analysis library of eVision. A blob is a grouping of neighboring pixels of the same gray level range. The pixels from a blob are connected: there exists a path between any couple of pixels from the blob that is entirely within the blob. This is also called connected-componenent analysis.
EasyObject can be used on BW8 .NET Python, BW16 .NET Python and C24 .NET Python images and its processing can be restricted to ROIs and to complex regions.
Selecting Blobs in an Image¶
Encode the image with an
EImageEncoder.NET Python to get anECodedImage2.NET Python.Add the blobs to an
EObjectSelection.NET Python, then remove the unwanted ones and sort the rest.
#include <eVision/EasyObject/EasyObject2/EImageEncoder.h>
using namespace eVision;
// Image constructor
EImageBW8 srcImage;
// Image encoder
EImageEncoder encoder;
// Coded image
ECodedImage2 codedImage;
// ...
// Encode the source image
encoder.Encode(srcImage, codedImage);
// Create a blob selection
EObjectSelection selection;
selection.AddObjects(codedImage);
// Remove the Small blobs
selection.RemoveUsingUnsignedIntegerFeature(EFeature_Area, 100, ESingleThresholdMode_Less);
// Retrieve the number of remaining blobs
unsigned int numBlobs = selection.GetElementCount();
// Sort the remaining blobs based on their area
selection.Sort(EFeature_Area, ESortDirection_Ascending);
// Retrieve the selected blobs
for (unsigned int index = 0; index < numBlobs; index++)
{
float centerX = selection.GetElement(index).GetGravityCenterX();
float centerY = selection.GetElement(index).GetGravityCenterY();
}
using eVision;
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// Image encoder
EImageEncoder encoder = new EImageEncoder();
// Coded image
ECodedImage2 codedImage = new ECodedImage2();
// ...
// Encode the source image
encoder.Encode(srcImage, codedImage);
// Create a blob selection
EObjectSelection selection = new EObjectSelection();
selection.AddObjects(codedImage);
// Remove the small blobs
selection.RemoveUsingUnsignedIntegerFeature(EFeature.Area, 100, ESingleThresholdMode.Less);
// Retrieve the number of remaining blobs
uint numBlobs = selection.ElementCount;
// Sort the remaining blobs based on their area
selection.Sort(EFeature.Area, ESortDirection.Ascending);
// Retrieve the selected blobs
for (uint index = 0; index < numBlobs; index++)
{
float centerX = selection.GetElement(index).GravityCenterX;
float centerY = selection.GetElement(index).GravityCenterY;
}
import eVision
# Image constructor
src_image = eVision.EImageBW8()
# Image encoder
encoder = eVision.EImageEncoder()
# Coded image
codedImage = eVision.ECodedImage2()
# ...
# Encode the source image
encoder.Encode(src_image, codedImage)
# Create a blob selection
selection = eVision.EObjectSelection()
selection.AddObjects(codedImage)
# Remove the small blobs
selection.RemoveUsingUnsignedIntegerFeature(eVision.EFeature.Area, 100, eVision.ESingleThresholdMode.Less)
# Retrieve the number of remaining blobs
numBlobs = selection.ElementCount
# Sort the remaining blobs based on their area
selection.Sort(eVision.EFeature.Area, eVision.ESortDirection.Ascending)
# Retrieve the selected blobs
for index in range(numBlobs):
centerX = selection.GetElement(index).GravityCenterX
centerY = selection.GetElement(index).GravityCenterY
Contents¶
How EasyObject encodes images and builds blobs.
Segment and build blobs.
Build holes and computes various features.
Select and sort objects and holes.
Matching objects to a template.
Validate images using a Golden Template.
Quick Links¶
List of all Classes, Structs and Enumerations of the EasyObject library.
Code snippets for the EasyObject library.
See also
Some eVision Studio samples illustrate EasyObject:
EasyObjectInertia: detects blobs and filters them by area range.
EasyObjectEChecker2: checks defects with EChecker.