Is live FFT of an ROI on screen possible?


Is it possible to do the following in ImageJ / Fiji:

  1. Select an ROI on the PC monitor
  2. Display live FFT of the selected image region.
    (may be slow: an update every few seconds is ok)


Upgrade to the latest ImageJ daily build (1.52s13) and you will be able to do this.

  1. Check “Reuse ‘FFT of…’ window” in the Process>FFT>FFT Options dialog.
  2. Create a rectangular ROI. Power of 2 square ROIs (128x128, 256x256, etc.) will faster. Create a square ROI by holding shift key down.
  3. Use the Process>FFT>FFT command.
  4. Move the ROI while holding down the ‘r’ key.

The ‘r’ key is the new keyboard shortcut for the Process>Repeat Command command. Shift-r is now the shortcut the File>Revert command.


Yess, that works amazingly well !
Thank you so much.

Is there also a way to draw an ROI outside of the Fiji image, on any screen location ?
Or i.o.w. can I ‘livestream’ an ROI on the screen into Fiji ?

As a background info:
I want to adjust TEM and SEM microscopes for optimal focus and stigmation via FFT.
Unfortunately the software from the supplier doesn’t always have DM or anything else with FFT in it, so I 'd like to use Fiji for this.


1 Like

You can only create ROIs in image windows so you need to capture the screen by pressing shift-g (Plugins>Utilities>Capture Screen).

Hi @Cobalt !

I just realized that the application that you are looking for is quite similar to the core idea of a set of macros that I had written a few years ago to process a live feed from the screen. I just refactored the code to make it work for your case:

 *  Acquire a live FFT from a screen region
 *  Nicolás De Francesco, Nov 2019 - user: @NicoDF
 *  Use:  - install the macro set
 *        - F1 key: setup the location of the screen from which the FFT is calcultated FFT.
 *        - F2 key: start/stop the live FFT feed. It will stop if the window is closed.
 *        - F5 key: modifiy the FFT refresh rate.
 *  The macro will remember the location of the live window if it is closed.

var bx=50; // default acqusition window parameters
var by=50;
var bw=256;
var bh=256;

var time_step=200; // milliseconds

var FFT_name="Live FFT";

var FFT_x=820;
var FFT_y=450;
var FFT_w=256;
var FFT_h=256;

var FFT_running=false;

macro "Select target area [F1]" {
	run("Capture Screen");
	waitForUser("Select capture area");
	if (isOpen("Screenshot")) {
	if (isOpen(FFT_name)) {
		run("Capture single FFT");

macro "Start/stop Live FFT [F2]" {
	FFT_running = !FFT_running;
	while (FFT_running)	{	
		run("Capture single FFT");
		setOption("Changes", false); // allows closing without prompt
		showStatus("LIVE FFT");
		if(!isOpen(FFT_name)) FFT_running=false;
	showStatus("FFT STOPPED");	

macro "Set time step [F5]"{
	// setup
	Dialog.create("Capture Settings");
	Dialog.addNumber("Time Step (ms)", time_step);;

macro "Capture single FFT" {
	run("Capture Screen");
   	close(); //close temp FFT
   	close(); //close screenshot

   	if (isOpen(FFT_name)) { 
		getLocationAndSize(FFT_x, FFT_y, temp_w, temp_h);
   	else {
   		newImage(FFT_name, "8-bit black", FFT_w, FFT_h, 1);
	run("Select None");
	setBatchMode("exit and display");
	setLocation(FFT_x, FFT_y);

In this particular case, I didn’t need to use the (awesome!) new feature implemented by @Wayne.

Let me know if it works for you.



Hi Nico,

Fully tested and approved:
these macros do exactly what I had in mind.

1000x thanks !