Ejemplo n.º 1
0
        public void saveToCSV(CSVStructure record, String path)
        {
            CSVRecord rec = record.getRecordFromStructure(path);

            saveRecordsToCsv(new CSVRecord[] { rec });
            MessageBox.Show("Zapisano wiersz:\n" + buildRecordString(rec));
        }
Ejemplo n.º 2
0
        public Image drawPierscien(Image im, CSVStructure ob)
        {
            Graphics g = Graphics.FromImage(im);

            for (int i = 0; i < ob.PierscienStartAngle.Count; i++)
            {
                float penWidth = ob.PierscienR[i] - ob.PierscienStartR[i];

                int       diameter = (int)ob.PierscienR[i] * 2 - (int)penWidth;
                int       rectLeft = ob.PierscienX - (int)(diameter / 2);
                int       rectTop  = ob.PierscienY - (int)(diameter / 2);
                Pen       myPen    = new Pen(kolorPierscien, penWidth);
                int       arc      = (int)ob.PierscienStopAngle[i] - (int)ob.PierscienStartAngle[i];
                Rectangle rect     = new Rectangle(rectLeft, rectTop, diameter, diameter);
                g.DrawArc(myPen, rect, (int)ob.PierscienStartAngle[i], arc);
            }



            return(im);
        }
Ejemplo n.º 3
0
        private void loadPatientInfo()
        {
            PatientCountValue.Text = "" + pathStorer.currentPath;
            PatientRecord rec = InformationCSVMerger <PatientRecord> .getRecord(pathStorer.paths[pathStorer.currentPath], cSVMerger.getRecords());

            if (rec == null)
            {
                SexValue.Text       = "";
                AgeValue.Text       = "";
                ICDValue.Text       = "";
                DescriptionBox.Text = "";
            }
            else
            {
                SexValue.Text       = rec.sex;
                AgeValue.Text       = rec.age;
                ICDValue.Text       = rec.correct_icd_code;
                DescriptionBox.Text = rec.description1;
            }
            CSVStructure = CSVStructure.getStructure(pathStorer.getCurrentRecord());
            loadImageInfo();
        }
Ejemplo n.º 4
0
        public Image Draw(CSVStructure ob)
        {
            Image im = (Image)image.Clone();

            if (visibityPierscien)
            {
                im = drawPierscien(im, ob);
            }
            if (visibitySrodek)
            {
                im = drawCenter(im, ob.SrodekX, ob.SrodekY, Color.Blue, ob.SrodekR, new float[] { 1, 4 });
            }
            if (visibityWyjscie)
            {
                im = drawCenter(im, ob.WyjscieX, ob.WyjscieY, kolorWyjscie, ob.WyjscieR, new float[] { 1, 1 });
            }
            //--------------------------------------------------------------------------------PROMIEN + 2
            if (repoWyjscieDraw)
            {
                im = fillCircle(im, ob.WyjscieX, ob.WyjscieY, Brushes.White, ob.WyjscieR);
            }
            return(im);
        }
Ejemplo n.º 5
0
 private void Form_KeyDown(object sender, KeyEventArgs e)
 {
     e.Handled = true;
     if (e.KeyCode.Equals(Keys.P))
     {
         labelledPatients = Utils.GetNewVal(labelledPatients, 1, maxVal: 1, minVal: 0);
         refreshFeatures();
     }
     if (e.KeyCode.Equals(Keys.B))
     {
         drawer.visibitySrodek ^= true;
         refreshFeatures();
     }
     if (e.KeyCode.Equals(Keys.N))
     {
         drawer.visibityWyjscie ^= true;
         refreshFeatures();
     }
     if (e.KeyCode.Equals(Keys.M))
     {
         drawer.visibityPierscien ^= true;
         refreshFeatures();
     }
     if (e.KeyCode.Equals(Keys.Delete))
     {
         pathStorer.deleteLoadedRecord();
         refreshFeatures();
     }
     if (e.KeyCode.Equals(Keys.Back))
     {
         CSVSaver.deleteRecord();
         refreshFeatures();
     }
     if (e.KeyCode.Equals(Keys.Q))
     {
         CSVStructure = new CSVStructure();
         refreshFeatures();
     }
     if (e.KeyCode.Equals(Keys.L))
     {
         CSVStructure.eye      = Utils.GetNewVal(CSVStructure.eye, 1, 1);
         CSVStructure.eyeImage = ImageValue.Text;
         refreshFeatures();
     }
     if (e.KeyCode.Equals(Keys.Z))
     {
         CSVStructure.changeCurrentAngle(-1);
         refreshFeatures();
     }
     if (e.KeyCode.Equals(Keys.X))
     {
         CSVStructure.changeCurrentAngle(1);
         refreshFeatures();
     }
     if (e.KeyCode.Equals(Keys.Escape))
     {
         CSVStructure.Width  = ImageSlider.WIDTH;
         CSVStructure.Height = ImageSlider.HEIGHT;
         CSVSaver.saveToCSV(CSVStructure, pathStorer.paths[pathStorer.currentPath]);
     }
     if (e.KeyCode.Equals(Keys.Space))
     {
         CSVSaver.addDeleted();
         refreshFeatures();
     }
     if (e.KeyCode.Equals(Keys.A))
     {
         if (CSVStructure != null)
         {
             pathStorer.storeCSVRecord(CSVStructure.getRecordFromStructure(pathStorer.paths[pathStorer.currentPath]));
         }
         slider = new ImageSlider(pathStorer.changePath(-1, labelledPatients: labelledPatients), pictureBox1);
         loadPatientInfo();
         refreshFeatures();
     }
     if (e.KeyCode.Equals(Keys.D))
     {
         if (CSVStructure != null)
         {
             pathStorer.storeCSVRecord(CSVStructure.getRecordFromStructure(pathStorer.paths[pathStorer.currentPath]));
         }
         slider = new ImageSlider(pathStorer.changePath(1, labelledPatients: labelledPatients), pictureBox1);
         loadPatientInfo();
         refreshFeatures();
     }
     if (e.KeyCode.Equals(Keys.Left))
     {
         slider.slide(-1);
         loadImageInfo();
     }
     if (e.KeyCode.Equals(Keys.Right))
     {
         slider.slide(1);
         loadImageInfo();
     }
     if (e.KeyCode.Equals(Keys.Down))
     {
         changeCurrentParameter(1);
         hightlightSelection();
     }
     if (e.KeyCode.Equals(Keys.Up))
     {
         changeCurrentParameter(-1);
         hightlightSelection();
     }
     if (e.Modifiers.Equals(Keys.Control))
     {
         if (showing == 1)
         {
             pictureBox1.Image = slider.image;
             showing           = 0;
         }
         else
         {
             refreshFeatures();
             showing = 1;
         }
     }
 }
Ejemplo n.º 6
0
        public List <ImagePair> go(CSVSaver CSVSaver, bool zanik)
        {
            int halfW;
            int halfH;

            if (zanik)
            {
                halfW = 80;
                halfH = 80;
            }
            else
            {
                // Połowa wielkości( wysokości i szerokości)
                halfH = 40;
                halfW = 40;
            }

            InformationCSVMerger <CSVRecord> informationCSVMerger = new InformationCSVMerger <CSVRecord>(CSVSaver.CsvPath);
            List <CSVRecord> list = informationCSVMerger.getRecords();
            ImageDrawer      id;

            if (zanik)
            {
                id = getZanikDrawer();
            }
            else
            {
                id = getWyjscieDrawer();
            }

            Image resultImage = new Bitmap(ImageSlider.WIDTH, ImageSlider.HEIGHT, PixelFormat.Format24bppRgb);

            using (Graphics grp = Graphics.FromImage(resultImage))
            {
                grp.FillRectangle(
                    Brushes.Black, 0, 0, resultImage.Width, resultImage.Height);
            }

            List <ImagePair> data = new List <ImagePair>();

            foreach (var item in list)
            {
                ImagePair IP = new ImagePair();
                IP.directory = "/" + item.Patient + "/" + item.Date + "/" + item.Eye + "/mask/";

                BitmapAndPath BAP1 = new BitmapAndPath();
                BAP1.path = IP.directory + item.PierscienImage;

                id.setImage(resultImage);

                Image drawn = id.Draw(CSVStructure.getStructure(item));

                Rectangle cropRect = new Rectangle(item.PierscienX - halfH, item.PierscienY - halfW, halfH * 2, halfW * 2);
                Bitmap    src      = drawn as Bitmap;
                Bitmap    target   = new Bitmap(cropRect.Width, cropRect.Height);

                using (Graphics g = Graphics.FromImage(target))
                {
                    g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height),
                                cropRect,
                                GraphicsUnit.Pixel);
                }

                BAP1.bmp = new Bitmap(target);

                BitmapAndPath BAP2 = new BitmapAndPath();
                BAP2.path = "/" + item.Patient + '/' + item.Date + '/' + item.Eye + "/" + item.PierscienImage;

                Image original = new Bitmap(Image.FromFile(PropertiesReader.PATH_PROVIDER_ADDITIONAL_ARGS + "/" + item.Patient + "/" + item.Date + "/" + item.PierscienImage), new Size(ImageSlider.WIDTH, ImageSlider.HEIGHT));

                Bitmap src2    = original as Bitmap;
                Bitmap target2 = new Bitmap(cropRect.Width, cropRect.Height);

                using (Graphics g = Graphics.FromImage(target2))
                {
                    g.DrawImage(src2, new Rectangle(0, 0, target2.Width, target2.Height),
                                cropRect,
                                GraphicsUnit.Pixel);
                }

                BAP2.bmp = new Bitmap(target2);

                IP.X = BAP1;
                IP.Y = BAP2;

                data.Add(IP);
            }

            return(data);
        }