Код: Выделить всё
nifti_img = nib.load(file_path)
# Get the image data
img_data = nifti_img.get_fdata()
clahe_slices = np.zeros_like(img_data)
clahe_slices1 = np.zeros_like(img_data)
clahe_slices2 = np.zeros_like(img_data)
clahe_slices3 = np.zeros_like(img_data)
#I have filtered slides, but when editing the dimension must be specified like #this, and when I specify the dimension, it filters the other dimensions, but #it does not verify that the slide content in the other dimensions is empty, #and thus there are problems in the result.
#Because of this, I thought of applying the filter and specifying a dimension #each time, and in the end I collect the results of each dimension to obtain #correct results. Here, when I specify that, it does not save the result of #clahe_slices1 and clahe_slices2, but only the result of the last episode in #all dimensions. I'm still new to nifti anf numpy.
#Please give me a solution to this, thank you
#The code is very long and only included the important elements in
#the problem
for i in range(img_data.shape[0]):
# Assuming the slice dimension is the first dimension
clahe_slices[i, :, :] = clahe_slices1[i, :, :]
for i in range(img_data.shape[2]):
# Assuming the slice dimension is the third dimension
clahe_slices[:, :, i] = clahe_slices3[:, :, i]
for i in range(img_data.shape[1]):
# Assuming the slice dimension is the second dimension
clahe_slices[:, i, :] = clahe_slices2[:, i, :]
# Example usage:
return clahe_slicesУ меня проблемы с кодом. Содержимое clahe_slices3 сохраняется во всех измерениях в clahe_slices. Я хочу, чтобы содержимое clahe_slices1 сохранялось в первом измерении, clahe_slices2 — во втором измерении, а clahe_slices3 — в третьем измерении. В clahe_slices
Подробнее здесь: https://stackoverflow.com/questions/781 ... -in-the-fi