Skip to content

Commit 976fb68

Browse files
author
Kabuto_W
committed
Update output and readme.
1 parent 7654753 commit 976fb68

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# ImageSimilarityDetection-UI
2-
Find similar images in the directory by aHash/dHash/pHash.
2+
Find similar images in serveral directory by aHash/dHash/pHash.
33

44
## Supported formats
5-
.jpg; .jpeg; .png
5+
.jpg; .jpeg; .png; .bmp
66

77
## Purpose
8-
Reduce duplication in an image folder.
8+
Reduce duplication in image folders.
99

1010
## Principle
1111
1. Implement aHash, dHash, pHash to generate the fingerprint of images.

SimilarImages/SimilarImages/ImageHash.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static List<Tuple<string, string, double>> GetSimilarity(
8383
Debug.WriteLine($"GetHash: {hashTime}ms; CompareHash: {compareTime}ms");
8484

8585
// Sort by similarity
86-
return tuples.OrderByDescending(u => u.Item3).ToList();
86+
return tuples.OrderByDescending(u => u.Item3).ToList(); // TODO: seldom u=null.
8787
}
8888

8989
public enum HashEnum
@@ -124,7 +124,10 @@ where imageExtensions.Contains(file.Extension)
124124

125125
// Get hashes
126126
var imageHashPairs = new ConcurrentDictionary<string, string>();
127-
Parallel.ForEach(imageNames, imageName =>
127+
Parallel.ForEach(imageNames,
128+
// TODO: Add performance limitation option
129+
//new ParallelOptions { MaxDegreeOfParallelism = Convert.ToInt32(Math.Ceiling((Environment.ProcessorCount * 0.5) * 1.0)) },
130+
imageName =>
128131
{
129132
string hash = hashMethod(imageName);
130133
if (!string.IsNullOrEmpty(hash))
@@ -272,6 +275,8 @@ private static string GetPerceptualHash(string filename)
272275
g.DrawImage(originalBmp, 0, 0, bmp.Width, bmp.Height);
273276
}
274277

278+
originalBmp.Dispose();
279+
275280
watch.Stop();
276281
resizeImageTime = watch.ElapsedMilliseconds;
277282
watch.Restart();
@@ -299,8 +304,6 @@ private static string GetPerceptualHash(string filename)
299304
long imageMatrixTime = watch.ElapsedMilliseconds;
300305
//Debug.WriteLine($"Original: {originalBmpTime,3}ms; Resize: {resizeImageTime,3}ms; Matrix: {imageMatrixTime}ms");
301306

302-
originalBmp.Dispose();
303-
304307
// Get mean gray
305308
grayMean = graySum / height / width;
306309

SimilarImages/SimilarImages/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
1212
[assembly: AssemblyProduct("SimilarImages")]
13-
[assembly: AssemblyCopyright("Copyright © 2020")]
13+
[assembly: AssemblyCopyright("Copyright © Roy0309 2021")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -32,5 +32,5 @@
3232
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
3333
//通过使用 "*",如下所示:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.2.0.0")]
36-
[assembly: AssemblyFileVersion("1.2.0.0")]
35+
[assembly: AssemblyVersion("1.3.0.0")]
36+
[assembly: AssemblyFileVersion("1.3.0.0")]

_Output/SimilarImages.exe

1.5 KB
Binary file not shown.
-512 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)