I used supervise.ly tool to manually create masks. However, the order and assignment of mask labels are not consistent across images. Is it possible to redefine the order and assignment of them?
Note: If this problem needs mask label annotations you can download them from here.
Input- 1
Order
[0 3 4 5 6 7 8]
Assignment
0 - unlabeled
3 - left_psoas
4 - right_psoas
5 - left_erector
6 - right_erector
7 - left_rectus
8 - right_rectus
Input-2
Order
[0 3 4 5 6 7 8]
Assignment
0 - unlabeled
3 - left_rectus
4 - right_rectus
5 - left_psoas
6 - right_psoas
7 - left_erector
8 - right_erector
I want something like this
output-1
Order
[0 1, 2, 3, 4, 5, 6]
Assignment
0 - unlabeled
1 - left_psoas
2 - right_psoas
3 - left_erector
4 - right_erector
5 - left_rectus
6 - right_rectus
output-2
Order
[0 1, 2, 3, 4, 5, 6]
Assignment
0 - unlabeled
1 - left_psoas
2 - right_psoas
3 - left_erector
4 - right_erector
5 - left_rectus
6 - right_rectus
Reproducible_example
Input-1
numpy.set_printoptions(threshold=sys.maxsize)
#IM-0010-0007 - Rectus, Psoas
mask = Image.open(urlopen('https://user-images.githubusercontent.com/3885659/78283975-27721000-750e-11ea-8c0b-57d682c45f18.png'))
#plt.imshow(mask)
array = np.array(mask)
#print('Array Dimensions', array.shape)
new_array = [tuple(row) for row in array]
uniques = np.unique(new_array)
print(uniques)
#IM-0010-0010 - Rectus, Psoas, Erector
mask = Image.open(urlopen('https://user-images.githubusercontent.com/3885659/78284008-38228600-750e-11ea-95cc-0e71c1c90ade.png'))
array = np.array(mask)
new_array = [tuple(row) for row in array]
uniques = np.unique(new_array)
print(uniques)
#IM-0010-0011 - Rectus, Erector
mask = Image.open(urlopen('https://user-images.githubusercontent.com/3885659/78284035-453f7500-750e-11ea-8439-d26b9168c805.png'))
array = np.array(mask)
new_array = [tuple(row) for row in array]
uniques = np.unique(new_array)
print(uniques)
Input-2
numpy.set_printoptions(threshold=sys.maxsize)
# IM-0010-0005 - Rectus
mask = Image.open(urlopen('https://user-images.githubusercontent.com/3885659/78290155-cef14180-7512-11ea-96f4-c7f0ad9566b4.png'))
array = np.array(mask)
new_array = [tuple(row) for row in array]
uniques = np.unique(new_array)
print(uniques)
# IM-0010-0006 - Rectus, Psoas
mask = Image.open(urlopen('https://user-images.githubusercontent.com/3885659/78290189-dd3f5d80-7512-11ea-9eab-d0f861c5bf16.png'))
array = np.array(mask)
new_array = [tuple(row) for row in array]
uniques = np.unique(new_array)
print(uniques)
# IM-0010-0008 - Rectus, Psoas, Erector
mask = Image.open(urlopen('https://user-images.githubusercontent.com/3885659/78290216-eb8d7980-7512-11ea-9b17-1f1c1c170886.png'))
array = np.array(mask)
new_array = [tuple(row) for row in array]
uniques = np.unique(new_array)
print(uniques)