当前位置: 首页>>代码示例>>Python>>正文


Python WindowManager.getImageCount方法代码示例

本文整理汇总了Python中ij.WindowManager.getImageCount方法的典型用法代码示例。如果您正苦于以下问题:Python WindowManager.getImageCount方法的具体用法?Python WindowManager.getImageCount怎么用?Python WindowManager.getImageCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ij.WindowManager的用法示例。


在下文中一共展示了WindowManager.getImageCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: select_images

# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImageCount [as 别名]
def select_images():
    """
    Returns two ImagePlus objects that can be used by the drift correction.
    If more than two images are available a dialog is used for selection.
    """
    if WindowManager.getImageCount() > 0:
        imp = WindowManager.getCurrentImage()
        if imp.getImageStackSize() == 2:
            dup = Duplicator()
            img1 = dup.run(imp, 1, 1)
            img1.setTitle("Slice1")
            img2 = dup.run(imp, 2, 2)
            img2.setTitle("Slice2")
        elif WindowManager.getImageCount() == 2:
            img1, img2 = [WindowManager.getImage(id) for id in WindowManager.getIDList()]
        elif WindowManager.getImageCount() > 2:
            image_ids = WindowManager.getIDList()
            image_titles = [WindowManager.getImage(id).getTitle() for id in image_ids]
            try:
                sel1, sel2 = dialogs.create_selection_dialog(image_titles, range(2))
            except TypeError:
                return(None, None)
            img1 = WindowManager.getImage(image_ids[sel1])
            img2 = WindowManager.getImage(image_ids[sel2])
        else:
            IJ.error("You need two images to run the script.")
            return(None, None)
    else:
        IJ.error("You need two images to run the script.")
        return(None, None)
    return (img1, img2)
开发者ID:m-entrup,项目名称:EFTEMj,代码行数:33,代码来源:Correct_drift_(2_images).py

示例2: run_script

# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImageCount [as 别名]
def run_script():
    while WindowManager.getImageCount() < 10:
        create_test_image()
     
    image_titles = [WindowManager.getImage(id).getTitle() for id in WindowManager.getIDList()]
    # range(3) will create the list [0, 1, 2].
    selected_indices = create_selection_dialog(image_titles, range(3))
    # The script stops if the dialog has ben canceld (None was returned from create_selection_dialog).
    if selected_indices is None:
        print('Script was canceld.')
        return
    # We have to get the corresponding IMagePlus objects.
    selected_imps = [WindowManager.getImage(id) for id in [WindowManager.getIDList()[index] for index in selected_indices]]
    # The previous line can be split into 2 lines:
    # selected_ids = [WindowManager.getIDList()[index] for index in selected_indices]
    # selected_imps = [WindowManager.getImage(id) for id in selected_ids]
     
    for imp in selected_imps:
        # Strings can be formated using the % operator:
        # http://www.learnpython.org/en/String_Formatting
        IJ.log('The image \'%s\' has been selected.' % imp.getTitle())
开发者ID:imagej,项目名称:imagej-scripting,代码行数:23,代码来源:Wiki_Jython_Tutorial_1.py

示例3: Microscope_Communicator

# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImageCount [as 别名]
# Christian's method

from embl.almf import Microscope_Communicator
from ij import WindowManager

wm = WindowManager
#microscope = "LSM780"
microscope = "File system"
mc = Microscope_Communicator()
mc.setMicroscope(microscope)
mc.setFilepath('/Users/miura/Desktop/tmp/watch/p1_1.tif')
while True:
	mc.obtainImage(microscope)
	# check any hit
	
	if (WindowManager.getImageCount() > 0):
		#mc.image_selected_particle(int offsetx, int offsety)
		IJ.log("retrieved")
		break
	else:
		mc.do_nothing()
	
开发者ID:manerotoni,项目名称:CommMicroscope,代码行数:23,代码来源:useMicroscopeCommunicatorRegistry.py

示例4: __buildstack

# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImageCount [as 别名]
	def __buildstack(self, listfiles):						
		"""
		Creates stacks according to the list of paths given by the user.
		
		
		"""
		
		

		if not isinstance(listfiles[0],list) and os.path.isfile(listfiles[0]) : 
			if len(self.__positionsList)==0 : tempname = WindowManager.getUniqueName("image")
			else : tempname = self.__positionsList[0]
			tempd = tempfile.mkdtemp()
			fichier = open(tempd+"/"+tempname+".tif","w")
			rawtimes=[]
			rawtimes.append(0)
			zerotimes=0
			for i in range(len(listfiles)-1) :
				difftimes=int((os.stat(listfiles[i+1]).st_mtime-os.stat(listfiles[i]).st_mtime))
				if difftimes==0 : zerotimes+=1
				rawtimes.append(rawtimes[-1]+difftimes)
				fichier.writelines(listfiles[i]+"\n")
			
			fichier.writelines(listfiles[-1]+"\n")
			fichier.close()
			IJ.run("Stack From List...","open="+tempd+"/"+tempname+".tif")
			n=WindowManager.getImageCount()
			tempid=WindowManager.getNthImageID(n)
			tempimg=WindowManager.getImage(tempid)
			if self.__batch : tempimg.hide()
			else : tempimg.show()
			self.__dictImages[tempname]=tempimg
			tempimg.hide()
			nameimages=tempname
			if zerotimes/len(rawtimes) > 0.5 : rawtimes=range(len(listfiles))
			self.__dictTimeStack["image1"]=rawtimes
			

		#elif isinstance(listfiles[0][0],str) :
		elif os.path.isfile(listfiles[0][0]) : 
			nameimages=[]
			rawtimes=[]
			rawtimes.append(0)
			for i in range(len(listfiles)) :
				if len(self.__positionsList)==0 : tempname = WindowManager.getUniqueName("image"+str(i+1))
				else : tempname = self.__positionsList[i]
				tempd = tempfile.mkdtemp()
				fichier = open(tempd+"/"+tempname+".tif","w")
				zerotimes=0
				for j in range(len(listfiles[i])-1) :
					difftimes=int((os.stat(listfiles[i][j+1]).st_mtime-os.stat(listfiles[i][j]).st_mtime))
					if difftimes==0 : zerotimes+=1
					rawtimes.append(rawtimes[-1]+difftimes)
					fichier.writelines(listfiles[i][j]+"\n")

				fichier.writelines(listfiles[i][-1]+"\n")
				fichier.close()
				IJ.run("Stack From List...","open="+tempd+"/"+tempname+".tif")
				n=WindowManager.getImageCount()
				tempid=WindowManager.getNthImageID(n)
				tempimg=WindowManager.getImage(tempid)
				#self.__dictImages["image"+str(i+1)]=tempimg
				#nameimages.append("image"+str(i+1))
				self.__dictImages[tempname]=tempimg
				nameimages.append(tempname)
				if zerotimes/len(rawtimes) > 0.5 : rawtimes=range(len(listfiles[i]))
				#self.__dictTimeStack["image"+str(i+1)]=rawtimes
				self.__dictTimeStack[tempname]=rawtimes
				rawtimes=[] 
				rawtimes.append(0)
				tempimg.hide()
			
		
		else : 
			nameimages=[]
			print "ERROR IN BUILDSTACK"

		return nameimages
开发者ID:leec13,项目名称:MorphoBactDev,代码行数:80,代码来源:BacteriaTracking.py

示例5: __buildstacks

# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImageCount [as 别名]
	def __buildstacks(self) :
		listfiles = self.__listfiles[2]
		positionsList = self.__imagesnames
		
		if not isinstance(listfiles[0],list) and os.path.isfile(listfiles[0]) : 
			if len(positionsList)==0 : tempname = WindowManager.getUniqueName("image")
			else : tempname = positionsList[0]
			tempd = tempfile.mkdtemp()
			fichier = open(tempd+os.path.sep+tempname+".tif","w")
			rawtimes=[]
			rawtimes.append(0)
			zerotimes=0
			for i in range(len(listfiles)-1) :
				difftimes=int((os.stat(listfiles[i+1]).st_mtime-os.stat(listfiles[i]).st_mtime))
				if difftimes==0 : zerotimes+=1
				rawtimes.append(rawtimes[-1]+difftimes)
				fichier.writelines(listfiles[i]+"\n")
			
			fichier.writelines(listfiles[-1]+"\n")
			fichier.close()
			IJ.run("Stack From List...","open="+tempd+os.path.sep+tempname+".tif")
			n=WindowManager.getImageCount()
			tempid=WindowManager.getNthImageID(n)
			tempimg=WindowManager.getImage(tempid)
			tempimg.show()
			#self.__dictImages[tempname]=tempimg
			#tempimg.hide()
			nameimages=tempname+"tif"
			#if zerotimes/len(rawtimes) > 0.5 : rawtimes=range(len(listfiles))
			#self.__dictTimeStack[tempname]=rawtimes
			

		#elif isinstance(listfiles[0][0],str) :
		elif os.path.isfile(listfiles[0][0]) : 
			nameimages=[]
			rawtimes=[]
			rawtimes.append(0)
			for i in range(len(listfiles)) :
				if len(positionsList)==0 : tempname = WindowManager.getUniqueName("image"+str(i+1))
				else : tempname = positionsList[i]
				tempd = tempfile.mkdtemp()
				fichier = open(tempd+os.path.sep+tempname+".tif","w")
				zerotimes=0
				for j in range(len(listfiles[i])-1) :
					difftimes=int((os.stat(listfiles[i][j+1]).st_mtime-os.stat(listfiles[i][j]).st_mtime))
					if difftimes==0 : zerotimes+=1
					rawtimes.append(rawtimes[-1]+difftimes)
					fichier.writelines(listfiles[i][j]+"\n")

				fichier.writelines(listfiles[i][-1]+"\n")
				fichier.close()
				IJ.run("Stack From List...","open="+tempd+os.path.sep+tempname+".tif")
				n=WindowManager.getImageCount()
				tempid=WindowManager.getNthImageID(n)
				tempimg=WindowManager.getImage(tempid)
				tempimg.show()
				#self.__dictImages[tempname]=tempimg
				nameimages.append(tempname)
				#if zerotimes/len(rawtimes) > 0.5 : rawtimes=range(len(listfiles[i]))
				
				#self.__dictTimeStack[tempname]=rawtimes
				rawtimes=[] 
				rawtimes.append(0)
								
		
		else : 
			nameimages=[]
			print "ERROR IN BUILDSTACK"

		return nameimages
开发者ID:leec13,项目名称:MorphoBactPy,代码行数:72,代码来源:MeasuresCells_.py

示例6: erase

# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImageCount [as 别名]
def erase():
    i = WindowManager.getImageCount()
    while i > 0:
        WindowManager.getImage(WindowManager.getNthImageID(i)).close()
        i = i - 1
开发者ID:Mverp,项目名称:fiji,代码行数:7,代码来源:chess_.py

示例7: dialog

# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImageCount [as 别名]
    def dialog(self):
        """
        Open the classifier dialog window and return the paramters
        chosen.
        """

        # determine how many images are currently open
        image_count = WindowManager.getImageCount()
        image_titles = list(WindowManager.getImageTitles())
        image_titles.append("None")

        # now open a dialog to let the user set options
        path_listener = SetPathListener(self.path)
        path_button = TrimmedButton("Output directory",0)
        path_button.addActionListener(path_listener)

        dlg = GenericDialog("Create classifier data (v"+__version__+")")
        dlg.addMessage("Session ID: "+ str(self.session_id))
        dlg.addMessage("")
        dlg.addMessage("Select the ROI you want to save")
        dlg.addNumericField("Window size (pixels): ", self.window_size, 0)
        dlg.addChoice("Class label: ", DEFAULT_CLASSES+['Other...'], DEFAULT_CLASSES[0])
        dlg.addStringField("Class label (if other): ", "")
        dlg.addChoice("Image file #1 (BF):",image_titles,"None")
        dlg.addChoice("Image file #2 (GFP):",image_titles,"None")
        dlg.addChoice("Image file #3 (RFP):",image_titles,"None")
        dlg.addChoice("Mask file:",image_titles,"None")
        dlg.addCheckbox("Rename ROIs", True)
        dlg.addCheckbox("Exclude edges", True)
        dlg.addCheckbox("Save ROI zip", True)
        dlg.addCheckbox("Save classifier details", True)
        dlg.add(path_button)
        dlg.showDialog()

        # handle the cancelled dialog box
        if dlg.wasCanceled():
            return None


        label_option = dlg.getNextChoice()
        if label_option == 'Other...':
            label = dlg.getNextString()
        else:
            label = label_option



        # get the root path from the path listener
        root_path = path_listener.path

        if not os.path.isdir(root_path):
            w_dlg = GenericDialog("Warning")
            w_dlg.addMessage("Root path does not exist!!")
            w_dlg.showDialog()
            return None

        # try to make the directory for the label if it does not exist
        label_path = os.path.join(root_path, label)
        check_and_makedir(label_path)

		# get the options
        dialog_options = {'window_size': dlg.getNextNumber(),
                            'label': label,
                            'BF': dlg.getNextChoice(),
                            'GFP': dlg.getNextChoice(),
                            'RFP': dlg.getNextChoice(),
                            'mask': dlg.getNextChoice(),
                            'rename': dlg.getNextBoolean(),
                            'edges': dlg.getNextBoolean(),
                            'zip': dlg.getNextBoolean(),
                            'save': dlg.getNextBoolean(),
                            'path': label_path}

        # check that we actually selected an image file
        if all([dialog_options[d] == "None" for d in ['BF','GFP','RFP']]):
            w_dlg = GenericDialog("Warning")
            w_dlg.addMessage("You must select an image stream.")
            w_dlg.showDialog()
            return None

        # grab the contents and return these as a dictionary
        return dialog_options
开发者ID:quantumjot,项目名称:impy-tools,代码行数:84,代码来源:IJClassifier_.py


注:本文中的ij.WindowManager.getImageCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。