# Segmentation

The Segmentation tab is used to adjust and modify the settings that segment characters in the ROI. Typically, the default values and settings will read most text, however, in more challenging cases, some parameter values may need to be adjusted. In these types of cases, specifying a minimum character width, a maximum width and/or a minimum pitch (i.e. the character-to-character distance; for example, from the left edge of one character to the left edge of the one after it) will typically address the issues.

Note:

- The parameters on this tab may not be referenced to external cells. If cell references are required, set the External Settings parameter to reference an OCRMaxSettings function Functions are tools that are available in Spreadsheet for processing and analyzing acquisitions or other results. You can add functions to your Spreadsheet job to create tool chains and produce results for specific applications..
- If the External Settings parameter is configured to reference an OCRMaxSettings function, the controls in the Segmentation tab will be disabled.
- While in the Segmentation tab, the ROI can be adjusted (the Edit Graphic button is enabled) and the segmentation graphics (character rectangles) will be updated as the ROI is modified.
- When viewing the ROI and character regions, the lines of character regions may be partially hidden by the spreadsheet overlay. When adjusting the Segmentation parameters, hide the semitransparent spreadsheet overlay to prevent the character regions from being partially occluded.

## Segmentation Guidelines

- Images that contain backgrounds with strong textures and/or so much noise that the characters blend into the background will be difficult to segment.
- The ROI should only contain the characters to be read, and not any extraneous strong features, such as other characters or label edges.
- In instances where two characters touch, most likely, parameters will need to be adjusted. Fixed-width touching characters can be compensated for by specifying the character width; however, proportional fonts with touching characters are problematic, with the function correctly processing some cases, but not others.
- In cases involving short lines of text (for example, three or fewer characters) or relatively short lines with a lot of line jitter, specifying the expected Angle Range should help the function properly compensate for the inherent uncertainty in determining the orientation of a short line of text.
- All the characters in a line of characters must have the same orientation and skew.
- For well-separated dot-matrix print (e.g. where the dots are not touching), adjusting parameters such as the Minimum Character Fragment Size may be necessary to properly segment the characters.
- Character stroke width must be greater than or equal to two pixels.
- The minimum character size for large characters (typically alphanumeric) is 8 x 8 pixels. The minimum character size for small characters (such as periods) is 2 x 2 pixels.

Parameter | Description
Output Image Graphic | Type of output image to display: Input Image Normalized Image Binary Image Note: This parameter temporarily over-rides the Output Image Graphic parameter in the General tab. After exiting the Segmentation tab, the Output Image Graphic parameter in the General tab will be restored. Tip: Use the Output Image Graphic parameter to view the normalized or binary image of the characters while adjusting the Segmentation parameters (position the OCRMax property sheet so the image is clearly visible). The normalized and binary images can be helpful diagnostic tools for understanding and fixing problematic cases.
Segmentation Parameters | Specifies the parameter settings used to perform segmentation.
Character Polarity | Specifies the polarity of the characters in the input image. Note: To improve the performance of the function, specify the polarity of the text.
1 = Black on White | The polarity of the text is black text on a white background.
2 = White on Black | The polarity of the text is white text on a black background.
4 = Auto (default) | The function will automatically determine the polarity of text and background.
Character Width Type | Specifies how the widths of characters in the font are expected to vary, which determines how character fragments should be merged or split. Note: The character width is the width of the character region (such as the bounding box of the ink), not the region of interest (ROI) (which would typically include padding around the character rectangle).
1 = Auto (default) | The character width is unknown The font may have either fixed or proportional width. Character fragments that are wider than the specified maximum character width are split into individual characters that may or may not be of the same width, depending upon where the function determines the best place to split the character fragments.
2 = Fixed | All of the character regions in the font have the same width. Character fragments that are wider than the specified maximum character width are split into individual characters of the same width.
4 = Variable | The characters in the font may have character regions with different widths. Character fragments that are wider than the specified maximum character width are split into individual characters that may or may not be of the same width, depending upon where the function determines the best place to split the character fragments.
Minimum Character Width | Specifies the minimum width of the character region of a character, in pixels (1 - 1000; default = 3), that a character must have to be reported. This setting helps to filter background noise or other non-text features. Note: If the font being read contains small text features (i.e. periods, colons, hyphens, etc.), the ability to discriminate against background noise may be limited, because setting too high a minimum value may also discard real characters.
Use Maximum Character Width | Specifies whether or not the function should account for the maximum allowable width of the character region of a character. This setting may be used to help the function determine if a character fragment should be split or merged. If the character fragment should be split, the Character Width Type parameter determines the proper technique to be used.
0 = OFF (default) | The function does not account for the maximum allowable width of the character region of a character.
1 = ON | The function accounts for the maximum allowable width of the character region of a character. When enabled, a character wider than the specified value splits into pieces that are not too wide.
Maximum Character Width | Specifies the maximum allowable width of the character region of a character, in pixels (1 - 5000; default = 100). Note: This setting is unavailable unless the Use Maximum Character Width parameter is enabled.
Minimum Character Height | Specifies the minimum height of the character region of a character, in pixels (1 - 1000; default = 3), that a character must have in order to be reported. This setting helps to filter background noise or other non-text features. Note: If the font being read contains small text features (i.e. periods, colons, hyphens, etc.), the ability to discriminate against background noise may be limited, because setting too high a minimum value may also discard real characters.
Use Maximum Character Height | Specifies whether or not the function should account for the maximum allowable height of the character region of a character. This value is used in two ways: First, this value is used when finding the line, as a whole, such as reject vertically adjacent noise or other lines of vertically adjacent characters. Second, an individual character whose height exceeds this value is trimmed to meet this height.
0 = OFF (default) | The function does not account for the maximum allowable height of the character region of a character.
1 = ON | The function accounts for the maximum allowable height of the character region of a character.
Maximum Character Height | Specifies the maximum allowable height of the character region of a character, in pixels (1 - 5000; default = 100). Note: This setting is unavailable unless the Use Maximum Character Height parameter is enabled.
Use Minimum Character Aspect Ratio | Specifies whether or not the function accounts for the minimum allowable aspect ratio of a character, where the aspect ratio is defined as the height of the entire line of characters, divided by the width of the character region of a character.
0 = OFF | The function does not account for the minimum allowable aspect ratio of a character.
1 = ON (default) | The function accounts for the minimum allowable aspect ratio of a character. When enabled, a character whose aspect ratio is smaller than this value (such as the width being too large) is split into pieces that are not too wide.
Minimum Character Aspect Ratio | Specifies the minimum allowable aspect ratio (0 - 500; default = 80) of a character. This setting may be used to indirectly set the maximum width of characters by using the overall height of the line of characters, where the maximum width equals the line height, divided by the Minimum Character Aspect Ratio value. Character fragments wider than allowed by this parameter are not merged, and are split to form two or more character fragments that are not too wide (which is controlled by the Character Width Type parameter). Note: This setting is unavailable unless the Use Minimum Character Aspect Ratio parameter is enabled.
Angle Range | Specifies the angle search range (0 - 45; default = 0), in degrees. Note: If the line of text experiences angular rotation or skew, and that rotation or skew is consistent across images, configure the Region to compensate for those variances. Any value above 0 increases the execution time of the segmentation process.
Skew Range | Specifies the skew search range (0 - 45; default = 0), in degrees. Note: If the line of text experiences angular rotation or skew, and that rotation or skew is consistent across images, configure the Region to compensate for those variances. Any value above 0 increases the execution time of the segmentation process.
Character Fragment Merge Mode | Specifies how the function should merge character fragments when forming characters during segmentation. Determines whether or not two character fragments are required to overlap to be considered as a part of a character, or whether or not character fragments with a horizontal gap between them may be considered as part of a character.
1 = Require Overlap (default) | Character fragments must overlap horizontally, based on the value in the Minimum Character Fragment Overlap parameter.
2 = Set Min Inter-Character Gap | Character fragments with a horizontal gap between them may be merged to form characters, where any two fragments with a gap less than the value defined in the Min Inter-Character Gap parameter are merged.
4 = Set Min Inter-Character/Max Intra-Character Gap | Character fragments with a horizontal gap between them may be merged to form characters, with the decision to merge two fragments based on the values defined in the Min Inter-Character Gap and Max Intra-Character Gap parameters.
Minimum Character Fragment Overlap | Specifies the minimum fraction (0 - 100; default = 0) by which two character fragments must overlap each other horizontally, in order for the two character fragments to be considered as part of the same character. The default value (0) merges any two character fragments that overlap by at least 1 pixel. Larger values require that the character fragments overlap more substantially. For applications where some character pairs are intentionally overlapped horizontally (also called kerning), or cases where the Refine stage cannot completely correct for rotation or skew (typically because of inconsistent printing), the default value is necessary.
Max Intra-Character Gap | Specifies the maximum horizontal gap size, in pixels (0 - 1000; default = 5), that can occur within a single character, even for damaged characters. Note: In the most common application scenario, where the gaps that occur between adjacent characters are always wider than the gaps that may occur within a broken character, set the Min Inter-Character Gap parameter to the Max Intra-Character Gap parameter value, plus 1. For example, if characters never exhibit internal horizontal gaps, the Max Intra-Character Gap parameter would be set to 0, and the Min Inter-Character Gap parameter would be set to 1.
Min Inter-Character Gap | Specifies the minimum horizontal gap size, in pixels (0 - 1000; default = 0), that must occur between two character fragments to be belong to different characters. The gap is measured from the right edge of the character region of one character, to the left edge of the character region of the next character. If the gap between two fragments is smaller than this value, then the fragments must be considered to be part of the same character, unless the combined character would be too wide (as specified by the Maximum Character Width and/or Minimum Character Aspect Ratio parameters). Note: In the most common application scenario, where the gaps that occur between adjacent characters are always wider than the gaps that may occur within a broken character, set the Min Inter-Character Gap parameter to the Max Intra-Character Gap parameter value, plus 1. For example, if characters never exhibit internal horizontal gaps, the Max Intra-Character Gap parameter would be set to 0, and the Min Inter-Character Gap parameter would be set to 1.
Minimum Character Fragment Size | Specifies the minimum number of foreground (such as text) pixels (0 - 1000; default = 15) that a character fragment must have in order to be considered for possible inclusion in a character. When setting this value, it must be set so that is small enough to keep real pieces of text, while still being large enough to exclude small fragments from background noise. For dot-matrix text or text that contains small characters such as periods, a smaller value may be necessary. For solid stroke text, where the characters do not tend to break up into multiple, smaller pieces, a larger value may be necessary.
Minimum Character Size | Specifies the minimum number of foreground (such as text) pixels (0 - 5000; default = 30) that a binarized character must have in order to be reported. Characters with too few pixels are discarded. This setting helps to filter background noise or other non-text features. Note: If the font being read contains small text features (i.e. periods, colons, hyphens, etc.), the ability to discriminate against background noise may be limited, because setting too high a minimum value may also discard real characters.
Advanced Segmentation Parameters | Specifies additional parameters to be applied during the segmentation process.
Normalization Mode | Specifies the mode used to normalize the image, which removes background variation to utilize all 256 greyscale values (0 - 255). Note: This setting should be the same for both training and run-time. Changing this setting after training may cause classification issues.
1 = None | No normalization is performed.
2 = Global | A global normalization is performed, using information in the whole ROI, not local variations. This option is best when the background color and text are consistent across the entire ROI; also the fastest mode.
4 = Local (default) | A local normalization is performed, using information about each local character region in the ROI to normalize the image. This option removes background gradients, and should be tried if the Global mode does not work.
8 = Local Advanced | A local normalization is performed, using information about each local character region in the ROI to normalize the image, including adjustments for not only the background, but also the contrast of the foreground. This option removes background gradients and also adjusts for inconsistent text contrast. It also takes the most execution time of the three options.
Use Stroke Width Filter | Specifies whether or not to remove everything from a normalized image that does not have the same stroke width as the as the rest of the image. This option can remove some types of non-text features, such as thin lines that might otherwise connect nearby characters. This option can also remove some low-contrast background variations that might otherwise exceed the binarization threshold and create false fragments or interconnect nearby characters. However, using this option may cause problems if the text does not have a consistent stroke width or the text has significant variable contrast (such as parts of some strokes are very faint). Note: This setting should be the same for both training and run-time. Changing this setting after training may cause classification issues.
0 = OFF | The function does not remove everything in the image that does not have the same stroke width as the rest of the fragments in the image.
1 = ON (default) | The function removes everything in the image that does not have the same stroke width as the rest of the fragments in the image.
Ignore Border Fragments | Specifies whether or not the function completely ignores any fragments that touch any border of the ROI. Ignoring such fragments can be useful for non-text features, such as the edges of labels, that might be included within the ROI. Note: If a fragment extends from the border of the character region to the mainline of the text, the fragment will be considered to be a character. The fragment must not extend into the mainline of the text to be excluded when this parameter is enabled.
0 = OFF (default) | The function does not ignore border fragments.
1 = ON | The function ignores border fragments.
Binarization Threshold | Specifies a percentage modifier (0 - 100; default = 50) in the range that is used to compute the binarization threshold, in the normalized image, that binarizes the image between text and background. For example, the default setting of 50% would produce a binarization threshold of roughly 128 (on a 0-255 greyscale range), with 0 equaling Black on White text, and 100 equaling White on Black text. Using a value less than 50% alters the binarization threshold so that there is less text and more background, whereas using a value greater than 50% produces less background and more text. Typically, the default value correctly binarizes the image. However, in cases where there is background texture or other background variations, decreasing this value may help compensate for the background variations. Note: This setting should be the same for both training and run-time. Changing this setting after training may cause classification issues.
Character Fragment Contrast Threshold | Specifies the minimum amount of contrast [in grayscale levels (0 - 255; default = 30)] of a fragment as a whole, relative to the threshold in the normalized image, in order to be considered for possible inclusion in a character. Each foreground pixel in a fragment is always guaranteed to meet the threshold, but if all of the pixels in a fragment are very close to the threshold, then the fragment is likely just noise, rather than text. A value of 0 prevents low-contrast fragments from being rejected.
Maximum Fragment Distance to Mainline | Specifies the distance, as a percentage of character height (0 - 1000; default = 0), that a fragment may be vertically removed from the "mainline" running horizontally through the text. Ordinarily, characters are expected to lie along a straight, horizontal line after being refined (the stage of compensating for angular orientation and skew). However, characters may sometimes exhibit "jitter," where there may be vertical drift of the characters' positions. With the default setting, these character fragments would be rejected because they do not lie along the "mainline" of characters. Increasing this parameter setting allows the function to keep fragments that do not lie along the "mainline" of characters.
Segmentation Analysis Mode | Specifies the type of character analysis mode to perform to determine the optimal character segmentation. This parameter determines whether or not to perform additional analysis beyond the Group stage.
1 = Minimal | Performs basic segmentation analysis. Follows the Group stage analysis only.
2 = Standard (default) | Performs additional analysis of the line as a whole, including character spacing, to determine the optimal segmentation. When enabled, the function is affected by the Minimum Pitch, Character Pitch Type, and Character Pitch Position parameters.
Minimum Pitch | Specifies the minimum pitch, in pixels (0 - 1000; default = 0), that can occur between two characters, where the pitch is computed based on the Character Pitch Position parameter. If the pitch between two fragments is smaller than this, then they must be considered to be part of the same character, unless the combined character would be too wide (as specified by the Maximum Character Width or Minimum Character Aspect Ratio parameters). Note: If the Segmentation Analysis Mode parameter is set to Minimal, this parameter is disabled.
Character Pitch Position | Specifies how the pitch between two successive characters should be measured. Pitch is defined as the distance between (approximately) corresponding points on adjacent characters, and not the distance from the end of one character to the beginning of the next character (which is called the inter-character gap). For fixed-pitch fonts in which the characters have different widths, typically the pitch has a consistent value only when using the appropriate pitch metric. Note: If the Segmentation Analysis Mode parameter is set to Minimal, this parameter is disabled.
1 = Auto (default) | Specifies that an unknown metric is being used. The appropriate pitch may be any of the other pitch positions, or else there is not a constant pitch position (as may be the case for a proportional-pitch font), and the OCRMax function determines the appropriate pitch metric.
2 = Left-to-Left | Specifies that pitch is measured as the distance from the left-side of the character region of a character to the left-side of the character region of the adjacent character. Note: The terms "left" and "right" are relative to the coordinate axis defined by the ROI, meaning that "right" is equal to the positive X direction.
4 = Center-to-Center | Specifies that pitch is measured as the distance from the center of the character region of a character to the center of the character region of the adjacent character.
8 = Right-to-Right | Specifies that pitch is measured as the distance from the right-side of the character region of a character to the right-side of the character region of the adjacent character. Note: The terms "left" and "right" are relative to the coordinate axis defined by the ROI, meaning that "right" is equal to the positive X direction.
Character Pitch Type | Specifies whether the spacing between successive characters has a single, fixed value, or varies, depending on the particular characters. Pitch is defined as the distance between (approximately) corresponding points on adjacent characters, and not the distance from the end of one character to the beginning of the next character (which is called the inter-character gap). Note: If the Segmentation Analysis Mode parameter is set to Minimal, this parameter is disabled.
1 = Auto (default) | Specifies that pitch type is unknown, but the pitch type is expected to be either fixed or proportional, and not variable. The OCRMax function will determine the best type.
2 = Fixed | Specifies that pitch is fixed, which means that the pitch between any pair of characters is constant, regardless of the width of the character rectangles of the characters. The pitch is measured based on the Character Pitch Position parameter.
4 = Proportional | Specifies that the pitch is proportional, which means that the pitch between any pair of characters depends on the particular characters. For example, the distance between two "i" lowercase letters may be much less than the distance between two "M" uppercase letters. Note: Although no pitch measurement is constant throughout a string, typically the inter-character gap, which is the distance from the right-side of one character's character region to the left-side of the adjacent character's character region, is approximately constant. The terms "left" and "right" are relative to the coordinate axis defined by the ROI, meaning that "right" is equal to the positive X direction.
8 = Variable | Specifies that no character-to-character distance metric is consistent throughout a string, meaning that character placement is erratic, and the pitch is neither fixed nor proportional. The OCRMax function should not try to determine the type of pitch. Note: Variable pitch is different from Auto, since Auto assumes that the pitch is either fixed or proportional, but which is not known.
Show Diagnostics | Specifies which type of graphical diagnostic data to display on the image.
0 = hide all (default) | All graphical diagnostic data will be hidden, except when the cell containing the OCRMax function is highlighted in the spreadsheet.
1 = show rejected characters only | Regions around rejected characters will be drawn in red, and the mainline of the text will be enclosed in a blue rectangle. Example
2 = show kept fragments only | Regions around kept fragments will be drawn in cyan, and the mainline of the text will be enclosed in a blue rectangle. Example
3 = show rejected fragments only | Regions around rejected fragments will be drawn in yellow, and the mainline of the text will be enclosed in a blue rectangle. Example
4 = show all | Regions will be drawn around kept characters (green), rejected characters (red), kept fragments (cyan), rejected fragments (yellow), the mainline of the text (blue) and the extended mainline of the text (magenta).