static void Main(string[] args) { List <double> timeList = new List <double>(); for (int i = 0; i < 100; i++) { DateTime t1 = DateTime.Now; double[,,] arrayImage = BitmapConverter.BitmapToDoubleRgb(new Bitmap("testReading.png")); //double[,,] arrayImage = BitmapConverter.BitmapToDoubleRgbNaive(new Bitmap("testReading.png")); DateTime t2 = DateTime.Now; double time = (t2 - t1).TotalSeconds; //System.Diagnostics.Debug.WriteLine("reading"+i + ": " + time.ToString("0.0000")); timeList.Add(time); } STAT stat = new STAT(); stat.SetData(timeList.ToArray()); System.Diagnostics.Debug.WriteLine("Expectation: " + stat.Expectation_niz.ToString("0.0000") + " | " + stat.Expectation.ToString("0.0000") + " | " + stat.Expectation_verh.ToString("0.0000")); System.Diagnostics.Debug.WriteLine("Sigma: " + stat.Sigma_niz.ToString("0.0000") + " | " + stat.Sigma.ToString("0.0000") + " | " + stat.Sigma_verh.ToString("0.0000")); System.Diagnostics.Debug.WriteLine("Total time:" + timeList.Sum().ToString("0.0000")); }
private void вілкритиToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = m_sampleDirectory; if (ofd.ShowDialog() != DialogResult.OK) { return; } m_image = BitmapConverter.BitmapToDoubleRgb(new Bitmap(ofd.FileName)); OutputImageOnForm(); }
private void OutputSegmentations(Workbook wb, string filename, int width, int height) { Worksheet ws = wb.Worksheets[0]; //image reading Bitmap b = new Bitmap(filename); double[,,] arrayImage = BitmapConverter.BitmapToDoubleRgb(b); //MemoryStream memoryStream = new MemoryStream(); //b.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); //processing cycle int counter = 0; for (int k = kMin, i = 0; k <= kMax; k += kStep, i++) { int currentRow = i * (RowsForDetails + 1) + startImageRowNumber; for (int min = minMin, j = startImageColumnNumber; min <= minMax; min += minStep, j++) { //получение результатов сегментации Segmentation segmentationObj = new Segmentation(); Bitmap res = segmentationObj.DoSegmentation(b, 0.84, k, min, new SegmentationBasedOnGraph.ColorShemes.RGBColorSheme()); //приведение результатов к нужному размеру res = Service.ResizeImage(res, width, height); ///сохранения результата в поток MemoryStream memoryStream = new MemoryStream(); res.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); //добавления сегментации на страницу ws.Cells[currentRow + 1, j].Value = segmentationObj.m_componentLength.ToString(); int idx = ws.Pictures.Add(currentRow, j, memoryStream); ws.Cells[currentRow + 1, j].Value = $"Сегментів: {segmentationObj.m_componentLength}"; ws.Cells[currentRow + 2, j].Value = $"Сума внутрішньокластерних дисперсій: {segmentationObj.GetInternalDifferenceAssessment().ToString("0.00")}"; counter++; System.Diagnostics.Debug.WriteLine($"Сегментация {counter} посчитана"); } } }
private void открытьToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileWindow = new OpenFileDialog(); if (openFileWindow.ShowDialog() == DialogResult.OK) { Bitmap bmp = new Bitmap(openFileWindow.FileName); //storing image info m_workImage = BitmapConverter.BitmapToDoubleRgb(bmp); m_originalImage = (double[, , ])m_workImage.Clone(); m_imageName = Path.GetFileNameWithoutExtension(openFileWindow.FileName); //fill fields with image height and width textBox1.Text = String.Format("Ширина: {0}{2}Висота: {1}", bmp.Width, bmp.Height, Environment.NewLine); SubdivisionWidthTextBox.Text = bmp.Width.ToString(); SubdivisionHeightTextBox.Text = bmp.Height.ToString(); OutputBitmapOnPictureBox(bmp); } }
public void Teach() { Errors.Clear(); DateTime t1 = DateTime.Now; for (int epoсh = 0; epoсh < EPOCH_NUMBER; epoсh++) { double epohError = 0; //System.Diagnostics.Debug.WriteLine("----" + "epoсh" + epoсh+"----"); string[] folders = Directory.GetDirectories(m_folder); for (int i = 0; i < folders.Length; i++) { string[] files = Directory.GetFiles(folders[i]); for (int j = 0; j < files.Length; j++) { char ch = Path.GetFileName(folders[i])[0]; double[,,] arrImage = BitmapConverter.BitmapToDoubleRgb(new Bitmap(files[j])); Vector input = ArrayImageService.formInputVectorForNeuralNetwork(arrImage); double err = m_network.BackPropagation(input, LettersInformator.GetVectorForLetter(ch), 0.5); //System.Diagnostics.Debug.WriteLine(String.Format("letter: '{0}' error: {1:0.0000}", ch, err)); epohError += err; } } Errors.Add(epohError); //System.Diagnostics.Debug.WriteLine(String.Format("EPOCH: '{0}' ERROR: {1:0.0000}", epoсh, epohError)); //System.Diagnostics.Debug.WriteLine("_________________________________"); } DateTime t2 = DateTime.Now; System.Diagnostics.Debug.WriteLine("Время обучения: " + (t2 - t1)); }
private static void OutputSegmentations(Workbook wb, string filename, int width, int height) { Worksheet ws = wb.Worksheets[0]; //image reading Bitmap b = new Bitmap(filename); double[,,] arrayImage = BitmapConverter.BitmapToDoubleRgb(b); //MemoryStream memoryStream = new MemoryStream(); //b.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); //processing cycle for (int k = kMin, i = 0; k <= kMax; k += kStep, i++) { int currentRow = i * (RowsForDetails + 1) + startImageRowNumber; for (int min = minMin, j = startImageColumnNumber; min <= minMax; min += minStep, j++) { int idx = ws.Pictures.Add(currentRow, j, memoryStream); } } }
private void відкритиToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileWindow = new OpenFileDialog(); if (openFileWindow.ShowDialog() == DialogResult.OK) { Bitmap bmp = new Bitmap(openFileWindow.FileName); //storing image info WorkingImage.Clear(); WorkingImage.Add(BitmapConverter.BitmapToDoubleRgb(bmp)); ImageName = Path.GetFileNameWithoutExtension(openFileWindow.FileName); toolStripStatusLabel1.Text = ImageName; LogOutputTextBox.Text += "Відкрито зображення \"" + ImageName + "\"" + Environment.NewLine + "Ширина зображення :" + bmp.Width + Environment.NewLine + "Висота зображення:" + bmp.Height + Environment.NewLine; //fill fields with image height and width //textBox1.Text = String.Format("Ширина: {0}{2}Висота: {1}", bmp.Width, bmp.Height, Environment.NewLine); //SubdivisionWidthTextBox.Text = bmp.Width.ToString(); //SubdivisionHeightTextBox.Text = bmp.Height.ToString(); OutputBitmapOnPictureBox(bmp); textBox4.Text = "" + WorkingImage.Count; } }
private void открытьToolStripMenuItem_Click(object sender, EventArgs e) { segmented = null; ResetScrollsBarsValues(); OpenFileDialog openFileWindow = new OpenFileDialog(); if (openFileWindow.ShowDialog() == DialogResult.OK) { Bitmap bmp = new Bitmap(openFileWindow.FileName); m_workImage = BitmapConverter.BitmapToDoubleRgb(bmp); m_originalImage = (double[, , ])m_workImage.Clone(); m_imageName = Path.GetFileNameWithoutExtension(openFileWindow.FileName); //pictureBox1.Width = bmp.Width; //pictureBox1.Height = bmp.Height; //pictureBox1.Image = bmp; OutputBitmapOnPictureBox(bmp); } }
public Bitmap DoSegmentation(Bitmap bmp, double sigma, double k, int minSize, IColorSheme colorSheme) { double[,,] arrayImage = BitmapConverter.BitmapToDoubleRgb(bmp); return(DoSegmentation(arrayImage, sigma, k, minSize, colorSheme)); }