|
@@ -0,0 +1,24 @@
|
|
|
|
+from skimage.measure import label
|
|
|
|
+import numpy as np
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def areas(LB, label):
|
|
|
|
+ cs = []
|
|
|
|
+ for i in range(1, label + 1):
|
|
|
|
+ cs.append((LB == i).sum())
|
|
|
|
+ return cs
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+img = np.load("./coins.npy.txt")
|
|
|
|
+
|
|
|
|
+lbl = label(img)
|
|
|
|
+
|
|
|
|
+cs = areas(lbl, lbl.max())
|
|
|
|
+nom = sorted(list(set(cs)))
|
|
|
|
+
|
|
|
|
+c1 = cs.count(nom[0])
|
|
|
|
+c2 = cs.count(nom[1]) * 2
|
|
|
|
+c5 = cs.count(nom[2]) * 5
|
|
|
|
+c10 = cs.count(nom[3]) * 10
|
|
|
|
+
|
|
|
|
+print(c1 + c2 + c5 + c10)
|