本文整理汇总了Python中ij.WindowManager.getImage方法的典型用法代码示例。如果您正苦于以下问题:Python WindowManager.getImage方法的具体用法?Python WindowManager.getImage怎么用?Python WindowManager.getImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ij.WindowManager
的用法示例。
在下文中一共展示了WindowManager.getImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: select_images
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [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)
示例2: get_setup
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [as 别名]
def get_setup():
''' Returns the drift correction mode and three image.
The order of return values is drift detection mode, pre-edge 1, pre-edge 2, post-edge.
'''
options = drift.get_options()
modes = drift.get_modes()
dialog = GenericDialog('3-window-method setup')
dialog.addMessage('Select the mode for drift correction\n' +
'and the images to process.')
dialog.addChoice('Mode:', options, options[0])
image_ids = WindowManager.getIDList()
if not image_ids or len(image_ids) < 2:
return [None]*4
image_titles = [WindowManager.getImage(id).getTitle() for id in image_ids]
dialog.addMessage('Post-edge is divided by the pre-edge.')
dialog.addChoice('Pre-edge 1', image_titles, image_titles[0])
dialog.addChoice('Pre-edge 2', image_titles, image_titles[1])
dialog.addChoice('Post-edge', image_titles, image_titles[2])
dialog.showDialog()
if dialog.wasCanceled():
return [None]*4
mode = modes[dialog.getNextChoiceIndex()]
img1 = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
img2 = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
img3 = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
return mode, img1, img2, img3
示例3: get_images
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [as 别名]
def get_images(minimum=0, maximum=None, exact=None):
''' Returns a list of ImagePlus objects or None if it failed.
Passing None as parameter will trigger a dialog to show up to enter the exact number of images.
:param minimum: The minimum number of images to select (default: 0).
:param maximum: The maximum number of images to select (default: None).
:param exact: Set this to get an exact number of images (default: None).
'''
if not (minimum or maximum or exact):
exact = int(IJ.getNumber("How many images do you want to process?", 3))
def check_count(count):
'''Returns True if the count of images is as required.'''
# print count, exact, minimum, maximum
if exact:
if not count == exact:
return False
else:
if minimum:
if count < minimum:
return False
if maximum:
if count > maximum:
return False
return True
# Option 1: The selected image is a stack and has the demanded size.
if check_count(WindowManager.getCurrentImage().getStackSize()):
return stack_to_list_of_imp(WindowManager.getCurrentImage())
# Option 2: The count of open images matches the demanded number.
image_ids = WindowManager.getIDList()
if exact:
if len(image_ids) < exact:
return None
if len(image_ids) == exact:
return [WindowManager.getImage(img_id) for img_id in image_ids]
# Option 3: The user can select the images from a list.
image_titles = [WindowManager.getImage(id).getTitle() for id in image_ids]
img_count = len(image_ids)
if exact:
img_count = exact
elif maximum:
img_count = maximum
image_titles.append('None')
images_selected = dialogs.create_selection_dialog(image_titles,
range(img_count),
'Select images for drift correction'
)
# dialogs.create_selection_dialog() returns None if canceled
if not images_selected:
return None
# This is only true if 'None has been appended to image_titles and the user selected it.
if len(image_ids) in images_selected:
images_selected.remove(len(image_ids))
if not check_count(len(images_selected)):
return None
image_list = [WindowManager.getImage(image_ids[selection]) for selection in images_selected]
return image_list
示例4: draw_roi_on_full_res_tile
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [as 别名]
def draw_roi_on_full_res_tile(containing_tiles_dict,subupcoords_dict):
masterXs = []
masterYs = []
for key in containing_tiles_dict.keys():
if (len(containing_tiles_dict.keys())>1):
active_image = WindowManager.getImage("Fused")
else:
active_image = WindowManager.getImage("tile_"+key+".ome.tif")
for point in containing_tiles_dict[key]:
masterXs.append(point[3]+subupcoords_dict["tile_"+str(point[0])][0])
masterYs.append(point[4]+subupcoords_dict["tile_"+str(point[0])][1])
proi = PolygonRoi(masterXs,masterYs,Roi.FREEROI)
active_image.setRoi(proi)
return active_image
示例5: get_images
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [as 别名]
def get_images(ids):
"""
Returns a list of ImagePlus objects.
:param ids: The ids of the ImagePlus objects to return.
"""
image_ids = WindowManager.getIDList()
return [WindowManager.getImage(image_ids[id]) for id in ids]
示例6: get_image_titles
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [as 别名]
def get_image_titles():
"""
Returns the titles of all open image windows as a list.
"""
image_ids = WindowManager.getIDList()
image_titles = [WindowManager.getImage(id).getTitle() for id in image_ids]
return image_titles
示例7: bSaveZProject
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [as 别名]
def bSaveZProject(imp, dstFolder, shortname):
#bring to front
impWinStr = imp.getTitle()
IJ.selectWindow(impWinStr)
bPrintLog('Making Z-Project from ' + impWinStr, 2)
madez = 0
z1 = 1
z2 = imp.getNSlices()
if z2>1:
paramStr = 'start=%s stop=%s projection=[Max Intensity]' % (z1, z2)
IJ.run('Z Project...', paramStr) #makes 'MAX_' window
zWinStr = 'MAX_' + impWinStr
zImp = WindowManager.getImage(zWinStr)
madez = 1
else:
zImp = imp
if dstFolder != None:
dstFile = dstFolder + 'max_' + shortname + '.tif'
bPrintLog('Saving Z-Project: ' + dstFile, 2)
bSaveStack(zImp, dstFile)
if madez:
zImp.changes = 0
zImp.close()
示例8: runPoreDetection
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [as 别名]
def runPoreDetection():
'''roiManager=RoiManager(False)
roiManager.runCommand("open", roiname)
roiHash=roiManager.getROIs()
roi=roiHash.get("Right")
print roi'''
imageList=Utility.GetOpenImageList()
nbgd=NonBlockingGenericDialog(Messages.AddRoi)
nbgd.addMessage(Messages.ChooseImage)
if (imageList==None):
IJ.showMessage(Messages.noOpenImages)
return;
nbgd.addChoice("Image1:", imageList, imageList[0]);
nbgd.showDialog()
name = nbgd.getNextChoice()
inputImp = WindowManager.getImage(name)
inputDataset=Utility.getDatasetByName(data, name)
detectionParameters=DetectionParameters(10, 200, 0.5, 1.0, 0.3)
#inputImp.setRoi(roi)
nbgd2=NonBlockingGenericDialog(Messages.PositionRoi)
nbgd2.addMessage(Messages.PositionRoiAndPressOK)
nbgd2.showDialog()
poreDetectionUV(inputImp, inputDataset, inputImp.getRoi().clone(), ops, data, display, detectionParameters)
示例9: ridge_detect
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [as 别名]
def ridge_detect(imp, rd_max, rd_min, rd_width, rd_length):
title = imp.getTitle()
IJ.run(imp, "8-bit", "");
IJ.run(imp, "Ridge Detection", "line_width=%s high_contrast=%s low_contrast=%s make_binary method_for_overlap_resolution=NONE minimum_line_length=%s maximum=0" % (rd_width, rd_max, rd_min, rd_length))
IJ.run(imp, "Remove Overlay", "")
skel = WindowManager.getImage(title + " Detected segments")
IJ.run(skel, "Skeletonize (2D/3D)", "")
skel.hide()
return(skel)
示例10: Resize
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [as 别名]
def Resize(imp):
gd = GenericDialog("Image size")
scales = ["1024","2048","4096"]
gd.addChoice("Choose image size",scales,scales[1])
gd.showDialog()
scale_choice = gd.getNextChoice()
IJ.run(imp,"Scale...", "x=- y=- z=1.0 width="+scale_choice+" height="+scale_choice+" interpolation=Bilinear average process create title=Scaled")
scaled_imp = WindowManager.getImage("Scaled")
return scaled_imp
示例11: merge_images
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [as 别名]
def merge_images(_imp1, _imp2, force_same_bit_depth):
imp1 = _imp1.duplicate()
imp2 = _imp2.duplicate()
imp1.show(); imp2.show();
if(force_same_bit_depth):
bd = max(imp1.getBitDepth(),imp2.getBitDepth())
if bd==16:
convert_to_16bit(imp1)
convert_to_16bit(imp2)
if bd==32:
convert_to_32bit(imp1)
convert_to_32bit(imp2)
IJ.run(imp1, "Merge Channels...", "c1=[%s] c2=[%s] create" % (imp1.getTitle(), imp2.getTitle()))
imp_out = WindowManager.getImage("Composite")
if not imp_out:
imp_out = WindowManager.getImage("Merged")
imp_out.hide()
imp1.hide(); imp2.hide()
return imp_out
示例12: __selectMeasureStack
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [as 别名]
def __selectMeasureStack(self) :
# We allow the user to choose what to measure in the stack, and on which stack.
gd1=NonBlockingGenericDialog("Stack Choice for measures")
idimages=WindowManager.getIDList()
images=[WindowManager.getImage(imgID) for imgID in idimages if WindowManager.getImage(imgID).getImageStackSize()>1 ]
imagesnames=[img.getTitle() for img in images]
activindex=0
for i in range(len(imagesnames)) :
if imagesnames[i] == self.__activeTitle :
activindex=i
gd1.addChoice("Select a stack in the list : ",imagesnames,imagesnames[activindex])
gd1.showDialog()
chosenstack=gd1.getNextChoice()
self.__img=WindowManager.getImage(chosenstack)
IJ.selectWindow(self.__img.getID())
if gd1.wasOKed() : return True
else : return False
示例13: overlayImages
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [as 别名]
def overlayImages(self, e):
impBase = WindowManager.getImage(self.imageIDs[self.baseImageBox.getSelectedIndex()])
refBase = impBase.getStack().getProcessor(1)
impOverlay = WindowManager.getImage(self.imageIDs[self.overlayImageBox.getSelectedIndex()])
refOverlay = impOverlay.getStack().getProcessor(1)
print "Overlaying for stack sizes " + str(impBase.getStackSize()) + "/" + str(impOverlay.getStackSize()) + "..."
stack = None
if self.virtualStackCheckbox.isSelected():
stack = OverlayVirtualStack()
stack.overlayOpacity = float(self.opacitySpinner.getValue())/100.0
stack.overlayColor = AWTColorToArray(self.overlayColorPreviewLabel.getBackground())
stack.base = impBase
stack.overlay = impOverlay
ImagePlus("Stack Overlay from " + self.imageNames[self.baseImageBox.getSelectedIndex()] + " and " + self.imageNames[self.overlayImageBox.getSelectedIndex()], stack).show()
else:
IJ.error("Not implemented yet", "Using normal stacks is not implemented yet. Please use the Virtual Stack option.")
示例14: run_script
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [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())
示例15: get_setup
# 需要导入模块: from ij import WindowManager [as 别名]
# 或者: from ij.WindowManager import getImage [as 别名]
def get_setup():
'''Returns two ImagePlus objects and a dictionary of properties to copy.'''
dialog = GenericDialog('Copy Properties setup')
dialog.addMessage('Select the source and target image and the properties to copy.')
image_ids = WindowManager.getIDList()
if not image_ids or len(image_ids) < 2:
IJ.showMessage('Two or more images are necessary to use this plugin.')
return [None]*3
image_titles = [WindowManager.getImage(id).getTitle() for id in image_ids]
dialog.addChoice('Source', image_titles, image_titles[0])
dialog.addChoice('Target', image_titles, image_titles[1])
dialog.addCheckbox('Copy Calibration', True)
dialog.addCheckbox('Copy Slice Labels', False)
dialog.showDialog()
if dialog.wasCanceled():
return [None]*3
source = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
target = WindowManager.getImage(image_ids[dialog.getNextChoiceIndex()])
choices = {'cal': dialog.getNextBoolean(),
'labels': dialog.getNextBoolean()
}
return source, target, choices