# Blue Read Parameters

The parameters adjust how the neural network model is trained, and also how the tool processes statistical results. You can open and close the parameters side pane by selecting the tool and then clicking the % icon. You can access additional parameters that provide advanced features by selecting Expert Mode in the Help menu.

## Features Parameters

The Blue Read tool has two hidden parameters, the same as the Oriented and Scaled parameters of the Blue Locate tool. For the Blue Read tool, these parameters are enabled by default, and cannot be disabled.

The Blue Read tool is set to use the Non-uniform option for the Scaled parameter. To allow you to specify the range of characters sizes, in pixels, for correct character matching in runtime, the Angle Range and the Size Range are available under Processing. Characters with sizes in the search range are matched, and those outside the range are not matched. As the Non-uniform is default for Blue Read, the "size" of the character is defined as the geometric mean of the X- and Y- dimension of the character.

When considering the runtime scale range for non-uniform scale, the scale of a particular found feature is equal to the geometric mean of the X- and Y-sizes of the found feature, divided by the geometric mean of the X- and Y-sizes of the Feature Size.

## Sampling Parameters

The Sampling parameters control the way that images are sampled you train and process Focused mode tools. For more information, see Feature Sampling.

Note: If you change the Sampling parameters of an already trained tool, you must retrain the tool because the underlying image statistics might be changed.

Parameter | Expert Mode | Description
Feature Size | No | Specifies the typical feature diameter in pixels. The Feature Size is displayed in the lower left of the image, and you can resize it within the image to set a more accurate size. The feature size should be approximately the size of the bounding box of a typical "A" or "E" character. Feature size strongly influences processing time (n2). In other words,, a Feature Size of 100 is 100 times faster than a size of 10, while a Feature Size less than 15 usually does not yield good results. When setting the Feature Size, consider the following in regards to processing time (Ptime): Note: The tool sees an area five times larger than the Feature Size setting. However, the level of detail is much higher in the center of the feature than in the periphery. For more information, see Feature Size.
Polarity | No | Specifies the polarity of the image. The Blue Read tool is pre-trained on a set of images with a consistent text and background polarity. In other words, dark text on a light background. If you have a data set of images with an inverse polarity, change the polarity by selecting Inverted. When set to Inverted, the images in the image display and in the main display show the corrected polarity. Note: This change in polarity only applies to the Blue Read tool, and any child tools in the tool chain keep the original image greyscale polarity.
Border Type | Yes | Specifies how pixels on the outside of the image are sampled. Adding an additional mask at the boundaries of the image highly reduces the false detection rate. Black: Fills the outside of the image with a solid color, black. Replicate: Fills the outside of the image with the last pixel.
Masking Mode | Yes | Specifies how a mask is applied to the sampled image. A mask is used to limit areas of the image processed by the tool. Masks can be set after training, however, setting them before training helps the learning phase. Transparent: Collects samples within the unmasked parts of the image, but also collects data from the Context Region from the areas that are masked. This ensures that features or defects that are at the boundary of the mask or ROI generate the same response as features or defects that are in the center. Mask: Ignores the pixels in the masked parts of the image during training and runtime. This setting also alters the response of the tool to defects or features near the mask boundary. This setting also works to focus the tool toward the center of the ROI. Overlay: Adds the mask to the sampled image as an additional color channel.

## Training Parameters

The Training tool parameters control the training process.

Note: If you change the training parameters of an already trained tool, you must retrain the tool.

Parameter | Expert Mode | Description
Training Set | No | Specifies the training data set used to create a neural network model. The system only extracts the features of the images that are included in the training set. Click Edit to open a dialog where you can specify the sample sets and the percentage of the labeled images used as training samples. The system selects the training images randomly each time you start training.
Epoch Count | No | Specifies the number of optimization iterations done during training. Use a lower value when your application has limited complexity, or when creating a lower quality model for testing different parameter settings. The tools typically need to see the training image set data about 50 times, which is the default setting, and is typically sufficient for most standard applications. If you use fewer epochs, the neural network might get stuck in learning, or become unable to accurately solve the problem. However, if you use too many epochs, you risk overfitting. Note: If your training image set contains a large number of images, or the size of the images in your training image set are large compared to the Feature Size, you might need to increase the Epoch Count setting. There is a risk of overfitting if you have a very small training image set. If you have a large training image set, and your network is addressing all of the samples in the set, the network is much more general than if you have a smaller training image set and the network is keyed into that small sample set.

## Perturbation Parameters

With the Perturbation parameters, you can allow the tools to generate images that simulate the variations expected during runtime.

Read more...

For example, if your part rotates by +/-45 degrees, you can set the Rotation parameter, and the software rotates the images during training by that amount. However, image perturbation is not a substitute for collecting and training actual images. The image perturbations can only approximate the variations of real parts or scenes.

Note: For the best results, Cognex recommends using actual sample images of the part variations. When a part spins, there might be different shadows, which are not captured by the tool when the rotation is based on artificially spinning the image.

The Perturbation parameters are common across all of the tools, and you can use these parameters in combination. This way, you can generate more complex images by using the parameters separately, as well as in conjunction.

Note: All training image samples can be applied to perturbation. Every train image has 50% chance to be augmented to every checked options independently. By the law of large numbers, all perturbation options can be applied equally and trained by increasing the number of epochs.

Parameter | Expert Mode | Description
Aspect-Ratio | No | Specifies the normal distribution around 1 from which a perturbing aspect-ratio factor is drawn (if set to 0%, it is not applied).
Shear | No | Specifies the normal distribution around 1 from which a perturbing shearing factor is drawn (if set to 0%, it is not applied).
Luminance | No | Specifies the normal distribution around 1 from which a perturbing luminance factor is drawn (if set to 0%, it is not applied).
Contrast | No | Specifies the normal distribution around 1 from which a perturbing contrast factor is drawn (if set to 0%, it is not applied).
Invert Contrast | Yes | Randomly inverts the contrast in order to simulate contrast reversal in the training samples.

## Processing Parameters

The Processing parameters control the way the tool processes images. Processing (in another word, inferencing) with the same models always gives the same results. You do not need to retrain the tool after changing the Processing parameters. You can see the effect after reprocessing the database.

For a tool with a defined model, the features found during processing are searched for the feature collections that provide the best fit for the defined models.

Parameter | Expert Mode | Description
Sampling Density | No | Specifies the density of sampling points with respect to the Feature Size setting. The sampling density determines the degree of overlap between adjacent samples. A sampling rate of 1 means that the sampling location is incremented by the feature size between samples. The default sampling rate for most tools is 3, which means that the sampling location is incremented by one third of the feature size. The Sampling Density parameter affects the processing time and the accuracy of the tool. Higher Sampling Density settings are more accurate but significantly increase processing time. The processing time depends approximately quadratically to the Sampling Density (Sd) value. For example, a Sampling Density setting of 1 is approximately nine times faster than a setting of 3 (n2).
Threshold | No | Specifies how close the found feature must be to the desired feature to be detected. The found feature must exceed the setting.
Angle Range | No | Specifies the range (the minimum and the maximum values) of rotation that the tool can accommodate. The default values are [-10°, 10°].
Size Range | No | Specifies the range (the minimum and the maximum values) of scale that the tool can accommodate. The default values are [30, 60].
Feature Filter | Yes | Specifies a filter based on feature id, x, y, size and orientation, which is used as criteria for found features. By specifying a filter for features, features that do not match the filter are hidden from the results. If the parameter is left blank, all features are returned. Since this filtering is done after the tool has processed the images, the features are not removed, simply hidden from the results. Features that are not present due to the filter reappear, without reprocessing the image, by removing the filter criteria. Note: The syntax for filters is the same as the syntax used for Display Filters. For more information about constructing the syntax for a filter, see Custom Display Filters. For example, if you set the Feature Filter parameter as follows:
Feature Filter | Description
--- | ---
x in [0,view.width] and y in [0,view.height] | With this filter, only features whose center is within the ROI are returned.
(id = '0' and x < 200) or (x='1' and x > 200) | With this filter, assuming a view that is 400 pixels wide, features that have an ID of 0 and are on the left, and features that have an ID of 1 and are on the right, are returned.
As the Scaled parameter is enabled by default for the Blue Read tool, the tool can find both large and small characters and return matches at scale values where you do not intend to find. In this event, you can use the Feature Filter to remove the mismatched character features. You can define a mechanism to suppress the types of matches you want to avoid (for example "size > X or size < Y").