Manual for Pinta Trainer
Corresponding SW version
This manual corresponds to version 2.0.0-beta-5 of Pinta Trainer software.
Preparations
- Make sure you have the latest version. You can check this by selecting Help -> About from the main menu of Pinta. If you have an older version, download and install the latest from http://intopii.com/en/products/pinta/download.
- IMPORTANT! Collect a statistically descriptive set of images representing the problem you are trying to solve. The more the better, but at minimum you will need at least some tens of them. Save the training set in a single directory.
Selecting images for training the classifier
- Start Pinta Trainer.
- Press Browse in the Image File Reader box and browse to the directory that contains your training images.
- Press ctrl+a to select all the images in the directory. Left click with mouse while keeping ctrl pressed to select or unselect some of the images.
- Press Open to accept the selection.
Adjusting preprocessing options
Image Scaling
- Useful for reducing the amount of unnecessary detail in the image (it may cause the classifier to learn wrong things).
- Open Image Scaling under Preprocessing, check the Image Scaling checkbox, and select suitable size. If images do not need further scaling, leave the check box unchecked.
- NOTE: The default setting will work in many cases.
Image Splitter
- Useful for segmenting images using Pinta (i.e. divide each image into subregions of certain classes).
- Open the Image Splitter, check it, and adjust the size and overlapping of subregions.
- Subregions will be rectangular, x px wide and y px tall, determined by the Size settings. The default setting will create subregions of 32 by 32 pixels. Subregions will be spaced by x px horizontally and y px vertically, determined by the Spacing setting (0 means they will be adjacent, not overlapping, -10 means they will overlap ten pixels, +10 means there will be 10 pixels of empty space between them).
- Offset setting can be used to leave x pixels from images' left edge and y pixels from images' upper edge outside of analysis.
- If you want as precise segmentation as possible, set spacing to minus Size + 1 (if the size of subregions is 32 by 32, the spacing will be -31 by -31).
- NOTE: Overlapping increases the amount of image data the classifier has to digest, so beware of increased processing time and memory consumption!
Selecting suitable image features
Select one or more features to analyze. This is maybe the most critical step for the successful classification. First determine what are the distinguishing factor between the classes you want the classifier to divide your images into. Colors? Select Color Histogram or Color Percentiles. Brightness/Darkness/Distribution of gray scale values? Go for Gray-level Histogram. Texture or shapes? Go for Local Binary Patterns.
Local Binary Patterns (texture, stucture)
- Open and check Local Binary Patterns to classify by texture or shapes.
- NOTE: Please remember that this feature is strongly dependent of on scaling of the images.
- Select suitable option from the dropdown menu.
- Use Small scale LBP if the interesting features are variations in the small scale texture in the images.
- Use Multi-scale LBP if you are interested on larger scale variations (shapes) as well.
- Use Custom if you want to concentrate on the larger scale (shapes) only or want to make classification more invariant for rotation, for example. Using custom option requires understanding the inner workings of LBP.
- NOTE: The default setting (Multi-scale) will work in many cases.
Gray-Level Histogram (brightness, contrast)
- Open and check Gray-Level Histogram to classify by the distribution of gray scale values (distinguish between f.eg. bright, dark, and contrasty images).
- Set suitable number of histogram levels to use.
- Default (256) is the maximum and results in the most fine-grained classification.
- Reduce the number for coarser results.
Color Histogram (colors)
- Open and check Color Histogram to classify by the distribution of color values.
- Select Channel-wise from the drop-down to handle all channels separately.
- Select Multidimensional to combine all channels into a single multi-dimensional histogram.
- Select the number of levels as above.
Color Percentiles (colors)
- Open and check Color Percentiles to take another approach to classification based on the colors.
- Set type to Universal, mode to Absolute, Step to 10%, and Channels to R+G+B for most fine-grained classification.
- If the color temperature of the illumination or white balance settings in your images varies, try using Difference mode for more robust results.
- Try different Steps for best results.
- Prebuilt type includes two percentile configurations for wood classification, but they might be suitable for other uses as well (we have used them to detect rust from lettuce).
- NOTE: Using the Custom type requires understanding the inner workings of color percentiles (or good luck).
Color Correlogram (colors and their spatial distribution)
- Instructions coming soon. Please see http://bit.ly/cuKk71 for background information.
Adjusting the classifier
- Open Self-Organizing Map to configure the classifier
- Set the size of the map. The bigger the map the more fine-grained the result and more time consuming the learning and classification. For initial tests, use the default and experiment with different sizes as you gain some insight about the behaviour of the classifier in your application.
- Select suitable Weighting to adjust for possible inbalances in the training data.
- If some of the classes you want to classify your material into is under-represented by the samples or differences between some classes are distinct and between some other classes not so clear, select "Give rare data more weight" or "Give rare data even more weight".
- Use "Treat all data equally" if your samples are well balanced and differences between different classes are equally distinct.
- IMPORTANT! The result with "Give rare data even more weight" may be corrupted if you have a big map and not so many samples. To play safe, start by using the other two options.
- Use Learning slider to set how profoundly you want to teach the clasifier. Use the default setting or relatively low values (5-25%) for initial experiments and increase thoroughness when you start finalizing the training of your classifier.
Building the classifier
- Hit Build button in the toolbar to make the classifier start learning from the images.
- NOTE: The build process may take some time, depending on the number and resolution of images and processing options you selected. Let Pinta do the hard learning work and do something else in the meantime!
- Hit stop if you want to cancel build.
- When build is complete, review the results on the map.
Reviewing results
- If training was successful, similar images should be in the same or nearby cells, different images clearly farther away. Double-click on the cells to reveal their contents. Cells should contain similar images, probably with some confusion with neighboring cells. Different classes should form relatively contiguous areas on the map.
- If not:
- You might have not enough images to learn from or their quality might be too poor.
- Features you selected may not describe the properties you want the classifier to learn.
- The map might be too small.
- Classifier's weighting algorithm may be too weak for rarer samples.
- Classifier's learnign setting may be not thorough enough.
- If not safisfied with the results, adjust options and parameters and build again.
- To test with specific images, use Browse function in Image File Reader to select some images of interest and hit Run (not Build which makes the classifier relearn from the selected images!) to see how they settle on the map.
Assigning classes using a trained map
- Hit Edit Metrics button above the map to create classes you want to divide the map into.
- Give a descriptive name for the metric.
- Select suitable Type for the metric. Use Label for textual class names, numeric if you want to use some numeric range as an output.
- Add and assign names/set the value range for the metric using options below.
- Set color codes for labels/values.
- When satisfied, hit Ok, and start assigning the classes.
- Press left mouse button to select a cell from the map and select suitable class from the drop-down above the map. Number keys can be used as a shortcut to assign a class to selected cell(s). Drag mouse and/or click when holding down the crtl button to select multiple cells.
Remember to save your work!
- When completed, save your analyzer by pressing crtl+s, from the File menu, or by hitting the save or save as tool buttons. This will create a cft file (or save over the existing open file) that contains all the results of your work (excluding image data and paths to images).
- It's highly recommended to also save unfinished work once in a while, especially after a time consuming training phase, since Pinta does not offer autosave functionality at the moment.
Next steps
Congratulations! You have now a trained analyzer ready for action. Use Pinta API to integrate to your own software or open the saved analyzer from File -> Open for a new training/testing session later on.
Questions, problems?
Please check the instructions on our support landing page at http://intopii.com/support.