# Image

The In-Sight Image tool processes the input image to enhance desirable features while removing or diminishing undesirable features. The result is an enhanced input image or a new output image that is better suited for additional data-extraction functions such as Blob or Histogram analysis.

Note: Functions that require an Image parameter must reference a spreadsheet cell that contains a valid Image data structure. The default Image parameter reference is cell A0 , which contains the Image data structure returned by the AcquireImage function. Other valid Image parameters include Image data structures returned by the CompareImage, FindCircleDefects, and Filter functions.

## Image Processing

Machine vision applications need high-quality images. Data is lost when images are unfocused, warped or poorly lit, which can cause data-extraction functions such as Blob or Histogram analysis to operate poorly or even fail.

The first step to producing high-quality images is to ensure that hardware and environmental issues such as lighting and lenses are optimized during equipment setup so that the acquired images are sharply focused, undistorted and evenly illuminated. If there is difficulty extracting the desired data from images, the second step might be to use an Image function to enhance the images further.

As are all photos, In-Sight Spreadsheet images are raster graphics. Raster graphics store information about image characteristics in a grid of picture elements ("pixels"), which are the smallest complete samples of an image and are not scalable. The quality of a raster image is determined by the total number of pixels (known as "resolution") and the amount of information in each pixel.

To enhance the desired object and remove or diminish distracting features in images—for example, by adjusting color, brightness, contrast, or scaling—the In-Sight Spreadsheet Image functions employ sophisticated image-processing algorithms to add or subtract data from individual pixels or groups of adjacent pixels (known as "neighbors").

## When Image Processing Is Used

Image functions can be used for any of the following conditions:

- The acquired image displays little contrast between the object and its background.
- The acquired image contains distracting features that minimize the visual impact of the object.
- The acquired image is out of focus, and adjustments to the vision system lens are needed.
- An enlarged, reduced, unbent, or unrotated version of the acquired image is required by another In-Sight Spreadsheet tool.
- A black-and-white version of the acquired image is required by another In-Sight Spreadsheet tool.

Image functions can perform a variety of image-processing operations. Most of the functions target a specific operation, but three are designed for multipurpose use. The following table lists common operations and the applicable Image functions.

Operation | Description | Applicable Image Function
--- | --- | ---
Brightness/Contrast | "Clips" (or "scales up" or "scales down") the greyscale value in each pixel to user-specified minimum and maximum values to modify brightness and contrast. | Filter
Expansion/ Contraction | Expands or contracts features in the input image or ROI. | Filter
Filling | Fills pixels with white or black values so that they resemble adjacent pixels. | Filter
Filtering | Blocks undesirable or unwanted data, while passing only desirable data. | Filter
Image Differences | Compares the input image with a template, another image or a shape to determine differences between the two. | CompareImage FindCircleDefects ImageMath
Inverse | Creates a "negative" of the image. | Filter
Lens Adjustment | Measures the lens focus so that it can be adjusted through an iterative process. | ComputeImageSharpness
Scaling (size) | Creates an enlarged or reduced version of the input image. | ScaleImage
Sharpening | Discovers edges (that is, areas in an image where pixel greyscale values change sharply) based on orientation (vertical, horizontal) or enhances edges by comparing a "smoothed" version of the image with the original. | Filter
Smoothing | Averages the greyscale values in a set of adjacent pixels ("neighbors") in the input image to diminish the effect of rapidly changing greyscale values. | Filter
Thresholding | Produces a black-and-white version of the input image or ROI based on a user-set threshold. | Filter FindCircleDefects ImageMath

## Why Image Processing Is Used

If failure occurs because of poor image quality, an Image function can help enhance the image so that the desired data is easier to extract. Some examples include:

- Reducing noise or changing the patterns of object connectivity for Blob analysis.
- Converting spatial features into greyscale values so that statistics can be computed for Histogram analysis.
- Minimizing confusing or unwanted spatial frequency characteristics from both the model and image pixel data, to improve the speed and reliability for Pattern Match template searching.

## How to Perform Image Processing

The image-processing procedure can be broken down into three steps:

- Step 1: Analyze the acquired image to determine whether image processing will help and what kind of modifications are needed.
- Step 2: Insert an appropriate Image function into the In-Sight spreadsheet and experiment with the parameters to determine the optimal settings for enhancing the image.
- Step 3: If needed, insert another Image function into the In-Sight spreadsheet, reference it to the preceding function's output image and experiment with the parameter settings. Repeat as required.

As indicated, several Image functions might be needed to improve the quality of the acquired image, each referenced to the output of a subsequent Image function.

Note: The degree of improvement possible with the Image tool depends on the quality of the acquired image, which, in turn, is largely determined by external factors such as lighting and optics. The Image tool cannot make a bad photo good.