private void ComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (_histogram != null) { _histogram.ResetToDefault(); } var val = (e.AddedItems[0] as ComboBoxItem); switch (val.Content as string) { case "Ręczna": _binarization = new LevelBinarization(_directBitmap, _histogram); BinarizationLevelChangeable = true; break; case "Selekcja czarnego": _binarization = new BlackSelectionBinarization(_directBitmap, _histogram); BinarizationLevelChangeable = true; break; case "Selekcja średniej": _binarization = new MeanSelectionBinarization(_directBitmap, _histogram); _binarization.Binarize(100); ImageCanvas.Source = BitmapConverter.GetBitmapSource(_directBitmap.Bitmap); BinarizationLevelChangeable = false; break; case "Entropia": _binarization = new EntropySelectionBinarization(_directBitmap, _histogram); BinarizationLevelChangeable = true; break; } }
public static double[,] CreatTemplateTest(double[,] imgDoubles) { imgDoubles.DoNormalization(100, 100); int[,] imgInts = imgDoubles.Select2D((x => (int)x)); OrientationField orf = new OrientationField(imgInts, 16); double[,] orient = orf.GetOrientationMatrix(imgInts.GetLength(0), imgInts.GetLength(1)); var freqMatrx = LocalRidgeFrequency.GetFrequencies(imgDoubles, orient); var res = ImageEnhancement.Enhance(imgDoubles, orient, freqMatrx, 32, 8); return(ImageBinarization.Binarize2D(res, 128)); }
public void BinarializationTest() { double[,] arrayD = ImageHelper.LoadImage <double>(Resources._1test); var binarizatedImageDouble = ImageBinarization.Binarize2D(arrayD, 128); for (int i = 0; i < arrayD.GetLength(0); i++) { for (int j = 0; j < arrayD.GetLength(1); j++) { if (arrayD[i, j] < 128) { arrayD[i, j] = 0; } else { arrayD[i, j] = 255; } // Check binarizatedImageDouble Assert.AreEqual(arrayD[i, j], binarizatedImageDouble[i, j]); } } ImageHelper.SaveArrayToBitmap(binarizatedImageDouble).Save(Path.GetTempPath() + Guid.NewGuid() + ".bmp"); int[,] arrayI = ImageHelper.LoadImage <int>(Resources._2_6); var binarizatedImageInt = ImageBinarization.Binarize2D(arrayI, 128); for (int i = 0; i < arrayI.GetLength(0); i++) { for (int j = 0; j < arrayI.GetLength(1); j++) { if (arrayI[i, j] < 128) { arrayI[i, j] = 0; } else { arrayI[i, j] = 255; } // Check binarizatedImageInt Assert.AreEqual(arrayI[i, j], binarizatedImageInt[i, j]); } } ImageHelper.SaveArrayToBitmap(binarizatedImageInt).Save("d://Result.bmp"); }
public void Show(string filePath, OpenMode openMode) { if (openMode == OpenMode.PPM) { _bitmap = LoadPPMImage(filePath); } else { _bitmap = LoadImage(filePath); } _directBitmap = new DirectBitmap(_bitmap); _histogram = new Histogram(_directBitmap); _binarization = new LevelBinarization(_directBitmap, _histogram); GridSpectro.DataContext = _histogram; PointTransformation.InitTransform(_directBitmap); Title = filePath; ImageCanvas.Source = BitmapConverter.GetBitmapSource(_bitmap); Show(); }