ImageGear .NET
Work with Zones

A zone is a rectangular area in the image, up to full size, containing a feature of interest to the user. The image data covered by each zone is handled and processed (and typically recognized) separately, according to zone-specific parameters. The zones of an ImGearRecPage Class image form a list, the zone list, which is attached to the image. The zone list can be examined at any time with the Zones Property of ImGearRecPage Class.

The characterizing attributes of a zone are the following:

The zone's filling method (fm) can take one of the following ImGearRecFillingMethod Enumeration values:

There are two special filling methods worth mentioning separately:

This section provides information about the following:

Add Zones 

Zones can be added to a given image (to the zone list of the image, to be precise) in three different ways:

Manually

In addition to, or instead of the automatic zone search, you can program your own zones by specifying the zone coordinates and zone attributes. For adding zones to the zone list manually, the application calls the Add Method of ImGearRecZoneCollection Class. Related methods are: Insert Method, Remove Method, RemoveAt Method, and Clear Method.

From a File

The third way of creating zones is by reading zones from a file (called a zone file) that contains the attributes of previously saved zones. An application can save the current zone definitions to a zone file any time with the ImGearRecZoneCollection.SaveToFile Method. The application can load them from a zone file with the LoadFromFile Method.

When a zone file is loaded, any previous zones on the image are removed.

If the application calls the ImGearRecPage.Recognize Method on an image with an empty zone list, the page-layout decomposition method is called automatically. 

Automatically

The automatic page-layout decomposition process (auto-zoning) can be activated directly by calling the ImGearRecZoneCollection.Locate Method for finding text blocks on the image. It creates an entire zone list for the given image.

The Locate Method has an overload that takes an ImGearRectangle as a parameter. This rectangle serves to limit the area of the image inside which zones will be searched and defined.

The recognition engine offers three different algorithms to be applied during auto-zoning: use the ImGearRecRecognitionSettings.DecompMethod Property to specify which Page parser algorithm setting should be applied during auto-zoning from among the following:

In addition, the integrating application can set the zoning method to AUTO. With this setting, the recognition engine determines the method to use. See ImGearRecDecompositionMethod Enumeration for details.

Applying the new STANDARD algorithm results in the best throughput in overall accuracy, though in some cases it might require significantly more time to complete.

When auto-zoning is used, each resulting zone is initialized with the following:

All zones created by this method will have the following:

Any zone can be locally overridden with the Zones Property of ImGearRecPage, which allows you to access the zone list and change the attributes of a zone. 

C#
Copy Code
using (ImGearRecPage recognitionPage = recognitionEngine.ImportPage((ImGearRasterPage)igPage))
  {
  //Decides which Page parser algorithm setting should be applied udring auto-zoning. 
  recognitionEngine.Recognition.DecompMethod = ImGearRecDecompositionMethod.AUTO;
  // Finds blocks of text on the image and creates a zone for each block.
  recognitionPage.Zones.Locate();
  // Determine the type of the text in the zones of a page (e.g. machine printed or dot-matrix printed text). 
  // The method performs a zone by zone analysis (instead of suggesting a general filling type for the entire image)
  // if the algorithm can determine a type for a given zone, the method replaces the DEFAULT value in the zone's 
  // ImGearRecZone.FillingMethod property by the determined one.
  recognitionPage.Zones.DetectFillingMethod();
  // Preprocess the page.
  recognitionPage.Image.Preprocess();
  // Perform recognition.
  recognitionPage.Recognize();                  
}
VB.NET
Copy Code
Using recognitionPage As ImGearRecPage = recognitionEngine.ImportPage(DirectCast(igPage, ImGearRasterPage))
' Decides which Page parser algorithm setting should be applied udring auto-zoning.
recognitionEngine.Recognition.DecompMethod = ImGearRecDecompositionMethod.AUTO
' Finds blocks of text on the image and creates a zone for each block.
recognitionPage.Zones.Locate()
' Determine the type of the text in the zones of a page (e.g. machine printed or dot-matrix printed text).
' The method performs a zone by zone analysis (instead of suggesting a general filling type for the entire image)
' if the algorithm can determine a type for a given zone, the method replaces the DEFAULT value in the zone's
' ImGearRecZone.FillingMethod property by the determined one.
recognitionPage.Zones.DetectFillingMethod()
' Preprocess the page.
recognitionPage.Image.Preprocess()
' Perform recognition.
recognitionPage.Recognize()
End Using

Detect Tables without Visible Cell Separators

Tables with visible grid lines (gridded tables) in an original page can usually be detected successfully by the auto-zoning method. However, tables without visible cell separators in the original are harder to identify as tables, because they could alternately be word lists or data arranged in columns. The recognition engine offers an algorithm for detecting such non-gridded tables more confidently. This feature can only be used in conjunction with an auto-zoning step. The algorithm to detect non-gridded tables is based on the result of character recognition. This algorithm will run only if all the following conditions are met:

The code examples below show how to:

Define a Zone Manually

The following example contains uppercase letters only for multi-lingual omnifont recognition:

C#
Copy Code
ImGearRecZone igRecZone = new ImGearRecZone();
igRecZone.Rect.Left = 739;
igRecZone.Rect.Top = 63;
igRecZone.Rect.Right = 1729;
igRecZone.Rect.Bottom = 114;
// textual zone: this contains flowed text.
igRecZone.Type = ImGearRecZoneType.FLOW;
// Omnifont filling method was used to fill the zone's area.
igRecZone.FillingMethod = ImGearRecFillingMethod.OMNIFONT;
// MOR recognition module will be applied for the zone's area.
igRecZone.RecognitionModule = ImGearRecRecognitionModule.OMNIFONT_MOR;
// Character Set: this only has uppercase letters.
igRecZone.Filter = ImGearRecFilter.UPPERCASE;
// Add the zone to the zone list.
igRecPage.Zones.Add(igRecZone);
igRecPage.Zones.SaveToFile("SAMPLE.ZON");
MessageBox.Show("Number of Zones: " + igRecPage.Zones.Count);
VB.NET
Copy Code
Dim igRecZone As New ImGearRecZone()
igRecZone.Rect.Left = 739
igRecZone.Rect.Top = 63
igRecZone.Rect.Right = 1729
igRecZone.Rect.Bottom = 114
' textual zone: this contains flowed text.
igRecZone.Type = ImGearRecZoneType.FLOW
' Omnifont filling method was used to fill the zone's area.
igRecZone.FillingMethod = ImGearRecFillingMethod.OMNIFONT
' MOR recognition module will be applied for the zone's area.
igRecZone.RecognitionModule = ImGearRecRecognitionModule.OMNIFONT_MOR
' Character Set: this only has uppercase letters.
igRecZone.Filter = ImGearRecFilter.UPPERCASE
' Add the zone to the zone list.
igRecPage.Zones.Add(igRecZone)
igRecPage.Zones.SaveToFile("SAMPLE.ZON")
MessageBox.Show("Number of Zones: " + igRecPage.Zones.Count.ToString())

To get information about any particular zone of the zone list of the image, the application can access the zone list via the Zones Property of ImGearRecPage Class. This can be useful in finding out more about the zones created by the auto-zoning method.

Update a Zone

When updating a table-type zone by accessing the zone list via the Zones Property, the "cell-detection" algorithm won't be activated, which will result in improper table detection within the zone.

The program can detect cells within a table-zone if automatic page decomposition is used.

C#
Copy Code
igRecPage.Zones.LoadFromFile("SAMPLE.ZON");
int nZones = igRecPage.Zones.Count;
// Get the first zone in the zone list.
ImGearRecZone igRecZone = igRecPage.Zones[0];
// . . .
// Adjust the left border of the zone by 50 pixels.
igRecZone.Rect.Left -= 50;
// Zone content will be handled as a flow text.
igRecZone.Type = ImGearRecZoneType.FLOW;
igRecPage.Zones.SaveToFile("SAMPLE.ZON");
VB.NET
Copy Code
igRecPage.Zones.LoadFromFile("SAMPLE.ZON")
Dim nZones As Integer = igRecPage.Zones.Count
' Get the first zone in the zone list.
Dim igRecZone As ImGearRecZone = igRecPage.Zones(0)
' . . .
' Adjust the left border of the zone by 50 pixels.
igRecZone.Rect.Left -= 50
' Zone content will be handled as a flow text.
igRecZone.Type = ImGearRecZoneType.FLOW
igRecPage.Zones.SaveToFile("SAMPLE.ZON")

 

 


©2017. Accusoft Corporation. All Rights Reserved.

Send Feedback