Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Label Images for Classification Model Training

Description

The Training Image Labeler provides an easy way to label objects in images. Using this app, you can:

  • Interactively specify rectangular regions of interest (ROIs) for multiple categories of objects.

  • Export ROIs for training or evaluating an object detector.

  • Train an object detector using the trainCascadeObjectDetector function.

Open the Training Image Labeler

  • MATLAB® Toolstrip: Open the Apps tab, under Image Processing and Computer Vision, click the app icon.

  • MATLAB command prompt: Enter trainingImageLabeler

App Controls

You can add an unlimited number of images to the Data Browser. You can then select, remove, and create ROIs, and save your session. When you are done, you can export the ROI information to an XML file.

Add Images

Use the Add Images icon to select and add images to the Data Browser. You can add more images at any time during your editing session. The source images remain in the folder where they were originally located. The app does not make copies of the original images or move them. If you rotate the images in the Data Browser, the app overwrites the images in their original location with the modified orientation.

The app provides a list of image thumbnails that you loaded for the session. Next to each thumbnail, you see the file name and number of ROIs created in that image.

Specify Regions of Interest

After you load images, you can delineate ROIs. You can switch between images and continue creating ROIs. The app allows you to create ROI Labels for multiple object categories. Each ROI label has a name and a color. First create the labels and then draw the ROIs in images.

Create labels:

  1. Click the Add ROI label for each object category.

  2. Name each ROI label and select its color.

  3. Select the category from the ROI labels list you created.

  4. Draw an ROI by dragging the cursor over the object in the image.

    • To modify the size of an ROI, click either the corner or side grips. To keep the aspect ratio of the ROI while changing its size, hold Shift.

    • To copy and paste an ROI, click within its border to select it. You can select one or more ROIs to move or to copy and paste.

    • To delete an ROI, click the red x in its upper-right corner.

    • If the object of interest fills the entire image, right-click the image and select Add full image ROI from the menu.

    To show or hide the label names in the currently displayed image, select Show ROI Labels.

You can also use the following common shortcuts:

  • Ctrl+C to copy

  • Ctrl+V to paste

  • Ctrl+X to cut

Remove, Rotate, and Sort Images

You can remove, rotate, or sort the images. Right-click any image to access these options. To select multiple images, press Ctrl+click. To select consecutive images, press Shift+click. To sort images by the number of ROIs, from least amount of ROIs contained in each image, right-click any image and select Sort list by number of ROIs.

New Session

When you start a new session, you can save the current session before clearing it.

Open Session

You can open a new session to replace or add to the current session. The app loads the selected MAT session file. To replace your current session, from the Open Session options, select Open an existing session. To combine multiple sessions, select Add session to the current session.

Save Session

You can name and save your session to a .MAT file. The default name is LabelingSession. The saved session file contains all the required information to reload the session in the state that you saved it. It contains the paths to the original images, the coordinates for the ROI bounding boxes for each image, file names, and logical information to record the state of the files.

Export ROIs

When you click Export ROIs, the app exports the ROI information to the MATLAB workspace as an M-by-N table containing the image file names and the ROIs. The image file names are stored in the first column of the table. The subsequent columns contain the ROIs for each category.

If you only have one ROI label, the app gives you the additional option to export the ROIs as a struct array. The structure contains two fields. One field stores the image file location and the other field stores the corresponding ROI information for each image.

Import ROIs

You can import ROIs created using another labeling method. The ROIs must be stored in a table using the same format as the ROIs exported by the app. The table can be a variable in the MATLAB workspace, or it can be saved as a MAT file.

See Also

Apps

Functions

More About

External Websites

Was this topic helpful?