本文整理汇总了Python中ij.WindowManager类的典型用法代码示例。如果您正苦于以下问题:Python WindowManager类的具体用法?Python WindowManager怎么用?Python WindowManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WindowManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: select_images
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_images
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]
示例3: get_image_titles
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
示例4: close
def close(self):
if self.olay != None:
yncd = YesNoCancelDialog(self.frame, "Save overlay?", "Save overlay?") #frame, title, message
if yncd.yesPressed():
self.saveOverlay()
WindowManager.removeWindow(self.frame)
self.frame.dispose()
示例5: __init__
def __init__(self, p):
self.cellCounter = 1
self.olay = Overlay()
self.position = p
print p.getRoiPath()
if p.getRoiPath() != None: # check if there is an existing overlay file and load it!
p.loadRois()
self.frame = JFrame("CellCropper", size=(200,200))
self.frame.setLocation(20,120)
self.Panel = JPanel(GridLayout(0,1))
self.frame.add(self.Panel)
#self.nameField = JTextField("p" + "_c",15)
self.nameField = JTextField("p" + str(self.position.getID()) + "_c",15)
self.Panel.add(self.nameField)
self.cutoutButton = JButton("Cut out cell",actionPerformed=cut)
self.Panel.add(self.cutoutButton)
self.delOlButton = JButton("Delete Overlay",actionPerformed=delOverlay)
self.Panel.add(self.delOlButton)
self.saveOlButton = JButton("Save Overlay",actionPerformed=saveOverlay)
self.Panel.add(self.saveOlButton)
self.quitButton = JButton("Quit script",actionPerformed=quit)
self.Panel.add(self.quitButton)
self.frame.pack()
WindowManager.addWindow(self.frame)
self.show()
示例6: get_setup
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
示例7: getImage
def getImage():
"""Get first open image or open Bio-Formats importer if no image is
available."""
imp = WindowManager.getCurrentImage()
if not imp:
# Show bio formats open dialog
IJ.run("Bio-Formats")
imp = WindowManager.getCurrentImage()
print("Start")
if not imp:
IJ.noImage()
raise ValueError("Need image")
return imp
示例8: draw_roi_on_full_res_tile
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
示例9: __init__
def __init__(self):
self.mainDir = ""
self.frame = JFrame("Dots Quality Check", size=(250,300))
self.frame.setLocation(20,120)
self.Panel = JPanel(GridLayout(0,1))
self.frame.add(self.Panel)
self.openNextButton = JButton('Open Next Random',actionPerformed=openRandom)
self.Panel.add(self.openNextButton)
self.saveButton = JButton('Save',actionPerformed=save)
self.saveButton.setEnabled(False)
self.Panel.add(self.saveButton)
self.cropButton = JButton('Crop values from here', actionPerformed=cropVals)
self.Panel.add(self.cropButton)
self.DiscardButton = JButton('Discard cell', actionPerformed=discardCell)
self.DiscardButton.setEnabled(True)
self.Panel.add(self.DiscardButton)
self.quitButton = JButton('Quit script',actionPerformed=quit)
self.Panel.add(self.quitButton)
annoPanel = JPanel()
#add gridlayout
wtRButton = JRadioButton("wt", actionCommand="wt")
defectRButton = JRadioButton("Defect", actionCommand="defect")
annoPanel.add(wtRButton)
annoPanel.add(defectRButton)
self.aButtonGroup = ButtonGroup()
self.aButtonGroup.add(wtRButton)
self.aButtonGroup.add(defectRButton)
self.Panel.add(annoPanel)
self.ProgBar = JProgressBar()
self.ProgBar.setStringPainted(True)
self.ProgBar.setValue(0)
self.Panel.add(self.ProgBar)
self.pathLabel = JLabel("-- No main directory chosen --")
self.pathLabel.setHorizontalAlignment( SwingConstants.CENTER )
self.Panel.add(self.pathLabel)
WindowManager.addWindow(self.frame)
self.show()
示例10: bSaveZProject
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()
示例11: myrun
def myrun(self):
imp = IJ.openImage(self.path) #open imp
if imp is None:
print 'ERROR opening file:', self.path
return 0
numSlices = imp.getNSlices()
if numSlices<2:
return 0
middleSlice = int(math.floor(imp.getNSlices() / 2)) #int() is necc., python is fucking picky
imp.show()
imp.setSlice(middleSlice)
impTitle = imp.getTitle()
impWin = WindowManager.getWindow(impTitle) #returns java.awt.Window
transformationFile = os.path.basename(self.path)
transformationFile = os.path.splitext(transformationFile)[0] + '.txt'
transformationFile = '/Users/cudmore/Desktop/out/' + transformationFile
stackRegParams = 'stack_1=[%s] action_1=Align file_1=[%s] stack_2=None action_2=Ignore file_2=[] transformation=[Rigid Body] save' %(impWin,transformationFile)
IJ.run('MultiStackReg', stackRegParams)
imp.close()
'''
#20150723, we just aligned on a cropped copy, apply alignment to original imp
origImpTitle = imp.getTitle()
stackRegParams = 'stack_1=[%s] action_1=[Load Transformation File] file_1=[%s] stack_2=None action_2=Ignore file_2=[] transformation=[Rigid Body]' %(origImpTitle,transformationFile)
IJ.run('MultiStackReg', stackRegParams)
'''
'''
示例12: runPoreDetection
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)
示例13: main
def main():
"""Get options and create new image."""
options = get_options()
if options is not None:
bwidth, bheight = options
img_cur = WindowManager.getCurrentImage()
img_new = boxed_intensities(img_cur, bwidth, bheight)
img_new.show()
示例14: __init__
def __init__(self):
self.mainDir = ""
self.setTitle("Dots Quality Check")
self.setSize(250, 300)
self.setLocation(20,120)
self.addWindowFocusListener(self)
self.Panel = JPanel(GridLayout(0,1))
self.add(self.Panel)
self.openNextButton = JButton("Open Next Random", actionPerformed=self.openRandom)
self.Panel.add(self.openNextButton)
self.saveButton = JButton("Save", actionPerformed=self.save, enabled=False)
self.Panel.add(self.saveButton)
self.cropButton = JButton("Crop values from here", actionPerformed=self.cropVals)
self.Panel.add(self.cropButton)
self.DiscardButton = JButton("Discard cell", actionPerformed=self.discardCell)
self.Panel.add(self.DiscardButton)
self.quitButton = JButton("Quit script",actionPerformed=self.quit)
self.Panel.add(self.quitButton)
annoPanel = JPanel()
#add gridlayout
self.wtRButton = JRadioButton("wt", actionCommand="wt")
self.wtRButton.addActionListener(self)
self.defectRButton = JRadioButton("Defect", actionCommand="defect")
self.defectRButton.addActionListener(self)
annoPanel.add(self.wtRButton)
annoPanel.add(self.defectRButton)
self.aButtonGroup = ButtonGroup()
self.aButtonGroup.add(self.wtRButton)
self.aButtonGroup.add(self.defectRButton)
self.Panel.add(annoPanel)
self.ProgBar = JProgressBar()
self.ProgBar.setStringPainted(True)
self.ProgBar.setValue(0)
self.Panel.add(self.ProgBar)
self.pathLabel = JLabel("-- No main directory chosen --")
self.pathLabel.setHorizontalAlignment( SwingConstants.CENTER )
self.Panel.add(self.pathLabel)
WindowManager.addWindow(self)
self.show()
示例15: Resize
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