---------------------------------------------------------------------------*/ * This routine matches blob to the built-in templates * to find out if there are any classes other than the correct * class which are potential ambiguities. * * @param Blob blob to get classification ambiguities for * @param CorrectClass correct class for Blob * * Globals: * - CurrentRatings used by qsort compare
| 1638 | * @note History: Fri Mar 15 08:08:22 1991, DSJ, Created. |
| 1639 | */ |
| 1640 | UNICHAR_ID *Classify::GetAmbiguities(TBLOB *Blob, |
| 1641 | CLASS_ID CorrectClass) { |
| 1642 | ADAPT_RESULTS *Results = new ADAPT_RESULTS(); |
| 1643 | UNICHAR_ID *Ambiguities; |
| 1644 | int i; |
| 1645 | |
| 1646 | Results->Initialize(); |
| 1647 | INT_FX_RESULT_STRUCT fx_info; |
| 1648 | GenericVector<INT_FEATURE_STRUCT> bl_features; |
| 1649 | TrainingSample* sample = |
| 1650 | BlobToTrainingSample(*Blob, classify_nonlinear_norm, &fx_info, |
| 1651 | &bl_features); |
| 1652 | if (sample == NULL) { |
| 1653 | delete Results; |
| 1654 | return NULL; |
| 1655 | } |
| 1656 | |
| 1657 | CharNormClassifier(Blob, *sample, Results); |
| 1658 | delete sample; |
| 1659 | RemoveBadMatches(Results); |
| 1660 | Results->match.sort(&UnicharRating::SortDescendingRating); |
| 1661 | |
| 1662 | /* copy the class id's into an string of ambiguities - don't copy if |
| 1663 | the correct class is the only class id matched */ |
| 1664 | Ambiguities = new UNICHAR_ID[Results->match.size() + 1]; |
| 1665 | if (Results->match.size() > 1 || |
| 1666 | (Results->match.size() == 1 && |
| 1667 | Results->match[0].unichar_id != CorrectClass)) { |
| 1668 | for (i = 0; i < Results->match.size(); i++) |
| 1669 | Ambiguities[i] = Results->match[i].unichar_id; |
| 1670 | Ambiguities[i] = -1; |
| 1671 | } else { |
| 1672 | Ambiguities[0] = -1; |
| 1673 | } |
| 1674 | |
| 1675 | delete Results; |
| 1676 | return Ambiguities; |
| 1677 | } /* GetAmbiguities */ |
| 1678 | |
| 1679 | // Returns true if the given blob looks too dissimilar to any character |
| 1680 | // present in the classifier templates. |
nothing calls this directly
no test coverage detected