private void Magnitude_Click(object sender, RoutedEventArgs e) { int i = imgDataGrid.SelectedIndex; if (i > -1) { MatrixDetection rowobj = (MatrixDetection)imgDataGrid.Items[i]; // this give you access to the row //var sobelVM= dal.ImageDal.GetSobelV(rowobj.Parent1.GetValueOrDefault()); //var sobelHM = dal.ImageDal.GetSobelH(rowobj.Parent2.GetValueOrDefault()); //var matrixV = core.Image.ConvertArrayToMatrix(sobelVM.Matrix, sobelVM.Width, sobelVM.Height); //var matrixH = core.Image.ConvertArrayToMatrix(sobelHM.Matrix, sobelHM.Width, sobelHM.Height); var matrix = core.Image.ConvertArrayToMatrixDoubles(rowobj.Matrix, rowobj.Width, rowobj.Height); var sobelMagMatrix = core.Image.MagnitudeFromDefoultMatrixForVisualization(matrix); var arrM = core.Image.ConvertMatreixToArray(core.Image.Normalize(sobelMagMatrix)); var image = new MatrixDetection() { Name = Guid.NewGuid().ToString(), Component = rowobj.Component, Height = sobelMagMatrix.GetLength(1), Type = "SobelM", Width = sobelMagMatrix.GetLength(0), Matrix = arrM }; dal.ImageDal.Add(image); core.Localization.SaveMatrix(sobelMagMatrix, image.Name + "_SobelM"); dal.ImageDal.SetMagnitude(rowobj.Id, image.Id); Bitmap img = core.Image.ConvertArrayToImage(arrM, rowobj.Width - 2, rowobj.Height - 2); core.Localization.SaveImage(img, image.Name); } else { } }
private void SobelH_Click(object sender, RoutedEventArgs e) { int i = imgDataGrid.SelectedIndex; if (i > -1) { MatrixDetection rowobj = (MatrixDetection)imgDataGrid.Items[i]; // this give you access to the row var matrix = core.Image.ConvertArrayToMatrixDoubles(rowobj.Matrix, rowobj.Width, rowobj.Height); var sobelhMatrix = core.Image.SobelHOperationDoubleForVisualization(matrix); var arrM = core.Image.ConvertMatreixToArray(core.Image.Normalize(sobelhMatrix)); var image = new MatrixDetection() { Name = rowobj.Name + "_H", Component = rowobj.Component, Height = rowobj.Height, Type = "SobelH", Width = rowobj.Width, Matrix = arrM }; dal.ImageDal.Add(image); dal.ImageDal.SetSobelH(rowobj.Id, image.Id); if (LocalizationFlag.IsChecked == true) { Bitmap img = core.Image.ConvertArrayToImage(arrM, rowobj.Width, rowobj.Height); core.Localization.SaveMatrix(sobelhMatrix, image.Name + "_SobelH"); core.Localization.SaveImage(img, image.Name); } } else { } }
private void ImgDataGrid_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { int i = imgDataGrid.SelectedIndex; if (i > -1) { MatrixDetection rowobj = (MatrixDetection)imgDataGrid.Items[i]; // this give you access to the row Bitmap img = core.Image.ConvertArrayToImage(rowobj.Matrix, rowobj.Width, rowobj.Height); Imagebox.Source = ImageSourceForBitmap(img); } else { } }
private void CreateAddMatrix_Click(object sender, RoutedEventArgs e) { var path = $"{imgpathtextbox.Text}"; var w = 0; var h = 0; var matrix = core.Image.ConvertImageToMatrixByte(path, (CompTypes)compComboBox.SelectedItem, ref w, ref h); var arrM = core.Image.ConvertMatreixToArray(matrix); var image = new MatrixDetection() { Name = Guid.NewGuid().ToString(), Component = "R", Height = h, Type = Convert.ToString(MatrixTypes.Default), Width = w, Matrix = arrM }; dal.ImageDal.Add(image); core.Localization.SaveMatrix(matrix, image.Name); Button_Click(sender, e); }
private void Estimation_Click(object sender, RoutedEventArgs e) { int i = imgDataGrid.SelectedIndex; if (i > -1) { MatrixDetection rowobj = (MatrixDetection)imgDataGrid.Items[i]; // this give you access to the row //var sobelM = dal.ImageDal.GetById(rowobj.BaseId.GetValueOrDefault());//GetMagnitude(rowobj.BaseId.GetValueOrDefault()); //var matrixM = core.Image.ConvertArrayToMatrix(sobelM.Matrix, sobelM.Width, sobelM.Height); var matrix = core.Image.ConvertArrayToMatrixDoubles(rowobj.Matrix, rowobj.Width, rowobj.Height); var matrixM = core.Image.MagnitudeFromDefoultMatrix(matrix); var estimaion = core.Image.EstimationDouble(matrixM); dal.ImageDal.SetEstimation(rowobj.Id, estimaion); } else { } }
private void CreateAddMatrix_Click(object sender, RoutedEventArgs e) { var path = $"{@imgpathtextbox.Text}"; var filename = System.IO.Path.GetFileNameWithoutExtension(path); var w = 0; var h = 0; var matrix = core.Image.ConvertImageToMatrixByte(path, (CompTypes)compComboBox.SelectedItem, ref w, ref h); var arrM = core.Image.ConvertMatreixToArray(matrix); var image = new MatrixDetection() { Name = filename, Component = "R", Height = h, Type = Convert.ToString(MatrixTypes.Default), Width = w, Matrix = arrM }; dal.ImageDal.Add(image); if (LocalizationFlag.IsChecked == true) { core.Localization.SaveMatrix(matrix, image.Name); } Button_Click(sender, e); }
private void CalcBlurMap_Click(object sender, RoutedEventArgs e) { int i = imgDataGrid.SelectedIndex; if (i > -1) { MatrixDetection rowobj = (MatrixDetection)imgDataGrid.Items[i]; // this give you access to the row //var sobelVM= dal.ImageDal.GetSobelV(rowobj.Parent1.GetValueOrDefault()); //var sobelHM = dal.ImageDal.GetSobelH(rowobj.Parent2.GetValueOrDefault()); var matrix = core.Image.ConvertArrayToMatrixDoubles(rowobj.Matrix, rowobj.Width, rowobj.Height); var sobelMagMatrix = core.Image.MagnitudeFromDefoultMatrix(matrix); var calcM = core.Image.CalcBlurMapDouble(sobelMagMatrix); var arrM = core.Image.ConvertMatreixToArray(core.Image.Normalize(calcM)); var image = new MatrixDetection() { Name = rowobj.Name + "_Map", Component = rowobj.Component, Height = sobelMagMatrix.GetLength(1), Type = "CalcMap", Width = sobelMagMatrix.GetLength(0), Matrix = arrM }; dal.ImageDal.Add(image); Button_Click(sender, e); if (LocalizationFlag.IsChecked == true) { Bitmap img = core.Image.ConvertArrayToImage(arrM, rowobj.Width - 2, rowobj.Height - 2); core.Localization.SaveMatrix(calcM, image.Name); core.Localization.SaveImage(img, image.Name); } // dal.ImageDal.SetMagnitude(rowobj.Id, image.Id); } else { } }
private void LoadAndCalcFromFolder_Click(object sender, RoutedEventArgs e) { var path = $"{imgpathtextbox.Text}"; var images = core.Localization.GetImagePathsFromFolder(path); foreach (var img in images) { var w = 0; var h = 0; var matrix = core.Image.ConvertImageToMatrixByte(img, (CompTypes)compComboBox.SelectedItem, ref w, ref h); var arrD = core.Image.ConvertMatreixToArray(matrix); var imageD = new MatrixDetection() { Name = Guid.NewGuid().ToString(), Component = "R", Height = h, Type = Convert.ToString(MatrixTypes.Default), Width = w, Matrix = arrD }; dal.ImageDal.Add(imageD); core.Localization.SaveMatrix(matrix, imageD.Name); //SobelV var matrixD = core.Image.ConvertImageToMatrix(img, (CompTypes)compComboBox.SelectedItem, ref w, ref h); var sobelvMatrix = core.Image.SobelVOperationDForVisualization(matrixD); var arrSV = core.Image.ConvertMatreixToArray(core.Image.Normalize(sobelvMatrix)); var imageSV = new MatrixDetection() { Name = Guid.NewGuid().ToString(), Component = imageD.Component, Height = h, Type = "SobelV", Width = w, Matrix = arrSV }; dal.ImageDal.Add(imageSV); core.Localization.SaveMatrix(sobelvMatrix, imageSV.Name + "_SobelV"); dal.ImageDal.SetSobelV(imageD.Id, imageSV.Id); Bitmap imgSV = core.Image.ConvertArrayToImage(arrSV, w, h); core.Localization.SaveImage(imgSV, imageSV.Name); //SobelH var sobelhMatrix = core.Image.SobelHOperationDoubleForVisualization(matrixD); var arrSH = core.Image.ConvertMatreixToArray(core.Image.Normalize(sobelhMatrix)); var imageSH = new MatrixDetection() { Name = Guid.NewGuid().ToString(), Component = imageD.Component, Height = h, Type = "SobelH", Width = w, Matrix = arrSH }; dal.ImageDal.Add(imageSH); core.Localization.SaveMatrix(sobelhMatrix, imageSH.Name + "_SobelH"); dal.ImageDal.SetSobelH(imageD.Id, imageSH.Id); Bitmap imgSH = core.Image.ConvertArrayToImage(arrSH, w, h); core.Localization.SaveImage(imgSH, imageSH.Name); //Mag var sobelMagMatrix = core.Image.MagnitudeFromDefoultMatrixForVisualization(matrixD); var arrM = core.Image.ConvertMatreixToArray(core.Image.Normalize(sobelMagMatrix)); var imageM = new MatrixDetection() { Name = Guid.NewGuid().ToString(), Component = imageD.Component, Height = sobelMagMatrix.GetLength(1), Type = "SobelM", Width = sobelMagMatrix.GetLength(0), Matrix = arrM }; dal.ImageDal.Add(imageM); core.Localization.SaveMatrix(sobelMagMatrix, imageM.Name + "_SobelM"); dal.ImageDal.SetMagnitude(imageD.Id, imageM.Id); Bitmap imgM = core.Image.ConvertArrayToImage(arrM, w - 2, h - 2); core.Localization.SaveImage(imgM, imageM.Name); //est var matrixM = core.Image.MagnitudeFromDefoultMatrix(matrixD); var estimaion = core.Image.EstimationDouble(matrixM); dal.ImageDal.SetEstimation(imageD.Id, estimaion); } Button_Click(sender, e); }
public void Add(MatrixDetection MatrixDetection) { DbContext.MatrixDetections.Add(MatrixDetection); DbContext.SaveChanges(); }