Package qupath.opencv.ml.objects
Class OpenCVMLClassifier<T>
java.lang.Object
qupath.lib.classifiers.object.AbstractObjectClassifier<T>
qupath.opencv.ml.objects.OpenCVMLClassifier<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
ObjectClassifier<T>
An
ObjectClassifier
that uses an OpenCVClassifiers.OpenCVStatModel
for classification.- Author:
- Pete Bankhead
-
Field Summary
Fields inherited from interface qupath.lib.classifiers.object.ObjectClassifier
PROJECT_LOCATION
-
Method Summary
Modifier and TypeMethodDescriptionint
classifyObjects
(ImageData<T> imageData, Collection<? extends PathObject> pathObjects, boolean resetExistingClass) Classify the objects in the specified collection.static <T> ObjectClassifier
<T> create
(OpenCVClassifiers.OpenCVStatModel model, PathObjectFilter filter, FeatureExtractor<T> extractor, List<PathClass> pathClasses) Create a newObjectClassifier
that uses anOpenCVClassifiers.OpenCVStatModel
for classification.getMissingFeatures
(ImageData<T> imageData, Collection<? extends PathObject> pathObjects) Check for missing features, returning the names and number of input objects missing the specified features.Get the classifications set by this classifier.toString()
Methods inherited from class qupath.lib.classifiers.object.AbstractObjectClassifier
classifyObjects, getCompatibleObjects
-
Method Details
-
create
public static <T> ObjectClassifier<T> create(OpenCVClassifiers.OpenCVStatModel model, PathObjectFilter filter, FeatureExtractor<T> extractor, List<PathClass> pathClasses) Create a newObjectClassifier
that uses anOpenCVClassifiers.OpenCVStatModel
for classification.- Type Parameters:
T
- generic type, which matches that of anImageData
- Parameters:
model
- theOpenCVClassifiers.OpenCVStatModel
used to apply the predictionfilter
- a filter used to select objects from a hierarchyextractor
- a feature extractor to determine features for each objectpathClasses
- available classifications; the order is important, and relates to the classification output- Returns:
-
getPathClasses
Description copied from interface:ObjectClassifier
Get the classifications set by this classifier.- Returns:
-
classifyObjects
public int classifyObjects(ImageData<T> imageData, Collection<? extends PathObject> pathObjects, boolean resetExistingClass) Description copied from interface:ObjectClassifier
Classify the objects in the specified collection. This provides a means to specify exactly which objects should be classified, avoiding reliance onObjectClassifier.getCompatibleObjects(ImageData)
.Note: this method does not typically fire any hierarchy change/object classification events. It is up to the caller to fire these events if required.
- Parameters:
imageData
- data that may or may not be required for classification depending upon how features are extractedpathObjects
- the objects to classifyresetExistingClass
-- Returns:
- the number of objects whose classification was changed.
- See Also:
-
toString
-
getMissingFeatures
public Map<String,Integer> getMissingFeatures(ImageData<T> imageData, Collection<? extends PathObject> pathObjects) Description copied from interface:ObjectClassifier
Check for missing features, returning the names and number of input objects missing the specified features. This is useful as a warning that the input for the classifier may not be valid. Default implementation returns an empty map; however, implementations should attempt to provide a meaningful output if possible. Features that are not missing should not be included in the output.- Parameters:
imageData
- image containing the objects to testpathObjects
- objects to test for missing features; if not available,ObjectClassifier.getCompatibleObjects(ImageData)
will be called.- Returns:
- a map of feature names and the number of objects missing the corresponding features.
-