本文整理汇总了Python中msct_image.Image.data[:,:,i]方法的典型用法代码示例。如果您正苦于以下问题:Python Image.data[:,:,i]方法的具体用法?Python Image.data[:,:,i]怎么用?Python Image.data[:,:,i]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msct_image.Image
的用法示例。
在下文中一共展示了Image.data[:,:,i]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_overlap
# 需要导入模块: from msct_image import Image [as 别名]
# 或者: from msct_image.Image import data[:,:,i] [as 别名]
def remove_overlap(file_centerline_generated_by_labels, file_with_seg_or_centerline, output_file_name, parameter=0):
# Image file process
if parameter == 0 :
image_with_seg_or_centerline = Image(file_with_seg_or_centerline).copy()
z_test = ComputeZMinMax(image_with_seg_or_centerline)
zmax = z_test.Zmax
zmin = z_test.Zmin
tab1 = Image(file_centerline_generated_by_labels).copy()
size_x=tab1.data.shape[0]
size_y=tab1.data.shape[1]
#X_coor, Y_coor, Z_coor = (tab1.data).nonzero()
#nb_one = X_coor.shape[0]
#for i in range(0, nb_one):
# tab1.data[X_coor[i], Y_coor[i], X_coor[i]] = 0
#each slice under zmax is filled with zeros
print zmax
for i in range(zmin, zmax):
tab1.data[:,:,i] = np.zeros((size_x,size_y))
#Save file
tab1.setFileName(output_file_name)
tab1.save('minimize') #size of image should be minimized
# Text file process
if parameter == 1 :
z_test = ComputeZMinMax(file_with_seg_or_centerline)
zmax = z_test.Zmax
zmin = z_test.Zmin
print zmax
#create output txt file
tab2 = open(output_file_name , "w")
tab2.close()
#Delete lines under zmax
with open(file_centerline_generated_by_labels) as f:
data_line = f.readlines()
with open(output_file_name, "w") as f1:
for line in data_line:
words = line.split()
if int(words [0]) < zmin or int(words [0]) > zmax :
f1.write(line)