Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        } /* SaveImagesByClass */

        private void  SaveImagesInList(PicesDataBaseImageList list,
                                       String dirName
                                       )
        {
            dirName = OSservices.AddSlash(dirName);
            curDir  = dirName;
            foreach (PicesDataBaseImage i in list)
            {
                if (cancelRequested)
                {
                    break;
                }

                String      fullName = dirName + i.ImageFileName + ".bmp";
                PicesRaster r        = dbConn.ImageFullSizeFind(i.ImageFileName);
                if (r == null)
                {
                    imagesFailedToExtract++;
                }
                else
                {
                    r.Save(fullName);
                }
                imagesSaved++;
            }
        } /* SaveImagesInList */
        public PredictionBreakDownDisplay(PicesDataBase _dbConn,
                                          PicesDataBaseImage _image,
                                          PicesRaster _raster,
                                          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;
            }

            if (_image == null)
            {
                return;
            }

            fileName       = _image.ImageFileName;
            instrumentData = _instrumentData;
            trainingModel  = _trainingModel;

            PicesRaster raster = _raster;

            if (_dbConn != null)
            {
                if (raster == null)
                {
                    raster = _dbConn.ImageFullSizeFind(fileName);
                }

                if (instrumentData == null)
                {
                    instrumentData = _dbConn.InstrumentDataGetByScanLine(_image.SipperFileName, _image.TopLeftRow);
                }

                dbFeatureVector = _dbConn.FeatureDataRecLoad(fileName);
            }

            if (raster == null)
            {
                return;
            }

            //raster = raster.ConnectedComponent ();

            featureCalcImages = new PicesRasterList();
            featureVector     = new PicesFeatureVector(raster, fileName, featureCalcImages, runLog);
            if (instrumentData != null)
            {
                featureVector.AddInstrumentData(instrumentData);
            }

            InitializeComponent();
        }
        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();
        }
Beispiel #5
0
        //SMP751001034_02_00025491_3588



        private void  SaveSampleImages(PicesDataBaseImageList planktonData)
        {
            PicesClassList classes = planktonData.ExtractListOfClasses();

            if (classes == null)
            {
                return;
            }

            String sampleDir = OSservices.AddSlash(OSservices.GetPathPartOfFile(dataFileName)) +
                               OSservices.GetRootName(dataFileName) +
                               "_SampleImages";

            sampleDir = OSservices.AddSlash(sampleDir);
            OSservices.CreateDirectoryPath(sampleDir);

            foreach (PicesClass pc in classes)
            {
                String classSampleDir = OSservices.AddSlash(sampleDir + pc.Name);
                OSservices.CreateDirectoryPath(classSampleDir);
                PicesDataBaseImageList examplesThisClass = planktonData.ExtractExamplesForAGivenClass(pc);
                examplesThisClass.RandomizeOrder();

                int numWritten = 0;
                foreach (PicesDataBaseImage i in examplesThisClass)
                {
                    String imageRootName = OSservices.GetRootName(i.ImageFileName);

                    PicesRaster fullSizeImage = dbConn.ImageFullSizeFind(imageRootName);
                    if (fullSizeImage != null)
                    {
                        String imageFileName = classSampleDir + imageRootName + ".bmp";
                        fullSizeImage.Save(imageFileName);
                        ++numWritten;
                    }
                    if (numWritten >= includeSampleImagesNumPerClass)
                    {
                        break;
                    }
                }
            }
        } /* SaveSampleImages */
Beispiel #6
0
        private void  SaveOneBatchOfImages(String dirPath,
                                           Dictionary <String, int> imagesPerClass,
                                           PicesDataBaseImageList batch
                                           )
        {
            if (classKeyToUse == 'V')
            {
                batch.Sort(PicesDataBaseImageList.SortOrderType.soValidatedClassName, false);
            }
            else
            {
                batch.Sort(PicesDataBaseImageList.SortOrderType.soClassName, false);
            }

            int idx = 0;
            PicesDataBaseImage i = batch[0];

            while ((idx < batch.Count) && (!cancelRequested))
            {
                String className = i.Class1Name;
                if (classKeyToUse == 'V')
                {
                    className = i.ValidatedClassName;
                }

                String curClassName = className;

                String classDir = OSservices.AddSlash(dirPath) + className;

                try { OSservices.CreateDirectoryPath(classDir); }  catch (Exception)  {}

                int countThisClass = 0;
                if (imagesPerClass.ContainsKey(curClassName))
                {
                    countThisClass = imagesPerClass[curClassName];
                }
                else
                {
                    imagesPerClass.Add(curClassName, 0);
                }

                int    lastFoldNum = -1;
                String foldDir     = "";

                while ((idx < batch.Count) && (!cancelRequested) && (className == curClassName))
                {
                    int foldNum = countThisClass / imagsPerDir;

                    if (foldNum != lastFoldNum)
                    {
                        foldDir = OSservices.AddSlash(classDir) + curClassName + "_" + foldNum.ToString("000");

                        OSservices.CreateDirectoryPath(foldDir);
                        lastFoldNum = foldNum;
                    }

                    String      fullName = OSservices.AddSlash(foldDir) + i.ImageFileName + ".bmp";
                    PicesRaster r        = dbConn.ImageFullSizeFind(i.ImageFileName);
                    if (r == null)
                    {
                        imagesFailedToExtract++;
                    }
                    else
                    {
                        r.Save(fullName);
                    }
                    imagesSaved++;

                    // Get the next image to save.
                    idx++;
                    if (idx < batch.Count)
                    {
                        i         = batch[idx];
                        className = i.Class1Name;
                        if (classKeyToUse == 'V')
                        {
                            className = i.ValidatedClassName;
                        }
                    }

                    countThisClass++;
                }

                imagesPerClass[curClassName] = countThisClass;
            }
        } /* SaveOneBatchOfImages */