NI Classification Training Interface Tutorial

NI Classification Training Interface

NI Classification Training Interface Tutorial

This tutorial guides you through the steps for classifying samples with the classification engine using a specific set of images. This tutorial illustrates the various steps required to classify varying representations of the same class.

This tutorial includes the following sections:

Classifying Samples with the Classification Engine

Complete the following steps to classify samples with the classification engine:

  1. Complete one of the following steps to launch the NI Classification Training Interface:
    1. If you are using Vision Builder for Automated Inspection (Vision Builder AI) or Vision Assistant, click New/Edit Classifier File.
    2. If you are not using Vision Builder AI or Vision Assistant, click Start»Programs»National Instruments»Vision»Classification Training.
  2. Save the Classifier File as Tutorial.clf and Click OK.
  3. Complete one of the following sets of steps to select the tutorial images:
    • NI Vision and Vision Assistant
      1. Click File»Open Images.
      2. Navigate to <Vision>\Images\Classification Tutorial, where <Vision> is the location to which you installed the NI Vision Development Module.
      3. Select the following images:
        Tip  You can select multiple image files by pressing the <Ctrl> key and clicking each file. Enable the Select all files checkbox to open all images in the directory you specified.
      4. Click Open.
    • Vision Builder AI
      1. Navigate to <Vision Builder AI>\DemoImg\Classification, where <Vision Builder AI> is the location to which you installed Vision Builder AI.
      2. Select the following images:
        Tip  You can select multiple image files by pressing the <Ctrl> key and clicking each file. Enable the Select all files checkbox to open all images in the directory you specified.
      3. Click Open.
    Tip  Click each of the image file names above to view the tutorial steps associated with the image. Click each image to return to the list above.
  4. Click Open.
  5. Use the navigation buttons to locate Parts00.png.
  6. Make sure your Preprocessing options are set properly. Select Clustering for the Method of thresholding, and select Dark Objects from the Look For drop-down menu.
  7. Draw an ROI around the bolt in the image.
    Tip  It may be necessary to include parts of other objects in the ROI you draw around the bolt to successfully contain the entire bolt in the ROI. To configure the classification engine to classify the sample of the bolt correctly even though the ROI contains part of another object, enable Reject Objects Touching ROI on the Preprocessing tab.

    The NI Classification Training Interface displays the objects in the ROI according to the preprocessing settings. When the preprocessing settings are configured to use a clustering method of thresholding and to look for dark objects, the objects in the ROI are blue.

  8. Select Add New Label from the Class Label list. Enter Bolt for the New Label.
  9. Click OK.
  10. Navigate to the Parts01.png file.
  11. Draw an ROI around a bolt in the image.

  12. Check that the Class Label control reads Bolt and click Add Sample.
  13. Select the Classify tab, and click Train Classifier.
  14. Navigate to the Bolt00.png file.
  15. Draw an ROI around the bolt in the image.

  16. Verify that the object in the ROI is classified correctly by checking that the Assigned Class Label indicator reads Bolt. The Classification Score is 1000 because you have only defined one class.
  17. Navigate to the Bolt01.png file.
  18. Draw an ROI around the bolt in the image.

  19. Verify that the sample in the ROI is classified correctly by checking that the Assigned Class Label indicator reads Bolt.

Complete the following steps to train and classify motors.

  1. Use the navigation buttons to locate Parts00.png.
  2. Make sure your Preprocessing options are set properly. Select Clustering for the Method of thresholding and select Dark Objects from the Look For drop-down menu.
  3. Draw an ROI around a motor in the image.
    Tip  It may be necessary to include parts of other objects in the ROI you draw around the motor to successfully contain the entire motor in the ROI. To configure the classification engine to classify the sample of the motor correctly even though the ROI contains part of another object, enable Reject Objects Touching ROI on the Preprocessing tab.

    The NI Classification Training Interface displays the objects in the ROI according to the preprocessing settings. When the preprocessing settings are configured to use a clustering method of thresholding and to look for dark objects, the objects in the ROI are blue.

  4. Select Add New Label from the Class Label list. Enter Motor for the New Label.
  5. Click OK.
  6. Navigate to the Parts01.png file.
  7. Draw an ROI around the motor in the image.

  8. Check that the Class Label control reads Motor and click Add Sample.
  9. Select the Classify tab, and click Train Classifier.
  10. Navigate to the Motor00.png file.
  11. Draw an ROI around a motor in the image.

  12. Verify that the sample in the ROI is classified correctly by checking that the Assigned Class Label indicator reads Motor.
  13. Navigate to the Motor01.png file.
  14. Draw an ROI around the motor in the image.

  15. Verify that the sample in the ROI is classified correctly by checking that the Assigned Class Label indicator reads Motor.

Editing the Classifier File

Use the Edit Classifier tab to view the thumbnail images and descriptive information about the samples classified.

The following list includes descriptions of each of the items on the Edit Classifier tab.

  • Use the Classifier File Description text box to input descriptive characteristics about the classifier file.
  • Use the Relabel button to change the class to which a sample belongs.
  • Use the Delete button to delete a sample from the browser.
  • Use Browser Display to display either all of the trained samples or only the samples of a certain class. If you select to display Samples of Class, you can select the class to display, and the number of samples in that class appears in the Samples indicator.
  • Use the Class Population chart to graphically display the number of each type of different class of samples in the classifier file as well as the total number of samples.

Saving the Classifier File

Now that you have classified several objects, you are ready to save the classifier file. Each classifier file contains the current state of the classification engine options as well as the samples you have trained.

  1. Use the navigation buttons to scroll through the images you classified in this tutorial. Review each image, and check that the class to which the image belongs is correct. When you hover your mouse over the thumbnail image in the Edit Classifier tab, the class name appears in the lower right corner below the image window.
  2. Relabel any images that are not correctly labeled by selecting the image from the browser and clicking Relabel. The Relabel Sample dialog opens. Type the correct label for the image in the New Label control.
  3. Delete any unwanted images by selecting the image in the browser and clicking Delete.
  4. Click File»Save Classifier File, enter Tutorial.clf in File Name for the classifier file, and then click Save.