public int HammingDistance(BucketImage image) { if (buckets != image.buckets || map.GetLength(0) != image.map.GetLength(0) || map.GetLength(1) != image.map.GetLength(1)) { throw new InvalidOperationException(); } int width = map.GetLength(0); int height = map.GetLength(1); int distance = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (map[x, y] != image.map[x, y]) { distance++; } } } return(distance); }
public int HammingDistance(BucketImage image) { if (buckets != image.buckets || map.GetLength(0) != image.map.GetLength(0) || map.GetLength(1) != image.map.GetLength(1)) throw new InvalidOperationException(); int width = map.GetLength(0); int height = map.GetLength(1); int distance = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (map[x, y] != image.map[x, y]) distance++; } } return distance; }