// Konstruktor public Pixel(Vector5 _vector, Bgr _bgr) { vector = _vector; distance = 9999; clusterNr = -1; bgr = _bgr; scanned = false; }
// =============== Gradient berechnen =============== private double calcGradient(Vector5 pixel) { int x = pixel.x; int y = pixel.y; double g = Math.Pow(pixels[x + 1, y].vector.sub(pixels[x - 1, y].vector).l2Norm(), 2) + Math.Pow(pixels[x, y + 1].vector.sub(pixels[x, y - 1].vector).l2Norm(), 2); return g; }
// Vektor-Subtraktion public Vector5 sub(Vector5 v) { Vector5 vsub = new Vector5(l - v.l, a - v.a, b - v.b, x - v.x, y - v.y); return vsub; }
// =============== Distanz zweier Pixel berechnen =============== private double calcDistance(Vector5 pixel1, Vector5 pixel2) { double dLab = Math.Sqrt(Math.Pow((pixel1.l - pixel2.l), 2) + Math.Pow((pixel1.a - pixel2.a), 2) + Math.Pow((pixel1.b - pixel2.b), 2)); double dXy = Math.Sqrt(Math.Pow((pixel1.x - pixel2.x), 2) + Math.Pow((pixel1.y - pixel2.y), 2)); double ds = dLab + m / s * dXy; return ds; }