public LBPCreator(ImageGrayData imageData, bool isTeaching, bool isDivideToFragments, bool isMultithread = true) { var needSize = RecognitionParameters.RecognitionFragmentSize; if (isTeaching) { needSize = RecognitionParameters.FragmentsSize; } if ((imageData.Width < needSize) || (imageData.Height < needSize)) { throw new ArgumentException("Размер изображения меньше размера фрагмента для разбиения. \n" + "Невозможно создать LBP-гистограмму"); } fragmentSize = needSize; this.isTeaching = isTeaching; this.isDivideToFragments = isDivideToFragments; this.isMultithread = isMultithread; data = imageData.Data; width = imageData.Width; height = imageData.Height; feature = null; ConstructFeature(); }
public TextureSample(ImageGrayData imageData, bool isDivideToFragments) { sample = imageData; var glcmCreator = new GLCMCreator(sample, false, isDivideToFragments); var lbpCreator = new LBPCreator(sample, false, isDivideToFragments); glcm = glcmCreator.Feature; lbp = lbpCreator.Feature; }
private void AddFeatures(GLCMFeature glcm, LBPFeature lbp, string path) { lock ((knownFiles as ICollection).SyncRoot) { ++featuresCount; glcmFeatures.Add(glcm); lbpFeatures.Add(lbp); knownFiles.Add(path); } }
public double GetDistance(LBPFeature other) { double result = 0; for (int i = 0; i < 18; ++i) { result += MathHelpers.Sqr(data[i] - other[i]) / (data[i] + other[i]); } return(result); }
private void ConstructFeature() { if (isDivideToFragments) { var list = GetSubfeatures(); feature = LBPFeature.BuildStandart(list); } else { feature = GetLBPFeature(new Fragment(0, 0, width, height)); } }
public LBPFeature PrepareLBP(out double average, out double variance) { var lStandart = LBPFeature.BuildStandart(lbpFeatures); var lDistances = new double[lbpFeatures.Count]; for (int i = 0; i < lbpFeatures.Count; ++i) { lDistances[i] = lStandart.GetDistance(lbpFeatures[i]); } average = MathHelpers.GetAverage(lDistances, 0, lbpFeatures.Count); variance = MathHelpers.GetVariance(lDistances, average, 0, lbpFeatures.Count); return(lStandart); }
public List <int> DischargeLBP(LBPFeature standart, double average, double variance) { var result = new List <int>(); var tValue = alglib.studenttdistribution(lbpFeatures.Count - 1, RecognitionParameters.CompactFactor); var deviation = Math.Sqrt(variance); for (int i = 0; i < lbpFeatures.Count; ++i) { var value = Math.Abs(standart.GetDistance(lbpFeatures[i]) - average) / deviation; if (value > tValue) { result.Add(i); } } return(result); }
internal void LoadKnowledges(XmlNode node) { Name = node.Attributes["name"].Value; int r, g, b; int.TryParse(node.Attributes["R"].Value, out r); int.TryParse(node.Attributes["G"].Value, out g); int.TryParse(node.Attributes["B"].Value, out b); RegionColor = Color.FromArgb(r, g, b); var samples = node.ChildNodes; foreach (XmlNode item in samples) { var file = item.ChildNodes[0].Attributes["path"].Value; var glcm = new GLCMFeature(); glcm.LoadKnowledges(item.ChildNodes[1]); var lbp = new LBPFeature(); lbp.LoadKnowledges(item.ChildNodes[2]); AddFeatures(glcm, lbp, file); } }
public double GetDistance(LBPFeature other) { double result = 0; for (int i = 0; i < 18; ++i) { result += MathHelpers.Sqr(data[i] - other[i]) / (data[i] + other[i]); } return result; }
public List<int> DischargeLBP(LBPFeature standart, double average, double variance) { var result = new List<int>(); var tValue = alglib.studenttdistribution(lbpFeatures.Count - 1, RecognitionParameters.CompactFactor); var deviation = Math.Sqrt(variance); for (int i = 0; i < lbpFeatures.Count; ++i) { var value = Math.Abs(standart.GetDistance(lbpFeatures[i]) - average) / deviation; if (value > tValue) { result.Add(i); } } return result; }