Exemple #1
0
from global_segmentation import (
    read_pgm, )

GT = read_pgm(f'Data\\Ground Truth\\TEST_55.pgm')
IM = read_pgm(f'Data\\Brain Volume\\TEST_55.pgm')

Y = 217  # height
X = 181  # col

intensity = {}
for k in range(Y):
    for l in range(X):
        if GT[k][l] not in intensity:
            intensity[GT[k][l]] = [IM[k][l]]
        else:
            intensity[GT[k][l]].append(IM[k][l])

for ele in intensity:
    print(ele, " ", sum(intensity[ele]) / len(intensity[ele]))
N_IT  = 100

C     = [13,45,100,115]	   	# Values of the initial Clusters
A     = 0.7					# Value of alpha
N     = len(C)
P     = 1
Q     = 3
M     = 2.5
E     = 0.01
p 	  = (1/(M-1))


img_vol 	 = []
ground_truth = []
for j in range(START,END):
    img_vol.append(read_pgm(f'Data\\Brain Volume\\TEST_{j}.pgm'))
    ground_truth.append(read_pgm(f'Data\\Ground Truth\\TEST_{j}.pgm'))

print("Z = ",len(img_vol))
print("Y = ",len(img_vol[0]))
print("X = ",len(img_vol[0][0]))


global_u = full((len(C),Z,Y,X),0).tolist()
local_u  = full((len(C),Z,Y,X),0).tolist()
final_u  = full((len(C),Z,Y,X),0).tolist()

for i in range(N):
	for j in range(Z):
		for k in range(Y):
			for l in range(X):

def intersection(lst1, lst2):
    return list(set(lst1) & set(lst2))


START = 50
END = 52
Z = (END - START)  # depth
Y = 217  # height
X = 181  # col

test_img = []
ground_truth = []
for j in range(START, END):
    test_img.append(read_pgm(f'Data\\Test Results\\TEST_{j}.pgm'))
    ground_truth.append(read_pgm(f'Data\\Ground Truth\\TEST_{j}.pgm'))

correct_classified = 0
mis_classified = 0

# Misclassification Error
for j in range(Z):
    for k in range(Y):
        for l in range(X):
            if ground_truth[j][k][l] in [0, 1, 2, 3]:
                if ground_truth[j][k][l] == test_img[j][k][l]:
                    correct_classified += 1
                else:
                    mis_classified += 1