SetSegmentData Method
Summary
Updates the specified segment.
Syntax
Parameters
image
The image that will be segmented.
id
ID of the segment to be updated.
data
Instance of the structure that contains the new segment information.
Example
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Mrc;
private bool MrcEnumerateSegmentInfoSetSegmentDataCallback(MrcSegmenter segmentHandle, MrcSegmentData data, int iD)
{
if (iD == 0)
{
MrcSegmentData newData = data;
newData.ImageSegment = new LeadRect(0, 0, 60, 60);
newData.SegmentType = MrcSegmentType.Picture;
//segmenter.SetSegmentData(segmentedImage, iD, newData);
}
return true;
}
public void SetSegmentDataExample()
{
// Load an image
RasterCodecs codecs = new RasterCodecs();
codecs.ThrowExceptionsOnInvalidImages = true;
RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "PDFSegmentation.pdf"));
MrcSegmenter segmenter = new MrcSegmenter(image, RasterColor.FromKnownColor(RasterKnownColor.White), RasterColor.FromKnownColor(RasterKnownColor.Black));
segmenter.SegmentImage(image, MrcSegmentImageOptions.Empty);
MrcEnumerateSegmentsInfo setSegmentCallBack = new MrcEnumerateSegmentsInfo(MrcEnumerateSegmentInfoSetSegmentDataCallback);
segmenter.EnumerateSegments(setSegmentCallBack);
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images";
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Mrc
Private segmentedImage As RasterImage
Private Function MrcEnumerateSegmentInfoSetSegmentDataCallback(ByVal segmentHandle As MrcSegmenter, ByVal data As MrcSegmentData, ByVal iD As Integer) As Boolean
If iD = 0 Then
Dim newData As MrcSegmentData = data
newData.ImageSegment = New LeadRect(0, 0, 60, 60)
newData.SegmentType = MrcSegmentType.Picture
'segmenter.SetSegmentData(segmentedImage, iD, newData);
End If
Return True
End Function
Public Sub SetSegmentDataExample()
' Load an image
Dim codecs As RasterCodecs = New RasterCodecs()
codecs.ThrowExceptionsOnInvalidImages = True
Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "PDFSegmentation.pdf"))
Dim segmenter As MrcSegmenter = New MrcSegmenter(image, RasterColor.FromKnownColor(RasterKnownColor.White), RasterColor.FromKnownColor(RasterKnownColor.Black))
segmenter.SegmentImage(image, MrcSegmentImageOptions.Empty)
Dim setSegmentCallBack As MrcEnumerateSegmentsInfo = New MrcEnumerateSegmentsInfo(AddressOf MrcEnumerateSegmentInfoSetSegmentDataCallback)
segmenter.EnumerateSegments(setSegmentCallBack)
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images"
End Class