private void ViewImage(Object sender, EventArgs e) { String imageFileName = lastSelectedImage; PicesDataBaseImage pi = dbConn.ImageLoad(imageFileName); if (pi != null) { PicesRaster pr = dbConn.ImageFullSizeFind(imageFileName); ImageViewer iv = new ImageViewer(pr, pi, null); iv.ShowDialog(this); } }
} /* DeriveRandomDistByDepth */ private PicesDataBaseImageList GetDatabaseImageRecords(PicesDataBase threadConn, List <ImageEntry> images ) { RunLogAddMsg("Extracting Images from the database." + "\n"); PicesDataBaseImageList dataBaseImages = new PicesDataBaseImageList(); foreach (ImageEntry ie in images) { if (cancelHarvesting) { break; } PicesDataBaseImage dbi = threadConn.ImageLoad(ie.imageId); if (dbi == null) { RunLogAddMsg("GetDatabaseImageRecords ***ERROR*** Could not get ImageId[" + ie.imageId + "]" + "\n"); } else { dataBaseImages.Add(dbi); if ((dataBaseImages.Count % 100) == 0) { RunLogAddMsg("Images Extracted " + dataBaseImages.Count + " of " + images.Count + "\n"); } } } return(dataBaseImages); } /* GetDatabaseImageRecords */
public PredictionBreakDownDisplayDual(PicesDataBase _dbConn, String _fileName, TrainingModel2 _trainingModel, PicesInstrumentData _instrumentData, /**< Instrument data that goes with image, if null will read from dtabase. */ PicesRunLog _runLog ) { if (_runLog == null) { runLog = new PicesRunLog(); } else { runLog = _runLog; } fileName = _fileName; instrumentData = _instrumentData; trainingModel = _trainingModel; PicesDataBase dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog); PicesRaster raster = dbConn.ImageFullSizeFind(fileName); if (raster == null) { return; } if (_dbConn != null) { dbFeatureVector = _dbConn.FeatureDataRecLoad(_fileName); if (instrumentData == null) { PicesDataBaseImage image = dbConn.ImageLoad(fileName); if (image != null) { instrumentData = dbConn.InstrumentDataGetByScanLine(image.SipperFileName, image.TopLeftRow); } } } featureVector = new PicesFeatureVector(raster, fileName, null, runLog); if (instrumentData != null) { featureVector.AddInstrumentData(instrumentData); } dbConn.Close(); dbConn = null; GC.Collect(); InitializeComponent(); }
public PredictionBreakDownDisplay(PicesDataBase _dbConn, String _fileName, TrainingModel2 _trainingModel, PicesInstrumentData _instrumentData, /*!< Instrument data that goes with image, if null will read from database. */ PicesRunLog _runLog ) { if (_runLog == null) { runLog = new PicesRunLog(); } else { runLog = _runLog; } fileName = _fileName; instrumentData = _instrumentData; trainingModel = _trainingModel; PicesRaster raster = _dbConn.ImageFullSizeFind(fileName); if (raster == null) { return; } if (_dbConn != null) { dbFeatureVector = _dbConn.FeatureDataRecLoad(_fileName); if (instrumentData == null) { PicesDataBaseImage image = _dbConn.ImageLoad(fileName); if (image != null) { instrumentData = _dbConn.InstrumentDataGetByScanLine(image.SipperFileName, image.TopLeftRow); } } } featureCalcImages = new PicesRasterList(); featureVector = new PicesFeatureVector(raster, fileName, featureCalcImages, runLog); if (instrumentData != null) { featureVector.AddInstrumentData(instrumentData); } InitializeComponent(); }
} /* ProcessDirectory */ private void ProcessOneImage(String fullImageFileName) { String rootName = OSservices.GetRootName(fullImageFileName); PicesDataBaseImage i = dbConn.ImageLoad(rootName); if (i != null) { runStatsImagesInDataBase++; return; } String sipperFileName = null; uint scanLine = 0; uint scanCol = 0; PicesFeatureVector.ParseImageFileName(fullImageFileName, ref sipperFileName, ref scanLine, ref scanCol); if (String.IsNullOrEmpty(sipperFileName) || (scanLine < 1)) { // We are not going to be able to locate this image in the Database. runStatsImagesNotInDataBase++; reconcilingRunLog.Writeln(fullImageFileName + "\t" + "Name format will not let me derive needed info."); return; } String sqlStr = "call ImagesLocateClosestImage(" + "\"" + sipperFileName + "\"" + ", " + scanLine.ToString() + ", " + scanCol.ToString() + ")"; String[][] results = dbConn.QueryStatement(sqlStr, null); if ((results == null) || (results.Length < 1)) { runStatsImagesNotInDataBase++; reconcilingRunLog.Writeln(fullImageFileName + "\t" + "Could not find an appropriate image in the Database"); RemoveImage(fullImageFileName); return; } String correctImageFileName = results[0][1]; String newFullName = OSservices.AddSlash(OSservices.GetPathPartOfFile(fullImageFileName)) + correctImageFileName + "." + OSservices.GetFileExtension(fullImageFileName); OSservices.RenameFile(fullImageFileName, newFullName); runStatsImagesFixed++; } /* ProcessOneImage */
} /* DeriveFracPartByDepth */ private PicesDataBaseImageList DeriveRandomDistribution(PicesDataBase connThread, List <ImageEntry> images ) { RunLogAddMsg("Extracting Images Randomly." + "\n"); PicesDataBaseImageList randDist = new PicesDataBaseImageList(); DateTime d = DateTime.Now; int miliSecsInDay = d.Millisecond + d.Second * 1000 + d.Minute * 60000 + d.Hour * 360000; Random randomGenerator = new Random(miliSecsInDay); RandomSortImageEntryList(images, randomGenerator); foreach (ImageEntry ie in images) { PicesDataBaseImage dbi = connThread.ImageLoad(ie.imageId); if (dbi == null) { RunLogAddMsg("DeriveRandomDistribution ***ERROR*** Could not get ImageId[" + ie.imageId + "]" + "\n"); } else { randDist.Add(dbi); if ((randDist.Count % 100) == 0) { RunLogAddMsg("Images Extracted " + randDist.Count + " of " + images.Count + "\n"); } } if (randDist.Count >= howManyToHarvest) { break; } } return(randDist); } /* DeriveRandomDistribution */
private void ImportImage(PicesDataBase threadConn, String fileName ) { String rootName = OSservices.GetRootName(fileName); String picesRootName = sipperFileName + "_" + rootName; PicesDataBaseImage dbi = threadConn.ImageLoad(picesRootName); if (dbi != null) { return; } PicesRaster r = new PicesRaster(fileName); r = r.Padded(2); PicesFeatureVector fv = new PicesFeatureVector(r, picesRootName, null, runLog); fv.ExampleFileName = picesRootName; int imageId = 0; bool successful = false; uint centroidRow = (uint)(0.5f + fv.CentroidRow); uint centroidCol = (uint)(0.5f + fv.CentroidCol); if ((centroidRow < 0) || (centroidRow > r.Height)) { centroidRow = (uint)(r.Height / 2); } if ((centroidCol < 0) || (centroidCol > r.Width)) { centroidCol = (uint)(r.Width / 2); } threadConn.ImageInsert(r, picesRootName, sipperFileName, 0, 0, 0, (uint)r.Height, (uint)r.Width, (uint)fv.OrigSize, 3, extractionLogEntryId.LogEntryId, extractionLogEntryId.LogEntryId, centroidRow, centroidCol, unknownClass, 1.0f, null, 0.0f, null, 0.0f, // depth, 0.0f, // Image Size null, ref imageId, ref successful ); if (successful) { threadConn.FeatureDataInsertRow(sipperFileName, fv); } else { RunLogAddMsg("RootName[" + rootName + "] Failed: " + threadConn.LastErrorDesc() + "\n"); } } /* ImportImage */