private Image FindBitmap(String fileName) { String rootName = OSservices.GetRootName(fileName); String fullFileName = OSservices.LookForFile(rootName + ".bmp", rootDir); if (String.IsNullOrEmpty(fullFileName)) { return(null); } else { return(new Bitmap(fullFileName)); } }
} /* LoadNextImageFromDir */ private String LocateRootName(String rootName) { String subDir = null; if (!String.IsNullOrEmpty(dir)) { subDir = OSservices.LookForFile(rootName + ".bmp", dir); } if (String.IsNullOrEmpty(subDir)) { if (!String.IsNullOrEmpty(dir2)) { subDir = OSservices.LookForFile(rootName + ".bmp", dir2); if (subDir == null) { return(null); } } } return(OSservices.AddSlash(subDir) + rootName + ".bmp"); } /* LocateRootName */
} /* LoadImageGrid */ private void UpdateDetailProbabilityDisplay(String fileName) { if (fileName == null) { return; } curSelImageFileName = fileName; String fullFileName = null; if ((fileName.Length > 1) && (fileName[1] == ':')) { fullFileName = fileName; } else { fullFileName = OSservices.AddSlash(rootDir) + fileName; } if (!File.Exists(fullFileName)) { String fn = OSservices.GetRootName(fileName) + ".bmp"; fullFileName = OSservices.LookForFile(fn, rootDir); } Prediction prediction = GetPrediction(fileName); // We need to call 'PredictProbabilities' twice. Once to get the intermediate images and the // second time to perform prediction using the FeatureVector that was used in the original // prediction. It has to be done this way because the version of 'PredictProbabilities' that // derives the FeatureVector from an image does not always have access of instrumentation data. PicesRasterList featureCalcImages = new PicesRasterList(); PicesPredictionList guesses2 = prediction.trainModel.PredictProbabilities(fullFileName, featureCalcImages); // Perform Prediction using original FeatureVector. PicesPredictionList guesses = prediction.trainModel.PredictProbabilities(prediction.fv); ImageFileName.Text = fileName; if (guesses == null) { return; } ClassificationProbabilities.Rows.Clear(); foreach (PicesPrediction p in guesses) { Object[] data = new Object[3]; data[0] = p.ClassName; data[1] = p.Probability; data[2] = p.Votes; ClassificationProbabilities.Rows.Add(data); } FeatureCalcImages.Rows.Clear(); if ((featureCalcImages == null) || (featureCalcImages.Count < 1)) { return; } for (int x = 0; x < featureCalcImages.Count; x++) { Object[] data = new Object[2]; data[0] = featureCalcImages[x].BuildBitmap(); data[1] = featureCalcImages[x].FileName; FeatureCalcImages.Rows.Add(data); } } /* UpdateDetailProbabilityDisplay */