When using ImageJ for focus stacking with MacBookPro Sierra OS, I get as far as my 12 stacking photos in sequence appearing on my computer screen over and over again, seemingly ad infinitum. How do I arrive at the finished product, i.e., all 12 photos blended together and saved? Please answer in plain English, I’m far from being a computer geek.
Welcome to the forum. Could you be a bit more specific about the details? Do you have a single recording of a Z-stack? Or do you have 12 images as separate files in a folder? How do you open the images? What do you mean with ‘blended together’? Do you want to combine parts of various images of the stack and combine them into one image infocus? Did you already find and start to use focus stacking and is this what causes the appearance?
I’ve got two folders of images I’ve been working on, one with 12 images of a crustacean, each image with slightly differing microscope focus adjustments, and another folder of 4 images of alga under the same conditions. All are aligned. I’ve tried to make ImageJ focus stack these images into one image for each folder with negative results. I open the images using the import button. Blended together means focus stacking all the images within each folder into one image. I seem to get as far as a screen image of say the alga. When I hit the play button at the bottom of the screen image, all four alga images pass in review horizontally ad infinitum. When I hit the pause button at 4/4, i.e., the 4th photo of the folder of 4 images - what do I do next in order to achieve one combined image? So far I haven’t been able to figure out how to combine the same images of varying focuses within a folder into one focused image.
You import the image sequence and thus create a stack, if I understand you correctly. This stack can be regarded a film strip, and pressing the play button will show all images in succession, in an endless loop. Pressing the (now pause) button will stop the film. > and < keys on the keyboard forward and revers one frame.
A stack can also be seen as a bunch of images on top of one another, each representing a Z-plane, or an image taken at a certain focal height with limited depth of field. You want to single out the focused part of each Z-plane, disregarding the rest and of all z-planes combine the sharpest areas into one single image.
Technically, you want to grab the image area with the highest local change. Out of focus images look blurred, all neighbouring picture elements all more or less have the same value. Sharp images have high contrast, neighbouring pixels can have wildly fluctuating values.
As you want separate areas of all stack images to be combined into one image with extended depth of field, you best use readily available software. The plugin I linked to above seems to be exactly that, as inferred from its description. It calculates per image (stack slice) groups of pixels that are sharp and then combines from each slice the sharpest areas to get the complete focused image.
If you need more help on the plugin, you best post the four sample images of the algae to allow us to follow your steps when you try out the afore mentioned plugin.
Thanks for your help. Someone should make a basic step by step tutorial simply showing how Imagej is used to stack 3-4 images and then combine them into one completely focused image. It can’t be that hard. For instance, In find it easy to use CombineZP with Wndows10. Unfortunately CombineZP doesn’t run on a Mac.
And in ImageJ image is the tool for processing. And plugins, macros and other code are written to ease the job. Use what is available, ask for help if your efforts get you stuck. What you consider ‘basic’ may be ‘geek’ for others.
If you think PC software can help you, there are Windos emulators for mac. Some require Windos licenses, others imitate that layer too. Most of them require some or more geek level.
Count your blessings we’re here to help.
Managed to use Z Project to arrive at an image which was disappointing as far as all parts of the image being in focus. Also tried 3D, but received some kind of a “can’t do” message before the conclusion. I’ll keep playing with ImageJ, and perhaps I’ll stumble over some thing that works. Thanks again for your help. Mike
Just projecting the stack won’t give you a sharp image.
Why did you not try the plugin? It is not that difficult, not even for a non-geek:
Download the Stack Focuser .class. This is as simple as pressing the link above, which shows you the link Stack_Focuser_.class, clicking the link will bring the class file to your Downloads folder. Now you need to move the class file to the ImageJ Plugins folder.
You find the ImageJ Plugins folder if, when ImageJ is running, you right-click ImageJ in your Dock, then do ‘Options > Show in Finder’. A Finder window opens where ImageJ is located and thatx should contain at least three folders: plugins and macros. Drag and drop the stack_focuser_.class in that plugins folder, quit ImageJ and start ImageJ again.
Now you have an extra command in the Plugins menu, Stack Focuser.
Load your stack, choose the StackFocuser command, tick the boxes of the dialog box that opens and have 11 for n. Then press OK That will generate you a nice focused image and a height map to go with it. If you are not satisfied with the result, play with n; try e.g. n=3.
Well that was a complete flop. Went to your link and tried to download. Message was something like “no opening download from unapproved developer”. Then went to privacy settings and said to open anyway. Safari still refused to open the file. So far can’t get Safari to open any Java file other than the original ImageJ. For example, Safari won’t open any JAR files. Went online to see how to work around Safari. None of them helped. Even downloaded Java’s Development Kit after which I couldn’t find it on the computer. The JDK wasn’t in Applications, and couldn’t locate it with Finder, even though Java claimed it was installed. I’ve had it. Completely frustrated. I thank you for all your help and your time. Mike
Well, at least we have some objective complaints to work on.
Let’s take it step by step to get you where you want to be.
Since you are a self-declared non-geek, we’ll take small steps.
As we take small steps, it might take a bit longer and will give less frustration.
Let’s first make sure you have the class file on your computer.
Downloading a file should be possible regardless of your privacy settings, which is what causes the complaint of the unapproved developer.
You say you tried to download; did you just click the link to the class file in this page?
If so, Safari should have started the download. Safari then gives an extra button at the top-right of the window, with a dark circle and an arrow pointing down. If you click that button, a line appears with the name of the downloaded file and a magnifying glass.
Pressing the magnifying glass will reveal the file.
If that button is not present, or there is no class file mentioned, try to use the right mouse button or hold the CTRL key while pressing the link, and from the menu that pops up, choose ‘Download Linked File’, which should get you that class file.
Maybe you have a new version of Safari that I don’t know yet, and that version of Safari refuses to download class files. If so, please let me know what version of Safari (in the Safari menu, choose ‘About Safari’ you have, and see what version of MacOS you have (under the Apple menu: about this Mac). Then we can work on the privacy settings, otherwise we’ll continue to get ImageJ to accept the plugin.
Oh, and it takes a little effort, but writing down (in the current conversation) the exact error message is very helpful, so please take this effort.
Safari downloads fine, but won’t OPEN the file, regardless what I do with my privacy settings. Also tried a different browser, Firefox, and same thing happened. I only have two options: 1. Open only App Store files 2. Open only App Store and Identified Developer files. There are no other options for opening files. I have my privacy settings set for the latter, but computer won’t open any JAR files. I’m using a MaBookPro Retina laptop running on Mac OS Sierra Version 10.12.6 and Safari 12.1.2 (12607.3.10). Here are the error messages I’ve been getting:
Good Evening (GMT+1) @Mike8,
Very well, you have downloaded the file. You don’t have to open it, you just need to land it in the proper place, from where ImageJ, without notifying you, will incorporate it in its list of available (plugin) commands.
Thanks for all the other info you gave, it might be needed later. At least for the system, we are on the same page. As the first screen shot indicates, somehow you have the file available (‘Safari DOWNLOADED the file blabla’) and somehow you tried to open it, which is not necessary. Let’s locate the file and let’s locate the place where it needs to go. Start with the latter:
As you know, when an application is running, its icon is in the Dock, with a black bullet in front of it. Press and hold the ctrl key on your keyboard, press and hold the mouse pointer on the ImageJ icon in the Dock. A menu will pop open. Choose Options and from there, choose Show in Finder. A Finder window opens which shows the contents of the folder ImageJ is located in. Other items in that folder are the folders ‘plugins’, ‘macros’ and luts; possibly a few more items. Double-click the plugins folder you see. This is where you are going to drop the class file in the next step.
Now open the location where you downloaded the class file (most likely in the Downloads folder in your home folder). Drag the file Stack_Focuser_.class from the Downloads folder and drop it into the plugins folder [window]. This was how you just “installed” the plugin. Should you get complaints about not being allowed to drag and drop, I’d like to hear. From here, lets see how far you can follow the next steps:
Quit ImageJ. Wait till the black dot has disappeared from the Dock, then launch ImageJ again.
Now go to the ImageJ Help menu. The first item is Search, with a text box. Type into the text box the four letters ‘stac’ and wait a moment. Menu items should appear under the text box, each containing the letters stac, and one of them being Stack Focuser. Hover your mouse over that word. While hovering, ImageJ will show you where you can find the wanted item: a menu should drop down from the Plugins menu, indicating where the Stack Focuser plugin command is located. If the command is not found or shown, let me know. Let go of the mouse and key.
Import or load your four images into an image stack. Go to Help again, the search term
should still be there. Just click the Stack Focuser from the Help menu. The stack Focuser dialog should now open. If it doesn’t, let me know.
“Show in Finder” didn’t work as expected. The computer simply went to the Applications Folder where ImageJ microscope resides. Used the Finder command “Find ImageJ” which resulted an image of ImageJ microscope and the Stack_Focuser_Class file. When I tried to move the aforementioned stack file into the ImageJ Plugin Window at the top of the screen, the Plugin Window disappeared. Repeated attempts had the same results. Tried to find an ImageJ Plugin Folder, again using Finder, with negative results. Went ahead anyway to ImageJ Help Menu, typed in “stac” , resulting in a list of “stac” words, but Stack Focuser was not among them. The problem might be your instruction “drop it into the plugins folder [window]”. I’m not sure that the ImageJ plugin window at the top of the screen is the one you meant, but I could find nothing else that fit the bill. Attached is ImageJ menu as it appears on my computer with the plugin window open. Thanks for all you’re doing. I learning a lot as we go along. Mike
Ah, here I am the cause of the confusion. I’ve been moving these folders around in my mac, as I need various versions of ImageJ and they are hanging around on my hard disk, each in their own folder, with their own set of plugins. Let’s see, ImageJ is in your Applications folder. So you can locate it and you have also seen how to find commands in ImageJ and display in which menu they reside. That’s good.
Applications in MacOS are actually a whole bundle of files and folders packed together in a special type of folder, which looks like a single item. To prevent users from moving them from the place the actual application (a file the computer can execute, an executable) expects them to be, Apple has hidden everything inside the bundle, wrapped it, stuck an icon on it and ‘sealed’ it with a special bit. That also means Finder, in order not to confuse users, won’t show items that are inside the bundle. So if you search for ImageJ’s plugins folder and it resides within the bundle, you won’t see it as you will only see top folders of packages. I expect the plugins folder to be inside the ImageJ package, so let’s have a look.
Go to ImageJ in the Applications folder, press the CTRL key on the keyboard, press and hold the mouse pointer on ImageJ and a menu appears. Choose ‘Show Package Contents’. A folder should open up, with various things inside, one of them being plugins. If that is correct, you can move up in this discussion and follow the steps we already discussed, from ‘drop into plugins’. Let us know what your results are.
If there is no plugins folder inside the package, we’ll be using a nifty utility FAF (Find Any File) by Olaf Tempelmann, which can find, based on various criteria, any file, anywhere on your hard disk, even ones hidden in bundles or invisible files. But maybe we don’t need it here.
Path randomization…caught me. Good you posted your system version.
According to this page this is the case with MacOS 10.12:
macOS 10.12 (Sierra) introduced a security feature called Path Randomization that can cause ImageJ to not work as expected. Path randomization is in effect if the “ImageJ home” path shown in the Image>Show Info window starts with “/private” and plugins are not installed in the Plugins menu. You can disable path randomization by dragging ImageJ.app to another folder and then (optionally) dragging it back.
So drag ImageJ out of the Applications folder to, e.g. a folder you make on your desktop or anywhere else convenient. Quit ImageJ before and launch it after you have moved it. Can you look for a Plugins folder now? Either in the same folder you put ImageJ (on the desktop) or in the Package of ImageJ. I suspect the former.
Moved ImageJ from Applications Folder to a folder I labeled IJ on Desktop. Upon clicking on the Microscope image in IJ folder while holding down the control key, I got the same contents as before. No plugin folder or file.
Quit ImageJ. Let’s try to make a new folder on the desktop: click on the desktop with the CTRL key pressed and choose New Folder from the popup or, in Finder, navigate to the Desktop, do File>New Folder, name it (“ImageJ 1.52t” can be the name; but anything works). Drop ImageJ in it.
Within the folder you just created, also create a folder Plugins in the same way, so it sits next to ImageJ.
Launch ImageJ. From the Plugins menu, choose ‘Install…’. In the dialog that opens, navigate to the downloaded plugin class file (you know where it is, probably in your Downloads folder), select the class file and a new dialog opens. It is suggesting a location (with me, it opens the folder ‘plugins’ of the folder where I put ImageJ).
There are a few dialog window parts: the top one says Save As:, the next is Tags:, the one straight down is a popup menu with a folder icon, a folder name (Plugins?) and a up and down caret. If you click and hold this popup, you see the hierarchy of folders where the suggested folder resides. I gather the list from top to bottom is -plugins-Desktop--Users-Macintosh HD-.
If the suggested folder is not the Plugins folder within the ImageJ folder on your desktop, navigate to the folder Plugins you just created; you can use the popup dialog to move up in the folder tree, or double-click folders in the lower part of the dialog window to drill down.
Now you know where the plugins folder is for future reference. (you can take a screenshot by clicking the popup briefly, then, after the popup unfolds, press cmd-shift-4, then with the mouse drag a rectangle around the interesting area and a “Screen shot .png” file will land on your desktop).
Once the location shown in the popup bar is the Plugins folder in the ImageJ folder on your Desktop, press Save. At this moment, the Stack Focuser command should be available from the Plugins menu. Quit and launch ImageJ and check the available Plugins menu or use the Help function to see if you now have the plugin command available permanently.
When I hit “install” the computer simply listed all the files on Desktop, including the ImageJ Folder. Just upgraded to the newest OS I could get for my Mac, Catalina (v10.15.3), hoping that would make a difference. It didn’t.