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); } }
private void ConstructFeature() { if (isDivideToFragments) { var list = GetSubfeatures(); feature = GLCMFeature.BuildStandart(list); } else { feature = GetGLCMFeature(new Fragment(0, 0, width, height)); } }
public double GetDistance(GLCMFeature other) { double result = 0; var dWeight = RecognitionParameters.GLCMDeviationWeight; for (int i = 0; i < 8; ++i) { var weight = ((i + 1) % 2 == 2) ? (dWeight) : (1.0); result += weight * MathHelpers.Sqr(feature[i] - other[i]); } return(Math.Sqrt(result)); }
public GLCMFeature PrepareGLCM(out double average, out double variance) { var gStandart = GLCMFeature.BuildStandart(glcmFeatures); var gDistances = new double[glcmFeatures.Count]; for (int i = 0; i < glcmFeatures.Count; ++i) { gDistances[i] = gStandart.GetDistance(glcmFeatures[i]); } average = MathHelpers.GetAverage(gDistances, 0, glcmFeatures.Count); variance = MathHelpers.GetVariance(gDistances, average, 0, glcmFeatures.Count); return(gStandart); }
public List<int> CompactGLCM(GLCMFeature standart, double average, double variance) { var result = new List<int>(); var tValue = alglib.studenttdistribution(glcmFeatures.Count - 1, RecognitionParameters.CompactFactor); var deviation = Math.Sqrt(variance); for (int i = 0; i < glcmFeatures.Count; ++i) { var value = Math.Abs(standart.GetDistance(glcmFeatures[i]) - average) / deviation; if (value <= tValue) { result.Add(i); } } return result; }
public List <int> DischargeGLCM(GLCMFeature standart, double average, double variance) { var result = new List <int>(); var tValue = alglib.studenttdistribution(glcmFeatures.Count - 1, RecognitionParameters.CompactFactor); var deviation = Math.Sqrt(variance); for (int i = 0; i < glcmFeatures.Count; ++i) { var value = Math.Abs(standart.GetDistance(glcmFeatures[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(GLCMFeature other) { double result = 0; var dWeight = RecognitionParameters.GLCMDeviationWeight; for (int i = 0; i < 8; ++i) { var weight = ((i + 1) % 2 == 2) ? (dWeight) : (1.0); result += weight * MathHelpers.Sqr(feature[i] - other[i]); } return Math.Sqrt(result); }