|
@@ -0,0 +1,36 @@
|
|
|
|
+import sys
|
|
|
|
+import numpy as np
|
|
|
|
+import matplotlib.pyplot as plt
|
|
|
|
+from skimage.measure import label
|
|
|
|
+
|
|
|
|
+if len(sys.argv) < 2:
|
|
|
|
+ print("No path provided")
|
|
|
|
+
|
|
|
|
+num = np.load(sys.argv[1])
|
|
|
|
+
|
|
|
|
+lb = label(num)
|
|
|
|
+
|
|
|
|
+fs = {}
|
|
|
|
+
|
|
|
|
+for l in np.unique(lb)[1:]:
|
|
|
|
+ x, y = np.where(lb == l)
|
|
|
|
+ x = x - x.min()
|
|
|
|
+ y = y - y.min()
|
|
|
|
+ k = (str(x), str(y))
|
|
|
|
+ if k not in fs.keys():
|
|
|
|
+ fs[k] = 1
|
|
|
|
+ else:
|
|
|
|
+ fs[k] += 1
|
|
|
|
+
|
|
|
|
+for i, (fi, coun) in enumerate(fs.items()):
|
|
|
|
+ plt.subplot(1, 5, i + 1)
|
|
|
|
+ fi = (
|
|
|
|
+ np.fromstring(fi[0][1:-1], dtype=int, sep=" "),
|
|
|
|
+ np.fromstring(fi[1][1:-1], dtype=int, sep=" "),
|
|
|
|
+ )
|
|
|
|
+ fig = np.zeros((max(fi[0]) + 1, max(fi[1]) + 1))
|
|
|
|
+ fig[fi[0], fi[1]] = 1
|
|
|
|
+ plt.title(f"{coun}")
|
|
|
|
+ plt.imshow(fig)
|
|
|
|
+plt.suptitle(f"Всего: {len(fs.items())}")
|
|
|
|
+plt.show()
|