Loading a Supervised Segmenter and Segmenting an Image¶
This code snippet shows how to load a trained supervised segmenter and how to segment a new image.
C++¶
#include <eVision/EasyDeepLearning/EasySegment/ESupervisedSegmenter.h>
using namespace eVision;
using namespace eVision::EasyDeepLearning;
// Image
EImageBW8 image;
image.Load("my_image_path");
// Segmenter
ESupervisedSegmenter segmenter;
segmenter.Load("segement_path");
// Apply the segmenter on the image
ESupervisedSegmenterResult r = segmenter.Apply(image);
// Retrieve the probability map
EImageBW8 probabilityMap = r.GetProbabilityMap("label 1");
C#¶
using eVision;
using eVision.EasyDeepLearning;
// Image and segmenter constructor
ESupervisedSegmenter segmenter = new ESupervisedSegmenter();
EImageBW8 image = new EImageBW8();
// Load segmenter and image
segmenter.Load("segment_path");
image.Load("image_path");
// Apply the segmenter on the image
ESupervisedSegmenterResult result = segmenter.Apply(image);
// Retrieve the probability map
EImageBW8 probabilityMap = result.GetProbabilityMap("label 1");
Python¶
import eVision
from eVision import EasyDeepLearning as edl
# Image and segmenter constructor
segmenter = edl.ESupervisedSegmenter()
image = eVision.EImageBW8()
# Load segmenter and image
segmenter.Load("segment_path")
image.Load("image_path")
# Apply the segmenter on the image
result = segmenter.Apply(image)
# Retrieve the probability map
probability_map = result.GetProbabilityMap("label 1")