# IPython log file from dect import calc_shape_corners calc_shape_corners(img) from scipy import ndimage img = ndimage.imread("/home/tpolgrabia/Pobrane/CSFID/tracks_cropped/00003.jpg") img.shape #[Out]# (570, 193) import matplotlib.pyplot as plt plt.imshow(img, cmap="Greys_r") #[Out]# plt.show() from skimage import filters otsu_lvl = filters.threshold_otsu(img) otsu_lvl #[Out]# 139 plt.imshow(img, cmap="Greys_r") #[Out]# plt.show() plt.imshow(img >= otsu_lvl, cmap="Greys_r") #[Out]# plt.show() m = img <= otsu_lvl plt.imshow(m, cmap="Greys_r") #[Out]# plt.show() img_label, nb_labels = ndimage.label(m) nb_labels #[Out]# 571 plt.imshow(nb_labels) plt.imshow(img_label)) plt.imshow(img_label) #[Out]# plt.show() sizes = ndimage.sum(m, img_label, range(0, nb_labels+1)) sizes #[Out]# array([ 0.00000000e+00, 1.00000000e+00, 4.50000000e+01, #[Out]# 1.70000000e+01, 6.20000000e+01, 1.50000000e+01, #[Out]# 5.00000000e+00, 2.00000000e+00, 2.00000000e+00, #[Out]# 3.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 3.00000000e+00, 9.00000000e+00, #[Out]# 2.90000000e+01, 1.00000000e+00, 5.00000000e+00, #[Out]# 2.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 4.00000000e+00, 5.00000000e+00, 1.00000000e+00, #[Out]# 3.00000000e+00, 2.40000000e+01, 6.00000000e+00, #[Out]# 5.00000000e+00, 3.10000000e+01, 1.00000000e+00, #[Out]# 5.30000000e+01, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 2.00000000e+00, #[Out]# 2.00000000e+00, 2.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 2.00000000e+00, 6.00000000e+00, #[Out]# 3.80000000e+01, 1.00000000e+00, 3.00000000e+00, #[Out]# 3.00000000e+00, 1.20000000e+01, 1.10000000e+01, #[Out]# 1.00000000e+01, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 5.60000000e+01, 3.00000000e+00, 1.00000000e+00, #[Out]# 2.00000000e+00, 1.00000000e+00, 2.50000000e+01, #[Out]# 1.00000000e+00, 3.00000000e+00, 4.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 3.00000000e+00, 3.00000000e+00, #[Out]# 3.00000000e+00, 2.00000000e+00, 1.00000000e+00, #[Out]# 3.00000000e+00, 3.00000000e+00, 2.20000000e+01, #[Out]# 1.00000000e+00, 3.00000000e+00, 3.00000000e+00, #[Out]# 1.00000000e+00, 8.00000000e+00, 1.00000000e+01, #[Out]# 1.00000000e+00, 2.00000000e+00, 1.46000000e+02, #[Out]# 2.00000000e+00, 3.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.40000000e+01, 1.00000000e+00, #[Out]# 1.00000000e+00, 4.00000000e+00, 1.15550000e+04, #[Out]# 1.00000000e+00, 1.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 5.80000000e+01, 2.00000000e+00, #[Out]# 1.00000000e+00, 2.00000000e+00, 8.00000000e+00, #[Out]# 1.00000000e+01, 2.00000000e+00, 3.00000000e+00, #[Out]# 1.00000000e+00, 3.00000000e+00, 5.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 5.00000000e+00, #[Out]# 1.00000000e+00, 2.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 2.00000000e+00, 3.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 3.00000000e+00, #[Out]# 2.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 5.40000000e+01, 5.00000000e+00, #[Out]# 8.00000000e+00, 1.90000000e+01, 1.00000000e+00, #[Out]# 1.00000000e+00, 2.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+01, 3.00000000e+00, 2.00000000e+00, #[Out]# 2.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 3.30000000e+01, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 4.00000000e+00, 1.00000000e+00, #[Out]# 4.00000000e+00, 1.30000000e+01, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 2.00000000e+00, #[Out]# 2.00000000e+00, 2.00000000e+00, 1.00000000e+00, #[Out]# 2.00000000e+00, 1.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 2.00000000e+00, 3.00000000e+00, #[Out]# 1.40000000e+01, 2.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 2.00000000e+00, 3.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 3.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 5.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 5.00000000e+00, 4.00000000e+00, #[Out]# 4.00000000e+00, 2.20000000e+01, 2.00000000e+00, #[Out]# 3.00000000e+00, 1.00000000e+00, 3.00000000e+00, #[Out]# 3.00000000e+00, 2.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 2.00000000e+00, 1.00000000e+00, 4.00000000e+00, #[Out]# 4.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 5.00000000e+00, 1.10000000e+01, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 3.00000000e+00, 1.00000000e+00, 3.00000000e+00, #[Out]# 3.00000000e+00, 4.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 2.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 4.00000000e+00, 5.00000000e+00, #[Out]# 3.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 2.00000000e+00, 1.20000000e+01, 1.01400000e+03, #[Out]# 4.00000000e+00, 1.00000000e+00, 3.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 5.00000000e+00, #[Out]# 4.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 2.00000000e+00, 1.00000000e+00, #[Out]# 1.90000000e+01, 2.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+01, 3.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 2.00000000e+00, 4.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 2.00000000e+00, #[Out]# 1.10000000e+01, 5.00000000e+00, 1.00000000e+00, #[Out]# 7.00000000e+00, 2.00000000e+00, 1.00000000e+00, #[Out]# 3.00000000e+00, 1.00000000e+00, 2.00000000e+00, #[Out]# 6.40000000e+01, 1.00000000e+00, 1.00000000e+00, #[Out]# 2.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 2.00000000e+00, 1.00000000e+00, 3.00000000e+00, #[Out]# 4.00000000e+00, 5.80000000e+01, 9.00000000e+00, #[Out]# 9.30000000e+01, 8.10000000e+01, 6.00000000e+00, #[Out]# 2.00000000e+00, 1.00000000e+00, 2.91000000e+02, #[Out]# 3.00000000e+00, 1.00000000e+00, 4.00000000e+00, #[Out]# 1.30000000e+01, 1.35000000e+02, 3.10000000e+01, #[Out]# 4.00000000e+00, 2.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 3.00000000e+01, 1.00000000e+01, #[Out]# 5.20000000e+01, 2.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 4.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 2.62000000e+02, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 4.00000000e+00, 2.28000000e+03, 1.00000000e+00, #[Out]# 1.39000000e+02, 2.00000000e+00, 2.00000000e+00, #[Out]# 2.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 3.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 3.00000000e+00, 1.00000000e+00, 2.75000000e+02, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 8.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.13000000e+02, 2.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 2.00000000e+00, 2.27000000e+02, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.40000000e+01, 2.00000000e+00, #[Out]# 2.26000000e+02, 2.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 3.54000000e+02, 1.00000000e+00, 1.10000000e+01, #[Out]# 1.00000000e+00, 1.00000000e+01, 1.00000000e+00, #[Out]# 1.00000000e+00, 9.00000000e+00, 1.00000000e+00, #[Out]# 1.40000000e+01, 1.00000000e+00, 2.00000000e+00, #[Out]# 1.11000000e+02, 2.00000000e+00, 1.00000000e+00, #[Out]# 5.00000000e+00, 6.00000000e+00, 1.89000000e+02, #[Out]# 1.00000000e+00, 8.00000000e+00, 1.00000000e+00, #[Out]# 7.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 7.90000000e+01, 3.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 5.00000000e+00, 1.00000000e+00, #[Out]# 8.00000000e+00, 2.00000000e+00, 1.94000000e+02, #[Out]# 1.20000000e+01, 1.00000000e+00, 4.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 2.00000000e+00, #[Out]# 8.70000000e+01, 1.55000000e+02, 1.68400000e+03, #[Out]# 3.00000000e+00, 1.30000000e+01, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 2.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 3.00000000e+00, #[Out]# 6.00000000e+00, 1.87900000e+03, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 6.00000000e+00, #[Out]# 3.15000000e+02, 1.59000000e+02, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 5.00000000e+00, #[Out]# 6.80000000e+01, 2.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 2.00000000e+00, #[Out]# 1.59000000e+02, 3.95000000e+02, 6.00000000e+00, #[Out]# 5.00000000e+00, 6.00000000e+00, 6.80000000e+01, #[Out]# 4.00000000e+01, 5.10000000e+01, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 3.69000000e+02, 1.17000000e+02, 1.00000000e+00, #[Out]# 2.00000000e+00, 3.80000000e+01, 5.61000000e+02, #[Out]# 3.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 9.00000000e+00, #[Out]# 1.00000000e+00, 2.00000000e+00, 1.00000000e+00, #[Out]# 2.89000000e+02, 1.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 2.00000000e+00, #[Out]# 1.70000000e+01, 2.00000000e+00, 1.00000000e+00, #[Out]# 4.00000000e+00, 3.00000000e+00, 4.00000000e+00, #[Out]# 3.00000000e+00, 1.00000000e+00, 4.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00, 3.00000000e+00, #[Out]# 3.00000000e+00, 2.00000000e+00, 6.00000000e+00, #[Out]# 1.00000000e+00, 3.00000000e+00, 1.00000000e+00, #[Out]# 2.00000000e+00, 2.00000000e+00, 3.10000000e+01, #[Out]# 7.00000000e+00, 2.00000000e+00, 9.00000000e+00, #[Out]# 6.10000000e+01, 1.00000000e+00, 6.00000000e+00, #[Out]# 3.00000000e+00, 1.00000000e+00, 7.00000000e+00, #[Out]# 2.00000000e+00, 1.00000000e+00, 6.00000000e+00, #[Out]# 2.40000000e+01, 5.00000000e+00, 2.00000000e+00, #[Out]# 1.00000000e+00, 2.00000000e+00, 9.00000000e+00, #[Out]# 9.40000000e+01, 1.00000000e+00, 1.00000000e+00, #[Out]# 2.00000000e+00, 1.00000000e+00, 8.00000000e+00, #[Out]# 2.60000000e+01, 1.00000000e+00, 2.50000000e+01, #[Out]# 1.00000000e+00, 1.00000000e+00, 4.00000000e+00, #[Out]# 1.80000000e+01, 2.00000000e+00, 7.00000000e+00, #[Out]# 3.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.40000000e+01, 1.40000000e+01, 4.90000000e+01, #[Out]# 1.00000000e+00, 2.00000000e+00, 4.00000000e+00, #[Out]# 1.00000000e+00, 2.50000000e+01, 4.00000000e+00, #[Out]# 4.00000000e+00, 7.00000000e+00, 2.30000000e+01, #[Out]# 3.00000000e+00, 5.00000000e+00, 8.00000000e+00, #[Out]# 6.60000000e+01, 8.00000000e+00, 1.00000000e+01, #[Out]# 3.00000000e+00, 6.00000000e+00, 2.00000000e+00, #[Out]# 4.00000000e+00, 1.60000000e+01, 1.00000000e+00, #[Out]# 6.70000000e+01, 7.00000000e+00, 1.50000000e+02, #[Out]# 4.10000000e+01, 1.00000000e+00, 2.20000000e+01, #[Out]# 3.00000000e+00, 1.00000000e+00, 1.00000000e+00, #[Out]# 1.00000000e+00, 1.00000000e+00]) size_min_limit = 50 remove_segments = sizes < size_min_limit remove_segments[img_label] #[Out]# array([[ True, True, True, ..., True, True, True], #[Out]# [ True, True, True, ..., True, True, True], #[Out]# [ True, True, True, ..., True, True, True], #[Out]# ..., #[Out]# [False, False, False, ..., True, True, True], #[Out]# [False, False, False, ..., True, True, True], #[Out]# [False, False, False, ..., True, True, True]], dtype=bool) remove_mask = remove_segments[img_label] img_label[remove_mask] = 0 plt.imshow(img_label) #[Out]# plt.show() import numpy as np get_ipython().magic(u'pinfo np.unique') labels = np.unique(img_label) labels #[Out]# array([ 0, 4, 30, 54, 83, 92, 97, 127, 239, 276, 289, 291, 292, #[Out]# 296, 301, 309, 319, 325, 327, 338, 351, 356, 363, 369, 381, 386, #[Out]# 393, 401, 408, 409, 410, 430, 435, 436, 441, 447, 448, 452, 454, #[Out]# 459, 460, 464, 474, 504, 519, 552, 561, 563], dtype=int32) get_ipython().magic(u'pinfo np.searchsorted') img_label = np.searchsorted(labels, img_label) nb_labels = len(labels) plt.imshow(img_label) #[Out]# plt.show() ndimage.center_of_mass(img_label, labels, nb_labels+1) ndimage.center_of_mass(img_label, labels, nb_labels+1) get_ipython().magic(u'pinfo ndimage.center_of_mass') ndimage.center_of_mass(m, img_label, labels) #[Out]# [(274.99289099526067, 99.926540284360186), (60.863013698630134, 45.006849315068493), (413.25593824228031, 114.4667458432304), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan)] centers = ndimage.center_of_mass(m, img_label, labels) centers #[Out]# [(274.99289099526067, 99.926540284360186), (60.863013698630134, 45.006849315068493), (413.25593824228031, 114.4667458432304), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan), (nan, nan)] centers[0] #[Out]# (274.99289099526067, 99.926540284360186) centers[1] #[Out]# (60.863013698630134, 45.006849315068493) centers[2] #[Out]# (413.25593824228031, 114.4667458432304) centers[3] #[Out]# (nan, nan) centers[4] #[Out]# (nan, nan) centers[5] #[Out]# (nan, nan) labels] labels #[Out]# array([ 0, 4, 30, 54, 83, 92, 97, 127, 239, 276, 289, 291, 292, #[Out]# 296, 301, 309, 319, 325, 327, 338, 351, 356, 363, 369, 381, 386, #[Out]# 393, 401, 408, 409, 410, 430, 435, 436, 441, 447, 448, 452, 454, #[Out]# 459, 460, 464, 474, 504, 519, 552, 561, 563], dtype=int32) labels = np.unique(img_label) labels #[Out]# array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, #[Out]# 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, #[Out]# 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]) centers = ndimage.center_of_mass(m, img_label, labels) centers #[Out]# [(274.99289099526067, 99.926540284360186), (7.112903225806452, 30.677419354838708), (28.69811320754717, 103.75471698113208), (42.089285714285715, 112.85714285714286), (60.863013698630134, 45.006849315068493), (154.04898312418865, 112.49026395499784), (71.5, 32.413793103448278), (89.5, 60.388888888888886), (184.49112426035504, 34.280078895463511), (222.828125, 47.25), (238.68965517241378, 186.10344827586206), (241.40860215053763, 52.473118279569896), (241.8641975308642, 121.19753086419753), (250.85910652920961, 163.26116838487974), (259.62222222222221, 56.814814814814817), (259.84615384615387, 121.51923076923077), (269.1641221374046, 156.87022900763358), (445.33201754385965, 185.51271929824563), (278.58992805755395, 67.2158273381295), (286.66181818181821, 153.59272727272727), (297.10619469026551, 74.13274336283186), (305.29955947136563, 151.12775330396477), (318.63274336283183, 77.853982300884951), (327.37853107344631, 144.00564971751413), (342.48648648648651, 78.090090090090087), (350.68783068783068, 140.42328042328043), (360.32911392405066, 78.455696202531641), (368.29381443298968, 140.70103092783506), (377.85057471264366, 74.402298850574709), (386.11612903225807, 141.27741935483871), (413.25593824228031, 114.4667458432304), (495.27833954230977, 6.3432676955827567), (443.28888888888889, 145.54920634920634), (442.47169811320754, 99.345911949685529), (448.38235294117646, 61.676470588235297), (460.94339622641508, 100.12578616352201), (462.9594936708861, 144.1113924050633), (466.64705882352939, 60.441176470588232), (476.21568627450978, 175.94117647058823), (481.65853658536588, 143.49864498644988), (479.21367521367523, 99.282051282051285), (507.28163992869878, 96.748663101604279), (500.46020761245677, 144.54325259515571), (523.13114754098365, 145.36065573770492), (529.47872340425533, 126.72340425531915), (548.36363636363637, 83.015151515151516), (554.2388059701492, 81.880597014925371), (563.0333333333333, 103.40000000000001)] centers[:,0] np.array(centers) #[Out]# array([[ 274.992891 , 99.92654028], #[Out]# [ 7.11290323, 30.67741935], #[Out]# [ 28.69811321, 103.75471698], #[Out]# [ 42.08928571, 112.85714286], #[Out]# [ 60.8630137 , 45.00684932], #[Out]# [ 154.04898312, 112.49026395], #[Out]# [ 71.5 , 32.4137931 ], #[Out]# [ 89.5 , 60.38888889], #[Out]# [ 184.49112426, 34.2800789 ], #[Out]# [ 222.828125 , 47.25 ], #[Out]# [ 238.68965517, 186.10344828], #[Out]# [ 241.40860215, 52.47311828], #[Out]# [ 241.86419753, 121.19753086], #[Out]# [ 250.85910653, 163.26116838], #[Out]# [ 259.62222222, 56.81481481], #[Out]# [ 259.84615385, 121.51923077], #[Out]# [ 269.16412214, 156.87022901], #[Out]# [ 445.33201754, 185.5127193 ], #[Out]# [ 278.58992806, 67.21582734], #[Out]# [ 286.66181818, 153.59272727], #[Out]# [ 297.10619469, 74.13274336], #[Out]# [ 305.29955947, 151.1277533 ], #[Out]# [ 318.63274336, 77.8539823 ], #[Out]# [ 327.37853107, 144.00564972], #[Out]# [ 342.48648649, 78.09009009], #[Out]# [ 350.68783069, 140.42328042], #[Out]# [ 360.32911392, 78.4556962 ], #[Out]# [ 368.29381443, 140.70103093], #[Out]# [ 377.85057471, 74.40229885], #[Out]# [ 386.11612903, 141.27741935], #[Out]# [ 413.25593824, 114.46674584], #[Out]# [ 495.27833954, 6.3432677 ], #[Out]# [ 443.28888889, 145.54920635], #[Out]# [ 442.47169811, 99.34591195], #[Out]# [ 448.38235294, 61.67647059], #[Out]# [ 460.94339623, 100.12578616], #[Out]# [ 462.95949367, 144.11139241], #[Out]# [ 466.64705882, 60.44117647], #[Out]# [ 476.21568627, 175.94117647], #[Out]# [ 481.65853659, 143.49864499], #[Out]# [ 479.21367521, 99.28205128], #[Out]# [ 507.28163993, 96.7486631 ], #[Out]# [ 500.46020761, 144.5432526 ], #[Out]# [ 523.13114754, 145.36065574], #[Out]# [ 529.4787234 , 126.72340426], #[Out]# [ 548.36363636, 83.01515152], #[Out]# [ 554.23880597, 81.88059701], #[Out]# [ 563.03333333, 103.4 ]]) centers = np.array(centers) centers[:,0] #[Out]# array([ 274.992891 , 7.11290323, 28.69811321, 42.08928571, #[Out]# 60.8630137 , 154.04898312, 71.5 , 89.5 , #[Out]# 184.49112426, 222.828125 , 238.68965517, 241.40860215, #[Out]# 241.86419753, 250.85910653, 259.62222222, 259.84615385, #[Out]# 269.16412214, 445.33201754, 278.58992806, 286.66181818, #[Out]# 297.10619469, 305.29955947, 318.63274336, 327.37853107, #[Out]# 342.48648649, 350.68783069, 360.32911392, 368.29381443, #[Out]# 377.85057471, 386.11612903, 413.25593824, 495.27833954, #[Out]# 443.28888889, 442.47169811, 448.38235294, 460.94339623, #[Out]# 462.95949367, 466.64705882, 476.21568627, 481.65853659, #[Out]# 479.21367521, 507.28163993, 500.46020761, 523.13114754, #[Out]# 529.4787234 , 548.36363636, 554.23880597, 563.03333333]) xs = centers[:,0] ys = centers[:,0] xs = centers[:,1] plt.imshow(m, cmap="Greys_r") #[Out]# plt.plot(xs, ys, "r+") #[Out]# [] plt.show() get_ipython().magic(u'logstart') get_ipython().magic(u'pwd ') #[Out]# u'/home/tpolgrabia/Dokumenty/prace/signal-processing/shoe-soles' help %logstart get_ipython().magic(u'pinfo %logstart') get_ipython().magic(u'logstart -o') get_ipython().magic(u'logstop') get_ipython().magic(u'logstart -o') get_ipython().magic(u'logstop') # nie, 10 lip 2016 18:10:54 get_ipython().magic(u'pwd ') #[Out]# u'/home/tpolgrabia/Dokumenty/prace/signal-processing/shoe-soles' # nie, 10 lip 2016 18:10:59 get_ipython().system(u'cat ipython_log.py') # nie, 10 lip 2016 18:11:52 pw # nie, 10 lip 2016 18:12:19 get_ipython().magic(u'edit') #[Out]# 'corners = np.zeros(img.shape, dtype=np.bool)\n\nfor i in range(0, nb_labels):\n mseg = img_label == i\n seg_corner = calc_shape_corners(mseg)\n corners += seg_corner\n\n(n,m) = img.shape\nmat_x = np.tile(np.arange(0, m),n).reshape((n,m))\nmat_y = np.tile(np.arange(0, n),m).reshape((m,n)).T\n\nxs = mat_x[corners]\nys = mat_y[corners]\n\nplt.imshow(img, cmap="Greys_r")\nplt.plot(xs, ys, "b+")\nplt.show()\n' # nie, 10 lip 2016 18:16:31 get_ipython().magic(u'edit _') #[Out]# 'corners = np.zeros(img.shape, dtype=np.bool)\n\nfor i in range(0, nb_labels):\n mseg = img_label == i\n seg_corner = calc_shape_corners(mseg)\n corners += seg_corner\n\n(n,m) = img.shape\nmat_x = np.tile(np.arange(0, m),n).reshape((n,m))\nmat_y = np.tile(np.arange(0, n),m).reshape((m,n)).T\n\nxs = mat_x[corners]\nys = mat_y[corners]\n\nplt.imshow(img, cmap="Greys_r")\nplt.plot(xs, ys, "b+")\nplt.show()\n' # nie, 10 lip 2016 18:17:03 get_ipython().magic(u'edit dect.py') # nie, 10 lip 2016 18:17:28 get_ipython().magic(u'edit __') #[Out]# 'corners = np.zeros(img.shape, dtype=np.bool)\n\nfor i in range(0, nb_labels):\n mseg = img_label == i\n seg_corner = calc_shape_corners(mseg)\n corners += seg_corner\n\n(n,m) = img.shape\nmat_x = np.tile(np.arange(0, m),n).reshape((n,m))\nmat_y = np.tile(np.arange(0, n),m).reshape((m,n)).T\n\nxs = mat_x[corners]\nys = mat_y[corners]\n\nplt.imshow(img, cmap="Greys_r")\nplt.plot(xs, ys, "b+")\nplt.show()\n' # nie, 10 lip 2016 18:18:12 get_ipython().magic(u'edit _') #[Out]# 'corners = np.zeros(img.shape, dtype=np.bool)\n\nfor i in range(0, nb_labels):\n mseg = img_label == i\n seg_corner = calc_shape_corners(mseg)\n corners = corners + seg_corner\n\n(n,m) = img.shape\nmat_x = np.tile(np.arange(0, m),n).reshape((n,m))\nmat_y = np.tile(np.arange(0, n),m).reshape((m,n)).T\n\nxs = mat_x[corners]\nys = mat_y[corners]\n\nplt.imshow(img, cmap="Greys_r")\nplt.plot(xs, ys, "b+")\nplt.show()\n' # nie, 10 lip 2016 18:18:50 get_ipython().magic(u'edit _') #[Out]# 'corners = np.zeros(img.shape, dtype=np.bool)\n\nfor i in range(0, nb_labels):\n mseg = img_label == i\n seg_corner = calc_shape_corners(mseg)\n plt.imshow(seg_corner, cmap="Greys_r")\n plt.show()\n corners = corners + seg_corner\n\n(n,m) = img.shape\nmat_x = np.tile(np.arange(0, m),n).reshape((n,m))\nmat_y = np.tile(np.arange(0, n),m).reshape((m,n)).T\n\nxs = mat_x[corners]\nys = mat_y[corners]\n\nplt.imshow(img, cmap="Greys_r")\nplt.plot(xs, ys, "b+")\nplt.show()\n' # nie, 10 lip 2016 18:20:23 get_ipython().magic(u'edit __') #[Out]# 'corners = np.zeros(img.shape, dtype=np.bool)\n\nfor i in range(0, nb_labels):\n mseg = img_label == i\n plt.imshow(mseg, cmap="Greys_r")\n seg_corner = calc_shape_corners(mseg)\n corners = corners + seg_corner\n\n(n,m) = img.shape\nmat_x = np.tile(np.arange(0, m),n).reshape((n,m))\nmat_y = np.tile(np.arange(0, n),m).reshape((m,n)).T\n\nxs = mat_x[corners]\nys = mat_y[corners]\n\nplt.imshow(img, cmap="Greys_r")\nplt.plot(xs, ys, "b+")\nplt.show()\n' # nie, 10 lip 2016 18:20:44 get_ipython().magic(u'edit __') #[Out]# 'corners = np.zeros(img.shape, dtype=np.bool)\n\nfor i in range(0, nb_labels):\n mseg = img_label == i\n seg_corner = calc_shape_corners(mseg)\n plt.imshow(seg_corner, cmap="Greys_r")\n plt.show()\n corners = corners + seg_corner\n\n(n,m) = img.shape\nmat_x = np.tile(np.arange(0, m),n).reshape((n,m))\nmat_y = np.tile(np.arange(0, n),m).reshape((m,n)).T\n\nxs = mat_x[corners]\nys = mat_y[corners]\n\nplt.imshow(img, cmap="Greys_r")\nplt.plot(xs, ys, "b+")\nplt.show()\n' # nie, 10 lip 2016 18:21:07 get_ipython().magic(u'edit _') #[Out]# 'corners = np.zeros(img.shape, dtype=np.bool)\n\nfor i in range(0, nb_labels):\n mseg = img_label == i\n plt.imshow(mseg, cmap="Greys_r")\n plt.show()\n seg_corner = calc_shape_corners(mseg)\n corners = corners + seg_corner\n\n(n,m) = img.shape\nmat_x = np.tile(np.arange(0, m),n).reshape((n,m))\nmat_y = np.tile(np.arange(0, n),m).reshape((m,n)).T\n\nxs = mat_x[corners]\nys = mat_y[corners]\n\nplt.imshow(img, cmap="Greys_r")\nplt.plot(xs, ys, "b+")\nplt.show()\n' # nie, 10 lip 2016 18:22:01 get_ipython().magic(u'edit test.py') # nie, 10 lip 2016 18:22:10 get_ipython().magic(u'save 1-92 try.py') # nie, 10 lip 2016 18:22:16 get_ipython().magic(u'save try.py 1-92') # nie, 10 lip 2016 18:22:22 get_ipython().magic(u'edit test.py') # nie, 10 lip 2016 18:22:33 get_ipython().magic(u'edit ___') #[Out]# 'corners = np.zeros(img.shape, dtype=np.bool)\n\nfor i in range(0, nb_labels):\n mseg = img_label == i\n# plt.imshow(mseg, cmap="Greys_r")\n seg_corner = calc_shape_corners(mseg)\n corners = corners + seg_corner\n\n(n,m) = img.shape\nmat_x = np.tile(np.arange(0, m),n).reshape((n,m))\nmat_y = np.tile(np.arange(0, n),m).reshape((m,n)).T\n\nxs = mat_x[corners]\nys = mat_y[corners]\n\nplt.imshow(img, cmap="Greys_r")\nplt.plot(xs, ys, "b+")\nplt.show()\n' # nie, 10 lip 2016 18:22:58 get_ipython().magic(u'edit ___') #[Out]# 'corners = np.zeros(img.shape, dtype=np.bool)\n\nfor i in range(0, nb_labels):\n mseg = img_label == i\n seg_corner = calc_shape_corners(mseg)\n plt.imshow(seg_corner, cmap="Greys_r")\n plt.show()\n corners = corners + seg_corner\n\n(n,m) = img.shape\nmat_x = np.tile(np.arange(0, m),n).reshape((n,m))\nmat_y = np.tile(np.arange(0, n),m).reshape((m,n)).T\n\nxs = mat_x[corners]\nys = mat_y[corners]\n\nplt.imshow(img, cmap="Greys_r")\nplt.plot(xs, ys, "b+")\nplt.show()\n' # nie, 10 lip 2016 18:23:05 get_ipython().magic(u'edit __') #[Out]# 'corners = np.zeros(img.shape, dtype=np.bool)\n\nfor i in range(0, nb_labels):\n mseg = img_label == i\n# plt.imshow(mseg, cmap="Greys_r")\n seg_corner = calc_shape_corners(mseg)\n corners = corners + seg_corner\n\n(n,m) = img.shape\nmat_x = np.tile(np.arange(0, m),n).reshape((n,m))\nmat_y = np.tile(np.arange(0, n),m).reshape((m,n)).T\n\nxs = mat_x[corners]\nys = mat_y[corners]\n\nplt.imshow(img, cmap="Greys_r")\nplt.plot(xs, ys, "b+")\nplt.show()\n' # nie, 10 lip 2016 18:23:13 get_ipython().magic(u'edit _') #[Out]# 'corners = np.zeros(img.shape, dtype=np.bool)\n\nfor i in range(0, nb_labels):\n mseg = img_label == i\n# plt.imshow(mseg, cmap="Greys_r")\n seg_corner = calc_shape_corners(mseg)\n corners = corners + seg_corner\n\n(n,m) = img.shape\nmat_x = np.tile(np.arange(0, m),n).reshape((n,m))\nmat_y = np.tile(np.arange(0, n),m).reshape((m,n)).T\n\nxs = mat_x[corners]\nys = mat_y[corners]\n\nplt.imshow(img, cmap="Greys_r")\nplt.plot(xs, ys, "b+")\nplt.show()\n' # nie, 10 lip 2016 18:24:06 get_ipython().magic(u'reload_ext') # nie, 10 lip 2016 18:24:50 get_ipython().magic(u'load_ext %autoreload') # nie, 10 lip 2016 18:25:30 get_ipython().magic(u'edit _') #[Out]# 'corners = np.zeros(img.shape, dtype=np.bool)\n\nfor i in range(0, nb_labels):\n mseg = img_label == i\n# plt.imshow(mseg, cmap="Greys_r")\n seg_corner = calc_shape_corners(mseg)\n corners = corners + seg_corner\n\n(n,m) = img.shape\nmat_x = np.tile(np.arange(0, m),n).reshape((n,m))\nmat_y = np.tile(np.arange(0, n),m).reshape((m,n)).T\n\nxs = mat_x[corners]\nys = mat_y[corners]\n\nplt.imshow(img, cmap="Greys_r")\nplt.plot(xs, ys, "b+")\nplt.show()\n' # nie, 10 lip 2016 18:26:10 with open("processing.py", "w+") as f: f.write(Out[102]) # nie, 10 lip 2016 18:26:14 get_ipython().system(u'cat processing.py')