當前位置: 首頁>>代碼示例>>Python>>正文


Python EMAN.image2list方法代碼示例

本文整理匯總了Python中EMAN.image2list方法的典型用法代碼示例。如果您正苦於以下問題:Python EMAN.image2list方法的具體用法?Python EMAN.image2list怎麽用?Python EMAN.image2list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在EMAN的用法示例。


在下文中一共展示了EMAN.image2list方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import EMAN [as 別名]
# 或者: from EMAN import image2list [as 別名]
def main():
	
	(options, input_imagefiles, output_lstfile) = parse_command_line()
	
	Particle.sym = options.sym
	Particle.max_ang_diff = options.max_ang_diff * math.pi/180.0
	Particle.max_cen_diff = options.max_cen_diff
		
	image_lists = []
	
	for f in input_imagefiles:	# build the image sets
		tmp_image_list = EMAN.image2list(f)
		
		# first check and remove duplicate images
		seen = sets.Set()
		tmp_image_list2 = []
		for i, img in enumerate(tmp_image_list): 
			imgid = "%s-%d" % (os.path.abspath(img[0]), img[1])
			if imgid in seen:
				print "%s: particle %d/%d (%s %d) is a duplicate image, ignored" % (f, i, len(tmp_image_list), img[0], img[1])
			else:
				seen.add(imgid)
				tmp_image_list2.append(img)
		
		image_list = sets.Set()
		for i, img in enumerate(tmp_image_list2): 
			p = Particle(img)
			image_list.add(p)
		print "%s: %d images" % (f, len(image_list))
		image_lists.append( image_list )

	all_images = image_lists[0]
	print "Begining with %d images in %s" % (len(all_images), input_imagefiles[0])
	for i in range(1,len(image_lists)):
		image_list = image_lists[i]
		if options.mode == "common":	# all_images & imageset
			all_images = intersection(all_images, image_list)
			print "%d common images after processing %d images in %s" % ( len(all_images), len(image_list), input_imagefiles[i] )
		elif options.mode == "union":
			all_images = union(all_images, image_list)	# all_images | imageset
			print "%d images after merging %d images in %s" % ( len(all_images), len(image_list), input_imagefiles[i] )
		elif options.mode == "diff":
			all_images = difference(all_images,image_list)	# all_images-imageset
			print "%d different images after processing %d images in %s" % ( len(all_images), len(image_list), input_imagefiles[i] )
		elif options.mode == "symdiff":
			all_images = symmetric_difference(all_images,image_list)	# all_images ^ imageset
			print "%d different images after processing %d images in %s" % ( len(all_images), len(image_list), input_imagefiles[i] )
	
	all_images=list(all_images)
	all_images.sort()
	
	all_images_output_list = [i.image for i in  all_images]
			
	if len(all_images_output_list):
		print "%d images saved to %s" % ( len(all_images_output_list), output_lstfile )
		EMAN.imagelist2lstfile(all_images_output_list, output_lstfile)
	else:
		print "No image left after the image sets operation"
開發者ID:,項目名稱:,代碼行數:60,代碼來源:


注:本文中的EMAN.image2list方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。