GetParagraphTop Method (GdPictureSegmenter)
                                 
                                
                                    
                                        In This Topic
                                    
                                
                                Returns the top y-coordinate of the bounding box of the specified paragraph, that is a part of the segmentation result specified by its index. 
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
Syntax
            
            
            
            
            'Declaration
 
Public Function GetParagraphTop( _
   ByVal  As String, _
   ByVal  As Integer _
) As Integer
             
        
            
            public int GetParagraphTop( 
   string ,
   int 
)
             
        
            
            public function GetParagraphTop( 
    : String;
    : Integer
): Integer; 
             
        
            
            public function GetParagraphTop( 
    : String,
    : int
) : int;
             
        
            
            public: int GetParagraphTop( 
   string* ,
   int 
) 
             
        
            
            public:
int GetParagraphTop( 
   String^ ,
   int 
) 
             
        
             
        
            Parameters
- SegmentationResultID
- The unique result identifier of the executed segmentation process obtained by the RunSegmentation method.
- ParagraphIdx
- The 0-based index of the paragraph within the specified segmentation result. It must be a value between 0 and GetParagraphCount(SegmentationResultID)-1.
Return Value
The top y-coordinate of the paragraph's bounding box, in pixels. 
Please always use the GetStat method to determine if this method has been successful.
 
            
            
            
            
            
            Example
How to find out detected paragraphs within the segmentation result. All paragraphs are subsequently color-coded and saved into the output file.
            
             
    
	
		Dim caption As String = "Example: GetParagraphTop"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
    Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
        'Set up the image you want to process.
        Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
        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 resultID As String = gdpictureSegmenter.RunSegmentation()
            If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
                'Check the results.
                Dim paragraphCount As Integer = gdpictureSegmenter.GetParagraphCount(resultID)
                If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
                    Dim message As String = "The number of detected paragraphs: "
                    message = message + paragraphCount.ToString() + vbCrLf
                    Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
                    For i As Integer = 0 To paragraphCount - 1
                        top = gdpictureSegmenter.GetParagraphTop(resultID, i)
                        If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetParagraphLeft(resultID, i)
                        If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetParagraphBottom(resultID, i)
                        If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetParagraphRight(resultID, i)
                        If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
                            If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
                                message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
                                save += 1
                            Else
                                message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
                            End If
                        Else
                            message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
                        End If
                    Next
                    If paragraphCount = 0 Then
                        message = message + "The resulting image HAS NOT been created."
                    Else
                        If save = paragraphCount Then
                            If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
                                message = message + "The resulting image HAS been saved successfully."
                            Else
                                message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
                            End If
                        End If
                    End If
                    MessageBox.Show(message, caption)
                Else
                    MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
                End If
            Else
                MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
            End If
            'Release the used image.
            gdpictureImaging.ReleaseGdPictureImage(image)
        Else
            MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
        End If
    End Using
    'Release resources.
    gdpictureSegmenter.ReleaseSegmentationResults()
End Using
	 
	
		string caption = "Example: GetParagraphTop";
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("input.tif");
        if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
            (gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
        {
            //Set the segmentation mode.
            gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
            //Run the segmentation process.
            string resultID = gdpictureSegmenter.RunSegmentation();
            if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
            {
                //Check the results.
                int paragraphCount = gdpictureSegmenter.GetParagraphCount(resultID);
                if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
                {
                    string message = "The number of detected paragraphs: ";
                    message = message + paragraphCount.ToString() + "\n";                                
                    int top = 0, left = 0, bottom = 0, right = 0, save = 0;
                    for (int i = 0; i < paragraphCount; i++)
                    {
                        top = gdpictureSegmenter.GetParagraphTop(resultID, i);
                        if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
                            left = gdpictureSegmenter.GetParagraphLeft(resultID, i);
                        if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
                            bottom = gdpictureSegmenter.GetParagraphBottom(resultID, i);
                        if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
                            right = gdpictureSegmenter.GetParagraphRight(resultID, i);
                        if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
                        {
                            if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
                            {
                                message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
                                save++;
                            }
                            else
                                message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
                        }
                        else
                            message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
                    }
                    if (paragraphCount == 0)
                    {
                        message = message + "The resulting image HAS NOT been created.";
                    }
                    else
                    { 
                        if (save == paragraphCount)
                        {
                            if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
                                message = message + "The resulting image HAS been saved successfully.";
                            else
                                message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
                        }
                    }                               
                    MessageBox.Show(message, caption);
                }
                else
                    MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
            }
            else
                MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
            //Release the used image.
            gdpictureImaging.ReleaseGdPictureImage(image);
        }
        else
            MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
    }
    //Release resources.
    gdpictureSegmenter.ReleaseSegmentationResults();
}
	 
	
 
Example
How to find out detected paragraphs within the segmentation result. All paragraphs are subsequently color-coded and saved into the output file.
            
            Dim caption As String = "Example: GetParagraphTop"
            Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
                Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
                    'Set up the image you want to process.
                    Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
                    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 resultID As String = gdpictureSegmenter.RunSegmentation()
                        If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
                            'Check the results.
                            Dim paragraphCount As Integer = gdpictureSegmenter.GetParagraphCount(resultID)
                            If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
                                Dim message As String = "The number of detected paragraphs: "
                                message = message + paragraphCount.ToString() + vbCrLf
                                Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
                                For i As Integer = 0 To paragraphCount - 1
                                    top = gdpictureSegmenter.GetParagraphTop(resultID, i)
                                    If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetParagraphLeft(resultID, i)
                                    If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetParagraphBottom(resultID, i)
                                    If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetParagraphRight(resultID, i)
                                    If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
                                        If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
                                            message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
                                            save += 1
                                        Else
                                            message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
                                        End If
                                    Else
                                        message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
                                    End If
                                Next
                                If paragraphCount = 0 Then
                                    message = message + "The resulting image HAS NOT been created."
                                Else
                                    If save = paragraphCount Then
                                        If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
                                            message = message + "The resulting image HAS been saved successfully."
                                        Else
                                            message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
                                        End If
                                    End If
                                End If
                                MessageBox.Show(message, caption)
                            Else
                                MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
                            End If
                        Else
                            MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
                        End If
                        'Release the used image.
                        gdpictureImaging.ReleaseGdPictureImage(image)
                    Else
                        MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
                    End If
                End Using
                'Release resources.
                gdpictureSegmenter.ReleaseSegmentationResults()
            End Using
            string caption = "Example: GetParagraphTop";
            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("input.tif");
                    if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
                        (gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
                    {
                        //Set the segmentation mode.
                        gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
                        //Run the segmentation process.
                        string resultID = gdpictureSegmenter.RunSegmentation();
                        if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
                        {
                            //Check the results.
                            int paragraphCount = gdpictureSegmenter.GetParagraphCount(resultID);
                            if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
                            {
                                string message = "The number of detected paragraphs: ";
                                message = message + paragraphCount.ToString() + "\n";                                
                                int top = 0, left = 0, bottom = 0, right = 0, save = 0;
                                for (int i = 0; i < paragraphCount; i++)
                                {
                                    top = gdpictureSegmenter.GetParagraphTop(resultID, i);
                                    if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
                                        left = gdpictureSegmenter.GetParagraphLeft(resultID, i);
                                    if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
                                        bottom = gdpictureSegmenter.GetParagraphBottom(resultID, i);
                                    if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
                                        right = gdpictureSegmenter.GetParagraphRight(resultID, i);
                                    if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
                                    {
                                        if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
                                        {
                                            message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
                                            save++;
                                        }
                                        else
                                            message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
                                    }
                                    else
                                        message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
                                }
                                if (paragraphCount == 0)
                                {
                                    message = message + "The resulting image HAS NOT been created.";
                                }
                                else
                                { 
                                    if (save == paragraphCount)
                                    {
                                        if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
                                            message = message + "The resulting image HAS been saved successfully.";
                                        else
                                            message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
                                    }
                                }                               
                                MessageBox.Show(message, caption);
                            }
                            else
                                MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
                        }
                        else
                            MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
                        //Release the used image.
                        gdpictureImaging.ReleaseGdPictureImage(image);
                    }
                    else
                        MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
                }
                //Release resources.
                gdpictureSegmenter.ReleaseSegmentationResults();
            }
            
            
            See Also