public void queryThread() { int shift = 0; lock (lockObject) { shift = shifts++; } for (int k = shift; k < task.queryNames.Count; k += threadNum) { SRD query = new SRD(task.queryPaths[k]); List <Score> scores = new List <Score>(); for (int i = 0; i < task.datasetNames.Count; ++i) { Score score = new Score(); score.index = i; score.score = SRD.similarity(query, datasets[i]); scores.Add(score); } scores.Sort(); StreamWriter writer = new StreamWriter("results/" + task.queryNames[k] + ".result"); for (int i = 0; i < scores.Count; ++i) { writer.WriteLine(task.datasetNames[scores[i].index]); } writer.Close(); ++progress; Console.Write("Progress: " + (100.0 * progress / task.queryNames.Count).ToString("0.00") + "%\r"); } lock (lockObject) { --shifts; } }
public static double similarity(SRD a, SRD b) { double sim = 0.0; for (int i = 0; i < 256; ++i) { for (int j = 0; j < 256; ++j) { sim += Math.Min(a.histogram[i, j], b.histogram[i, j]); } } return(sim); }
public void extractThread() { int shift = 0; lock (lockObject) { shift = shifts++; } for (int k = shift; k < task.datasetNames.Count; k += threadNum) { datasets[k] = new SRD(task.datasetPaths[k]); ++progress; Console.Write("Progress: " + (100.0 * progress / task.datasetNames.Count).ToString("0.00") + "%\r"); } lock (lockObject) { --shifts; } }