# SurfaceFX

The SurfaceFX function performs feature enhancement, utilizing lighting to create a high contrast image which enhances three dimensional features on an object, for feature extraction and inspection by other Vision Tools. The function removes noise and/or clutter from the surface's background, isolating surface features that are engraved, embossed, stamped, etched, recessed or raised, as well as defects (such as chips, dents, wrinkles, punctures and tears). Once a contrast image is generated, other Vision Tools (such as OCRMax, TrainPatMaxRedLine and FindPatMaxRedLine, DetectBlobs, SurfaceFlaw and InspectEdge) can be used for inspections and defect detection.

The SurfaceFX algorithm requires four images to be acquired, in sequence, from four individual, low angular (less than 45°) light sources. The light sources should be spaced evenly around the circumference of a circle, with the object placed under the center of the lights. During the acquisition phase, the object should remain stationary, and the lighting and image acquisition sequence must be clockwise; starting from the right quadrant of the object, followed by the bottom quadrant, then the left quadrant, and finally the top quadrant.

The algorithm will then produce a surface irregularity image, with the raised features displayed in white, and indented features displayed in black.

## SurfaceFX Inputs

Parameter | Description
--- | ---
Right, Bottom, Left, Top | These arguments must reference a spreadsheet cell that contains a valid Image or LatchImage data structure, with low angular (less than 45°) lighting from the right, bottom, left or top of the object. Right = Input Image or LatchImage data structure 0, with illumination from the right (towards decreasing X) Bottom = Input Image or LatchImage data structure 1, with illumination from below (towards decreasing Y) Left = Input Image or LatchImage data structure 2, with illumination from the left (towards increasing X) Top = Input Image or LatchImage data structure 3, with illumination from above (towards increasing Y) Note: The SurfaceFX function operates on the entire Image data structure, whether that is an image acquired by an In-Sight camera, or an Image data structure output by another Vision Tool. Therefore, all of the Image data structures must have the same size. Otherwise, the tool will report #ERR. For example, if each of the acquired images was processed by a Filter function, (which outputs an Image data structure) before being passed into the Surface FX function, the SurfaceFX function will use the area of the acquired image defined by the Filter function's Region parameter, and all of the Filter function's Region parameters must be set to the same dimensions and angle. If using an Image data structure that is output by another Vision Tool, the function providing the Image data structure must have a rectangular image region, without curvature, and cannot use an External Region or an EditCompositeRegion. Also, the defined Region cannot undergo any curvature, or the SurfaceFX function will result in a #ERR. The Image data structures may be rotated, but the rotation of each input must be the same. Otherwise, the function will report #ERR. The Image data structures should have the same location and/or offset, but they may exhibit slight lateral movement. However, an excessive amount of lateral movement will result in a poor surface irregularity output image. All four Image data structures must be present, or the function will report #ERR.
Sigma | Specifies the smoothness value (0–10; default = 1) to help eliminate high-frequency noise in the output image.
Brightness | Specifies the average intensity (0–255; default = 128) of the background in the output image.
Contrast | Specifies the intensity difference (0–100; default = 10) between surface features and the background pixels in the output image.
Show | Specifies which graphical overlays are displayed on top of the image.
0 = hide all (default) | The available graphics items will be hidden, except when the cell containing the SurfaceFX function is highlighted in the spreadsheet.
1 = result graphics only | The processed image will be displayed on the view associated with the Image data structure referenced by the Right parameter at all times.

## SurfaceFX Outputs

Returns | An Image data structure containing the processed surface irregularity image, or #ERR if any of the input parameters are invalid.