def initUI(self): """ Finished Dialog box Simple dialog box that says "Finished", to bw displayed when all image analysis has finished. When OK button is pressed all ImageJ windows are closed. """ panel = JPanel() self.getContentPane().add(panel) panel.setBackground(Color.WHITE) panel.setLayout(None) self.setTitle("Analysis has finished") self.setSize(300, 150) OKbutton = JButton("OK", actionPerformed=self.onOK) OKbutton.setBackground(Color.BLACK) OKbutton.setBounds(80, 50, 100, 30) panel.add(OKbutton) Title = JTextArea("Analysis has finised!! :-)") Title.setBounds(15, 10, 250, 20) panel.add(Title) self.setLocationRelativeTo(None) self.setLocation(int(IJ.getScreenSize().width * 0.01), int(IJ.getScreenSize().height * 3 / 10)) self.setVisible(True)
def green2(): """ Displays a duplicate of the active image. """ green2 = IJ.getImage() green2 = green2.duplicate() ImageWindow.setNextLocation(int(IJ.getScreenSize().width * 1 / 3), int(IJ.getScreenSize().height * 1 / 14)) green2.show()
def subpixels(pixel): """ Math: subtraction duplicates and displayes current image. Performs puxel subtraction using Math. """ green = IJ.getImage() green = green.duplicate() IJ.run(green, "Subtract...", "value=" + pixel) ImageWindow.setNextLocation(int(IJ.getScreenSize().width * 1 / 3), int(IJ.getScreenSize().height * 1 / 14)) green.show() bgTitle()
def run(title): gd = GenericDialog('Record Desktop') gd.addNumericField('Max. frames:', 50, 0) gd.addNumericField('Milisecond interval:', 300, 0) gd.addSlider('Start in (seconds):', 0, 20, 5) gd.showDialog() if gd.wasCanceled(): return n_frames = int(gd.getNextNumber()) interval = gd.getNextNumber() / 1000.0 # in seconds delay = int(gd.getNextNumber()) snaps = [] try: while delay > 0: IJ.showStatus('Starting in ' + str(delay) + 's.') time.sleep(1) # one second delay -= 1 IJ.showStatus('') System.out.println("Starting...") # start capturing robot = Robot() box = Rectangle(IJ.getScreenSize()) start = System.currentTimeMillis() / 1000.0 # in seconds last = start intervals = [] real_interval = 0 # Initial shot snaps.append(robot.createScreenCapture(box)) while len(snaps) < n_frames and last - start < n_frames * interval: now = System.currentTimeMillis() / 1000.0 # in seconds real_interval = now - last if real_interval >= interval: last = now snaps.append(robot.createScreenCapture(box)) intervals.append(real_interval) else: time.sleep(interval / 5) # time in seconds # Create stack System.out.println("End") awt = snaps[0] stack = ImageStack(awt.getWidth(None), awt.getHeight(None), None) t = 0 for snap, real_interval in zip(snaps, intervals): stack.addSlice(str(IJ.d2s(t, 3)), ImagePlus('', snap).getProcessor()) snap.flush() t += real_interval ImagePlus("Desktop recording", stack).show() except Exception, e: print "Some error ocurred:" print e for snap in snaps: snap.flush()
def run(title): gd = GenericDialog("Record Desktop") gd.addNumericField("Max. frames:", 50, 0) gd.addNumericField("Milisecond interval:", 300, 0) gd.addSlider("Start in (seconds):", 0, 20, 5) gd.showDialog() if gd.wasCanceled(): return n_frames = int(gd.getNextNumber()) interval = gd.getNextNumber() / 1000.0 # in seconds delay = int(gd.getNextNumber()) snaps = [] try: while delay > 0: IJ.showStatus("Starting in " + str(delay) + "s.") time.sleep(1) # one second delay -= 1 IJ.showStatus("") System.out.println("Starting...") # start capturing robot = Robot() box = Rectangle(IJ.getScreenSize()) start = System.currentTimeMillis() / 1000.0 # in seconds last = start intervals = [] real_interval = 0 # Initial shot snaps.append(robot.createScreenCapture(box)) while len(snaps) < n_frames and last - start < n_frames * interval: now = System.currentTimeMillis() / 1000.0 # in seconds real_interval = now - last if real_interval >= interval: last = now snaps.append(robot.createScreenCapture(box)) intervals.append(real_interval) else: time.sleep(interval / 5) # time in seconds # Create stack System.out.println("End") awt = snaps[0] stack = ImageStack(awt.getWidth(None), awt.getHeight(None), None) t = 0 for snap, real_interval in zip(snaps, intervals): stack.addSlice(str(IJ.d2s(t, 3)), ImagePlus("", snap).getProcessor()) snap.flush() t += real_interval ImagePlus("Desktop recording", stack).show() except Exception, e: print "Some error ocurred:" print e for snap in snaps: snap.flush()
def printLog(text, indent): msgStr = '' for i in (range(indent)): msgStr += ' ' print msgStr,text #to command line IJ.log(msgStr + text) if __name__ == '__main__': printLog("===========================================================",0) printLog(" ********rep_stack_V7:"+time.strftime("%c")+" ***********",0) try: imp = IJ.getImage() #for opened image except: printLog("No image found, please select one",0) imp = openFile() #prompt user to open an image if imp: #auto set the zoom of montaged image global mZoom screen = IJ.getScreenSize() screenWidth = screen.width impSize = imp.width printLog("screenWidth is:" + str(screenWidth)+", image size is:" + str(impSize),0) mZoom = 100*screenWidth*1024/(2560*impSize) #100 for 1560 width screen when image is 1024X1024 printLog("mZoom is: " + str(mZoom),0) selectBest(imp) printLog(" ********Finished on "+time.strftime("%X")+" ***********",0) printLog("===========================================================",0)