Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var files = Directory.EnumerateFiles(baseDir, "*.*", SearchOption.AllDirectories).ToArray();
- const int numberOfBins = 16;
- const double normalFactor = 64;
- var fingerprints = new List<ImageFingerPrint>();
- foreach(var file in files)
- {
- var img = new Image<Gray, byte>(file);
- var hist = new DenseHistogram(numberOfBins, new RangeF(0, byte.MaxValue));
- hist.Calculate(new[] {img}, false, null);
- hist.Normalize(normalFactor);
- var data = hist.MatND.ManagedArray.Cast<float>().ToArray();
- var fingerprint = new byte[numberOfBins];
- for(int i = 0; i < numberOfBins; ++i)
- {
- fingerprint[i] = (byte)Math.Round(data[i]);
- }
- fingerprints.Add(new ImageFingerPrint { FileName = file, FingerPrint = fingerprint });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement