# Setting Up the Red Analyze Block

With the VisionPro® Tool Block configured and outputting a pose to transform the images, you can add and configure a Red Analyze Tool to inspect the surface of your object.

1. Working within the ViDi Sub Task block, from the Task Toolbox, open the ViDi Tools node and select the Analyze tool.

2. Drag and drop the Analyze tool block into the ViDi Sub Task. The image pin should be automatically connected after dropping the block.

3. Connect the output pin of the VisionPro® Tool Block to the Pose input pin of the Analyze tool block.

4. Before using the Analyze tool, open the Database Editor of the ViDi Sub Task.

5. Press the Scissors icon to process the images based on the transform of the CogPMAlignTool.

6. Go back to the ViDi Sub Task and open the Analyze tool. The images should now all have the same orientation, due to the transform being provided by the CogPMAlignTool.

7. In the Image Display Area, right-click and select Edit ROI from the menu.

8. Adjust the size of the Region of Interest (ROI) so that it only encompasses the object.

9. Press the Apply button and the tool will adjust the ROI for all the images. Press the Close button to finish editing the ROI.

10. The Analyze tool will perform better if you exclude extraneous areas of the image from the inspection by using a mask. In the Image Display Area, right-click and select Edit Mask from the menu.

11. In this example, we will be applying a mask to the background, the small circles on the surface and the half-moon shape.

12. Select the Circle Tool, and from the center of the dial, draw the circle outward to the edge.

13. With the circle mask in place, press the Invert button to have the mask cover the outside of the circle.

14. Select the Circle Tool and apply circle masks to each of the other circular features in the image.

15. Select the Magic Wand tool, and holding down the Shift key, drag the wand over the shape to fill it in.

16. With all of the masks in place, press the Apply button, which will launch the Apply Mask dialog, allowing you to apply the mask to all of the images.

17. Press the Close button to close the Edit Mask phase. The mask should now be applied to all of the images.

18. Now go through all of the images and label them as Good or Bad.

19. Once all of the labels have been applied, press the Brain icon to train the tool.
20. Review the results and validate that the tool correctly marked the defects. If you have to adjust any of the parameters associated with training, or you have to re-label an image, you will need to retrain the tool and re-validate the results.
21. Once you are satisfied with the results being output by the tool, return to the ViDi Sub Task.
22. The Analyze tool block will automatically have three output pins by default: Markings, which contains the data about the detected defects, the Pass/Fail result, and the Score for each image.

23. Connect the three outputs to the output block of the ViDi Sub Task.

    Note: For more information about configuring the input and output pins of a ViDi Sub Task block, see the Sub Task topic in the Cognex Designer User Guide.

24. In the Task containing the ViDi Sub Task block, there should now be three output pins on the ViDi Sub Task block.