Dim caption As String = "Example: RunSegmentation"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultIDComp4 As String = "ConnectedComponents4"
gdpictureSegmenter.RunSegmentation(resultIDComp4)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results ...
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultIDComp4)
'Continue ...
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents8
'Run the segmentation process.
Dim resultIDComp8 As String = "ConnectedComponents8"
gdpictureSegmenter.RunSegmentation(resultIDComp8)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results ...
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultIDComp8)
'Continue ...
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResult(resultIDComp4)
gdpictureSegmenter.ReleaseSegmentationResult(resultIDComp8)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
End Using
string caption = "Example: RunSegmentation";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultIDComp4 = "ConnectedComponents4";
gdpictureSegmenter.RunSegmentation(resultIDComp4);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results ...
int blockCount = gdpictureSegmenter.GetBlockCount(resultIDComp4);
//Continue ...
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents8;
//Run the segmentation process.
string resultIDComp8 = "ConnectedComponents8";
gdpictureSegmenter.RunSegmentation(resultIDComp8);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results ...
int blockCount = gdpictureSegmenter.GetBlockCount(resultIDComp8);
//Continue ...
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResult(resultIDComp4);
gdpictureSegmenter.ReleaseSegmentationResult(resultIDComp8);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
}