public void LoadReferences() { DataSave[] savedData = jsonMgr.Read(); baseReference.Clear(); if (savedData != null) { foreach (DataSave i in savedData) { ImageFeature f = new ImageFeature(i.matrix0, i.matrix45, i.matrix90, i.matrix135); f.name = i.name; AddReference(i.name, f); } } }
public FeatureInfo CalculateMatrix(int[,] matrix0, int[,] matrix45, int[,] matrix90, int[,] matrix135) { ImageFeature inputFeature = new ImageFeature(matrix0, matrix45, matrix90, matrix135); string resName = string.Empty; float[] avgsre = new float[4]; float[] avgglu = new float[4]; float[] avglre = new float[4]; float[] avgrlu = new float[4]; float[] avgrpc = new float[4]; double lastEuclideanFactor = double.MaxValue; avgsre = inputFeature.SRE(); avgglu = inputFeature.GLU(); avglre = inputFeature.LRE(); avgrlu = inputFeature.RLU(); avgrpc = inputFeature.RPC(); foreach (string s in baseReference.Keys) { double tempFactor = double.MaxValue; float[] tgtValues = baseReference[s].Values(); float[] tstValues = inputFeature.Values(); float[] tempValues = new float[20]; for (int i = 0; i < 20; i++) { tempValues[i] = tstValues[i] - tgtValues[i]; } tempFactor = Math.Sqrt(tempValues.Sum()); Console.WriteLine(tempFactor); if (tempFactor < lastEuclideanFactor) { resName = s.Split('_')[0]; lastEuclideanFactor = tempFactor; } } FeatureInfo result = new FeatureInfo(resName, avgsre, avgglu, avglre, avgrlu, avgrpc); return(result); }
private void button1_Click(object sender, EventArgs e) { using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Title = "Open Image"; dlg.Multiselect = true; if (dlg.ShowDialog() == DialogResult.OK) { // Create a new Bitmap object from the picture file on disk, // and assign that to the PictureBox.Image property //Bitmap img = new Bitmap(dlg.FileName); //Bitmap resizedImg = ip.ResizeImage(img, 5, 5); //Bitmap greyscaledImg = ip.MakeGrayscale3(resizedImg); //Bitmap normalizedImg = ip.ContrastStretch(greyscaledImg); features.Clear(); for (int i = 0; i < dlg.FileNames.Length; i++) { Bitmap img = new Bitmap(dlg.FileNames[i]); TextBox textName = new TextBox(); textName.Text = dlg.FileNames[i].Split('\\')[dlg.FileNames[i].Split('\\').Length - 1].Split('.')[0]; textName.Parent = panel1; textName.Location = new Point(3, (29 * i) + 3); textName.Size = new Size(600, 26); textName.Name = "file_name_" + i; int[,] matrix0 = ip.sudut0(ip.grayLevel(img), img); int[,] matrix45 = ip.sudut45(ip.grayLevel(img), img); int[,] matrix90 = ip.sudut90(ip.grayLevel(img), img); int[,] matrix135 = ip.sudut135(ip.grayLevel(img), img); ImageFeature feature = new ImageFeature(matrix0, matrix45, matrix90, matrix135); feature.name = textName.Text; textName.TextChanged += on_fileListNameChanged; features.Add(feature); } } } }
public void AddReference(string referenceName, ImageFeature reference) { reference.name = referenceName; baseReference[referenceName] = reference; }