private void ПорівняльнийТестToolStripMenuItem_Click(object sender, EventArgs e) { SimpleMatrix.Matrix kernel = new SimpleMatrix.Matrix(3, 3, new double[] { 1, 6, 1, 6, 36, 6, 1, 6, 1 }); double normilizer = 64; kernel /= normilizer; DateTime t1, t2; double matrixTime, formulasTime; t1 = DateTime.Now; DoubleArrayImageOperations.ConvolutionFilter(m_workImage, kernel.data); t2 = DateTime.Now; matrixTime = (t2 - t1).TotalMilliseconds; t1 = DateTime.Now; BlurEffectWithoutMatrix.Apply(m_workImage); t2 = DateTime.Now; formulasTime = (t2 - t1).TotalMilliseconds; textBox1.Text += Environment.NewLine + "Час обробки з використання матриць: " + matrixTime.ToString("0.000") + "мс" + Environment.NewLine; textBox1.Text += Environment.NewLine + "Час обробки (формула напряму): " + formulasTime.ToString("0.000") + "мс" + Environment.NewLine; }
void ApplyFilter(SimpleMatrix.Matrix kernel, double normilizer) { kernel /= normilizer; m_workImage = DoubleArrayImageOperations.ConvolutionFilter(m_workImage, kernel.data); RefreshWorkImage(); }
//яркость private void trackBar1_Scroll(object sender, EventArgs e) { int value = trackBar1.Value; BrightnessTextBox.Text = value.ToString(); m_workImage = DoubleArrayImageOperations.ChangeBrightness(m_workImage, value); OutputBitmapOnPictureBox(BitmapConverter.DoubleRgbToBitmap(m_workImage)); }
//контраст private void ContrastTrackBar_Scroll(object sender, EventArgs e) { int value = ContrastTrackBar.Value; ContrastTextBox.Text = value.ToString(); m_workImage = DoubleArrayImageOperations.contrast(m_workImage, 1 + value / 100d); OutputBitmapOnPictureBox(BitmapConverter.DoubleRgbToBitmap(m_workImage)); }
private void button5_Click(object sender, EventArgs e) { double sigma = Convert.ToDouble(sigmaTextBox.Text.Replace(".", ",")); GaussianBlur gaussianBlur = new GaussianBlur(); double[][] filter = gaussianBlur.getKernel(sigma); m_workImage = DoubleArrayImageOperations.ConvolutionFilter(m_workImage, filter); OutputBitmapOnPictureBox(BitmapConverter.DoubleRgbToBitmap(m_workImage)); }
public Bitmap DoSegmentation(double[,,] arrayImage, double sigma, double k, int minSize, IColorSheme colorSheme) { m_height = arrayImage.GetLength(1); m_width = arrayImage.GetLength(2); //debug System.Diagnostics.Debug.WriteLine("Reading done: " + DateTime.Now); m_colorSheme = colorSheme; //препроцессинг иображения arrayImage = colorSheme.Convert(arrayImage); //сохранение для проведения оценки качества сегментации m_arrayImageCopy = (double[, , ])arrayImage.Clone(); //debug System.Diagnostics.Debug.WriteLine("color sheme changed: " + DateTime.Now); //DebugImageInfo(arrayImage); //smoothing GaussianBlur gaussianBlur = new GaussianBlur(); double[][] filter = gaussianBlur.getKernel(sigma); double[,,] blurredImage = DoubleArrayImageOperations.ConvolutionFilter(arrayImage, filter); //debug System.Diagnostics.Debug.WriteLine("Smooting done: " + DateTime.Now); //тест размещения преобразования цвета //arrayImage = colorSheme.Convert(arrayImage); //построение графа Edge[] edges = buildGraphByImage(blurredImage) .OrderBy(el => el.w) .ToArray(); //debug System.Diagnostics.Debug.WriteLine("graph builded: " + DateTime.Now); //debugging System.Diagnostics.Debug.WriteLine("edges total: " + edges.Length); //double minWeight = edges.Min(el => el.w); //double maxWeight = edges.Max(el => el.w); //Edge[] EdgesMoreThanMin = edges.Where(el => el.w > minWeight + 0.1).ToArray(); //Edge[] EdgesZeroWidth = edges.Where(el => el.w < 0.01).ToArray(); // //Edge[] edgesHor = edges.Where(el => el.neightbourType == NeightbourType.Horizontal).ToArray(); //Edge[] edgesVer = edges.Where(el => el.neightbourType == NeightbourType.Vertical).ToArray(); //Edge[] edgesTopDiag = edges.Where(el => el.neightbourType == NeightbourType.TopDiagonal).ToArray(); //Edge[] edgesBottom = edges.Where(el => el.neightbourType == NeightbourType.BottomDiagonal).ToArray(); //сегментированный лес непересекающихся деревьев DisjointSet segmentedSet = SegmentOnDisjointSet(k, m_height * m_width, edges); //картинка тут только для передачи размера потому осталась arrayImage //запоминание в поле для проведения оценки m_segmentedSet = segmentedSet; //debug System.Diagnostics.Debug.WriteLine("Segmented: " + DateTime.Now); //присоеденить те, что меньше min_size к соседу по ребру PostProcessSmallComponents(edges, segmentedSet, minSize); //debug System.Diagnostics.Debug.WriteLine("Small Component Merged: " + DateTime.Now); return(SegmentedSetConverter.ConvertToBitmap(segmentedSet, m_height, m_width, out m_componentLength)); //var a = SegmentedSetConverter.ConvertToRealCoordsSegments(segmentedSet, height, width); //return SegmentedSetConverter.RealCoordsSegmentResultToBitmap(a); }
public double[,,] Convert(double[,,] arrayImage) => DoubleArrayImageOperations.GetImageInLab(arrayImage);
public double[,,] Convert(double[,,] arrayImage) => DoubleArrayImageOperations.GetGrayScale(arrayImage);
//оттенки серого private void button2_Click(object sender, EventArgs e) { m_workImage = DoubleArrayImageOperations.GetGrayScale(m_workImage); OutputBitmapOnPictureBox(BitmapConverter.DoubleRgbToBitmap(m_workImage)); }