Home Business & Other Image Processing with ImageJ - Second Edition

Image Processing with ImageJ - Second Edition

books-svg-icon Book
eBook $35.99 $24.99
Print $43.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $35.99 $24.99
Print $43.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
  1. Free Chapter
    Getting Started with ImageJ
About this book
Advances in image processing have been vital for the scientific and technological communities, making it possible to analyze images in greater detail than ever before. But as images become larger and more complex, advanced processing techniques are required. ImageJ is built for the modern challenges of image processing – it’s one of the key tools in its development, letting you automate basic tasks so you can focus on sophisticated, in depth analysis. This book demonstrates how to put ImageJ into practice. It outlines its key features and demonstrates how to create your own image processing applications using macros and ImageJ plugins. Once you’ve got to grips with the basics of ImageJ, you’ll then discover how to build a number of different image processing solutions. From simple tasks to advanced and automated image processing, you’ll gain confidence with this innovative and powerful tool – however and whatever you are using it for.
Publication date:
November 2015
Publisher
Packt
Pages
256
ISBN
9781785889837

 

Chapter 1. Getting Started with ImageJ

Welcome to the second edition of Image Processing with ImageJ. ImageJ is a versatile and open source software package designed for scientific image processing and analysis. It is written in the Java programming language, allowing for a uniform cross-platform experience. It is based on the NIH Image software package on the Macintosh platform, developed in 1987 by Wayne Rasband. Rasband, who is still an active contributor of ImageJ, published the first ImageJ distribution in 1997. It was developed as a project to provide a solution to a problem. In 2012, ImageJ celebrated its twenty-fifth birthday with a publication in the journal Nature Methods.

 

ImageJ distributions


Currently, there are different distributions that are based on or are extensions of the original ImageJ. The basic ImageJ package is available on the ImageJ website at the National Institute of Health (http://imagej.nih.gov/ij/download.html). The current version of the package is version 1.50b, and the website is updated monthly. This is the core distribution of ImageJ, which contains the main interface and all the basic tools to load, view, process, and export images and data. Other distributions contain this core package and most of its features, but you need to add additional features and plugins to create an optimized interface for specific fields. Some of these other distributions are still easily recognizable as ImageJ, while others offer a completely different interface.

For different scientific fields, different distributions were developed based on the core of ImageJ. One of the major distributions for the life sciences is called Fiji (Fiji Is Just ImageJ), which can be found on the Fiji website (http://fiji.sc/Fiji). The basis of Fiji is ImageJ, but it comes with a large complement of preinstalled features (macros and plugins) that are commonly used for image processing in the life sciences. It is focused on fluorescence microscopy, with built-in tools for segmentation, visualization, and co-localization. It also contains plugins for image registration, particle tracking, and super-resolution processing and reconstruction. It also has an extensive library of image formats that can be opened. This library includes proprietary image formats from all the major acquisition software packages via the Bio-Formats plugin, as described in the upcoming section. The advantages of this distribution are the large number of supplied plugins that come with it as well as a very user-friendly script editor. It also has an extensive update mechanism for both ImageJ as well as some plugins.

For the field of astronomy, a different distribution of ImageJ was developed, named AstroImageJ (http://www.astro.louisville.edu/software/astroimagej/). This distribution takes the core implementation of ImageJ and supplements it with specific plugins and macros developed for analysis in the field of astronomy. It is not directly compatible with ImageJ. The core of ImageJ was slightly modified for this distribution.

An example of a distribution derived from ImageJ but with a different user interface is Icy (http://icy.bioimageanalysis.org/). The Icy distribution has integrated ImageJ, and many plugins are compatible. However, not every plugin developed for ImageJ will work within Icy and vice versa. In the Icy distribution, there is a strong emphasis on cellular and spot detection and tracking. There is also a strong emphasis on plugin development. Plugins that are developed for the Icy platform will have documentation and automated updating implemented by design. There are also possibilities for users to directly provide feedback to the developers from within the interface, which is a feature not present within other distributions based on ImageJ. A disadvantage may be that it requires several external libraries to be installed, most importantly VTK, which can cause issues on Linux systems.

Another distribution that uses ImageJ not only for the processing of data but also aids in the acquisition of data is called μManager, which can be found at https://www.micro-manager.org/. It is loaded from within ImageJ as a plugin, but provides a unique interface geared towards image acquisition and hardware control. Camera and microscope drivers allow the control of supported hardware used in image acquisition, which can then be fed directly to ImageJ for processing and analysis. An example of the use of μManager is in the Open SPIM project, where it is used to control a DIY light sheet microscope, acquire images, and process them.

 

The uses of ImageJ


ImageJ is a great tool to process images and perform analysis. It is used in many scientific peer-reviewed publications, with over 1000 articles in diverse fields such as life sciences, astronomy, and physics. In life sciences, it is used to quantify medical images to aid in the detection of pathological markers. It is also used to process and quantify data from single-cell or single-molecule experiments using super-resolution techniques such as STORM and PALM. In physics and engineering, it is used to quantify and visualize data obtained from atomic force microscopy. For astronomy, ImageJ is used to analyze images obtained from telescopes and satellites and visualize data obtained from observatories. NASA's Jet Propulsion Laboratory hosts a central node with a good collection of data that is available for download at http://pds.jpl.nasa.gov/. It contains information on the planetary missions as well as other research fields such as atmospheres or asteroids.

As it supports a large number of different image formats, it is a great image viewer and allows a great number of pixel-based operations. It also supports images with bit depths greater than 8 or 16 bits per channel. However, it is not meant for anything other than pixel-based operations. If you wish to use vector-based operations, then ImageJ is not the tool for you (unless you wish to develop this functionality).

Besides the common tools for image processing, such as cropping, rotating, and scaling, it supports images with multiple dimensions. Images with up to five dimensions can be processed and saved. These dimensions can include channels (multiple colors), frames (time points), and slices (Z planes), and any combination of these dimensions. Currently, multipoint acquisitions are not supported (different locations in a larger XY space). It is also possible to change the intensity of pixels displayed by adjusting the brightness and contrast, or the color-coding of the pixels (Lookup Tables). More advanced techniques to correct image acquisition artifacts, such as background and bleaching, are also available.

The default image format of ImageJ is the Tagged Image File Format (TIFF). This format allows for the storage of multidimensional data and supports many meta-information fields for calibration, data acquisition information, and descriptions. It can also store information about elements such as overlays. Graphical annotations are placed on the image in a separate layer. Measurements will benefit from the calibration included in the image, allowing for a fast feedback of sizes in the appropriate unit. It is, however, less suited for different kinds of mixed data such as video files. Using the FFMPEG plugin allows you to open and save the image data of a video but not the audio track(s). Also, editing is limited to a small set of transitions and layering techniques. For editing videos with image and sound, non-linear editors are available. They allow for greater control.

It can also be used as an image-conversion tool. Many image formats can be read natively by ImageJ, and with the help of a plugin, many proprietary formats can be opened. Once the image is opened, it can be saved to any of the supported export formats supported by ImageJ, including, but not limited to TIF, JPG, and PNG for images and AVI and MOV for time series and Z-stacks. It can also be used to change the order and/or color of images exported by other software. It is, however, not meant as a general photo editor or nonlinear video editor, as it lacks some of the specialized tools required for these workflows.

 

The current state of ImageJ


Currently, ImageJ has been cited in more than 200 publications since the beginning of 2015, in fields ranging from physics and engineering to medicine and biology. Many publications are about newly developed plugins that were specifically developed to solve a problem within a certain subfield of science. On the ImageJ website, the page that lists plugins has more than 1000 plugins available. A few research institutes even have collections of multiple plugins available that were developed there as research projects. Most, if not all, are open source plugins with the full source code available. You can adjust and customize the code to suit your needs.

ImageJ2

ImageJ is still under active development, and new features and bug fixes are added to the core distribution on a regular basis. Currently, the development of a revised system for ImageJ is being developed. It is called ImageJ2. The goals of ImageJ2 are to better support multidimensional data as well as create a more extensible platform that can be used as a library instead of a standalone application. It will also create a more consistent environment for development and extension. One of the features being developed is the updating mechanism for ImageJ. Currently, it is possible to update ImageJ automatically using a central repository, and one of the goals of ImageJ2 is to expand this option to plugins and other features and allow tracking of bugs and features. However, one of the core requirements in the new ImageJ2 system is backward compatibility. This goal means that plugins developed now will stay functional in future releases of ImageJ. The current status is indicated as beta, which means the plugin is functional but may still contain bugs and is not optimized for performance yet.

SciFIO and OME-XML

Other developments related to image are those related to image formats and standards. Currently, all major commercial acquisition platforms store image data in unique proprietary file formats. The SCIFIO project is aimed at creating an extensible and integrated interface to handle images of different formats. It will support more image formats and allow for additional options to be set when importing the data, such as autoscaling, loading metadata, and loading the data in different ImageJ image types. However, it is still under active development, and some of the features do not quite work in a production environment (yet).

The OME-XML (Open Microscopy Environment-XML) project is aimed at creating a file format that contains all the image and metadata in a standardized format. This would facilitate the exchange of microscope image data, regardless of the equipment used for acquisition. It is mainly focused on the exchange of microscopy data in the field of life sciences. It contains all the experimental and setup data as well as the pixel data in a single file specification.

Bio-formats

Besides the OME-XML format, which is focused on integrating acquisition and processing across multiple acquisition platforms, there is also active development of the plugin used to import many image formats currently in existence. This plugin, called Bio-Formats, is mostly focused on image formats from the life sciences. However, it also supports FITS data, which is used in the field of astronomy and space exploration. It currently supports (to different degrees) 140 different image formats and converts them to the OME-XML format for use in ImageJ.

 

Integrated environment for acquisition and processing


As ImageJ is such an extensible application for acquisition, processing, and analysis, it is impossible to deal with all the options and extensions. In this edition, I will focus on image processing and analysis. I recommend the Fiji distribution for people beginning with ImageJ, as it contains a large number of useful features that allow you to get off to a running start. Another advantage is the presence of the script editor supplied with Fiji, which has many features that some of the larger Java development suites also provide. These features mainly include syntax highlighting and smart indenting. The editor also includes a selection of macro and plugin templates that allow for a basic framework to start with.

 

Obtaining and installing ImageJ


The current version of ImageJ can be run on any platform that supports Java. When you wish to use ImageJ or one of the other distributions, a version can be downloaded for your specific operating system. A distribution of ImageJ can be downloaded with the Java Runtime Environment (JRE) prepackaged. The following sections will explain how to obtain and install ImageJ on the three main operating systems: Windows, OS X, and Linux.

Installation of ImageJ

When you download a copy of ImageJ, the JRE can be provided along with it. If you already have a copy of the JRE installed, you could download ImageJ without the JRE for a faster download. The minimal requirements to run ImageJ are JRE Version 1.6 or higher. For some distributions, most notably Fiji, the JRE has to be version 1.6. This limitation is due to the current implementation of the updater included with Fiji, which is not capable of updating the JRE. This problem may be resolved in the future.

As ImageJ comes with its own JRE, it can be extracted on a USB drive and run from there without installation. The only limitations on the system are dependent on the size of the images. ImageJ loads images directly into memory, so the available system memory needs to be large enough to hold the images you wish to process. When memory requirements exceed 3 GB, a 64-bit operating system with a 64-bit JRE is required.

Since ImageJ is platform independent, you could use the same version on all three platforms: Windows, OS X, and Linux. The only platform-dependent part is the JRE; for each platform, there is a specific JRE installation. The following sections will explain how to install ImageJ on each of the operating systems.

Installing on Windows

In order to install ImageJ on Windows, you can download the latest version from the ImageJ website at the NIH (http://imagej.nih.gov/ij/download.html) or for Fiji from the Fiji website (http://Fiji.sc/Downloads). When downloading from the NIH website, there are two choices: an installer for 32-bit or 64-bit systems and a ZIP archive when you wish to run ImageJ on a platform without installer privileges.

When using the installer version, it is generally not recommended that you install ImageJ in the Program Files folder. Certain files within the ImageJ folder need to be modified when using the program, so when running it as a regular user, access problems may occur. Also, when installing or creating plugins, the compiled files need to be placed in the plugins folder within ImageJ. This folder may not have write permission when it is located in the Program Files folder for regular (non-administrator) users. Alternatively, you could change the access permissions for the ImageJ folder specifically. However, this is not recommended from a security point of view.

Double-clicking on the ImageJ.exe file within the extracted folder will start ImageJ. This file is a wrapper executable that calls the ij.jar file and uses the supplied JRE to run it. The Fiji distribution comes as a ZIP archive that can be extracted on a disk and run immediately:

Installing on Mac OS X

ImageJ is available for Mac OS X as a ZIP archive that can be extracted to a folder within the Applications folder. The Fiji distribution can be downloaded as a DMG file that can be dropped in the Applications folder. This will install the ImageJ folder and make it accessible for all registered users. It will also create a Fiji icon in the app drawer. If you wish to import or export QuickTime movies under OS X 10.10 (Yosemite), you need to download the QTJava.zip and libQTJNative.jnilib files from http://imagej.nih.gov/ij/download/qt/ into your home directory within the Library/Java/Extensions folder.

Note that in OS X 10.7 and later, you may receive a warning the first time you try to run ImageJ. This warning will say ImageJ can't be opened because it is from an unidentified developer. This can be resolved by going to the system settings and pushing the allow button in the security and privacy panel. This should prevent this warning from showing up in the future. Alternatively, you can select the Anywhere option from the Allow apps downloaded from section. The latter option is not recommended from a security point of view, as it might also allow malicious software to be executed.

Note that when ImageJ (or Fiji) is run on OS X, the menu bar is not part of the main window as in Windows:

Installing on Linux

ImageJ can be installed on Linux platforms by unpacking the distribution from the NIH website. The distribution from the NIH website is available as a ZIP file, while the Fiji distribution is available as a tar.gz file. For most Linux distributions, it is recommended that you extract the archive to a location within your home folder. This prevents problems with write permissions on the ImageJ folders. The folder contains a shell script to run ImageJ. This shell script is named ImageJ. For different desktop environments, methods exist to create a shell shortcut to this script to allow it to run from a shortcut.

 

The ImageJ folder structure


After installing ImageJ, a folder structure is placed at a location designated during the installation process. This folder's structure consists of a few key folders that are essential to the regular functioning of ImageJ. If you installed ImageJ in a folder to which you have no write privileges, there are two important folders that need read and write permissions in order for ImageJ to function: the plugins and macros folders. Also, the configuration file on Windows platforms (pref.cfg) needs write permissions for the user. Without the write permission, settings cannot be changed. The next section briefly explains the properties for the plugins and macros folders, and how ImageJ uses them.

Plugins folder

The two most important folders are the macros and plugins folders. These folders will be searched for available macros and plugins when ImageJ loads. When you download a plugin and place it in the plugins folder, the plugin will be found the next time ImageJ starts. When downloading plugins, there are three different options of files that can be downloaded: a Java source file (.java), a compiled file (.class), or a Java archive (.jar). In order for plugins to be displayed in the plugins menu, the .java and .class files need to contain at least one underscore character in the filename. For .jar files, the archive needs to contain a plugins.config file that defines the location within the menu system. This has an additional advantage that plugins within a .jar archive can also be installed outside the plugins menu.Underscores are replaced by spaces in the plugins menu or removed completely if the last character is an underscore. If you place your plugins in a folder within the plugins folder, this folder name will also show up in the Plugins menu, but only if it contains at least one valid plugin. If you download the source file of a plugin, you can create an executable plugin by choosing Compile and Run from the Plugins menu and selecting the Java file. The next time ImageJ is run, the new plugin will be automatically detected.

JAR files are slightly special. They can be placed within the plugins folder, but they do not have to show up in the Plugins menu. The JAR file contains a manifest that specifies the location where the plugins within it are placed. This specification allows the developer to place the plugin in a specific submenu of the Plugins menu, regardless of the folder where the JAR file is placed. This would be especially handy if you create a group of linked or associated plugins that you wish to group within the Plugins menu.

Macros folder

The macros folder contains a collection of macros that come with ImageJ and is also the default location to store user-defined macros. ImageJ macros are flat text files with the .ijm extension, although this extension is not essential. Any flat text file with valid macro code can be run in ImageJ. Macros in ImageJ have their own language, which is similar to Java, but with a few minor differences. Chapter 5, Basic Measurements with ImageJ will investigate how to create macros and will explain the language constructs in ImageJ macros.

 

Configuring a fresh ImageJ installation


After installing ImageJ, it can be launched for the first time. When using ImageJ, a few settings need to be made to allow successful processing. One of the most important settings is the number of threads and memory available for ImageJ. By default, ImageJ has 512 MB of memory available. This allows for opening images up to 512 MB, which is fine for a large amount of use cases. However, with the current trends in image acquisition, files now tend to be in the range of 1 or more gigabytes. So, one of the first things is to set the memory for ImageJ to at least the size of the largest images you think you'll need to process. Fiji, on the other hand, automatically allocates 50 percent of the available system memory when installed, which can be changed if necessary.

To set the memory allocated to ImageJ, you can set find the setting for memory under Edit | Options | Memory and Threads…. You can set the maximum memory to any value that is less than the system memory. Keep in mind that on a 32-bit system, it is not possible to allocate more than 3 GB. If you wish to allocate more than 3 GB of memory, installing 64-bit ImageJ on a 64-bit operating system is required.

It is also possible to use a command-line argument to pass the memory size when starting ImageJ. To do so, run ImageJ from the command line using the following command:

javaw –Xmx1024m -cp ij.jar ij.ImageJ

This tells the computer to run ImageJ with 1024 MB (1024m) of memory. If you need more, then you can change the value of 1024m to whatever value is suitable. However, make sure that you do not use more memory than is available on your system.

Another setting that is important to verify is in the Appearance dialog. The Interpolate zoomed images option should be unchecked for image processing. This option can interfere or give misleading results when processing:

If you plan to work with images containing a lot of white pixels, it is also advisable that you change the selection color to a different value than the default Yellow. This can be done via the Colors setting in preferences. A good default value in many cases is Orange or Green.

 

Summary


In this chapter, we looked at the origin and use of ImageJ, and discussed how to download and install it on different platforms. We looked at the basic folder structure of the ImageJ installation and configured it for use. Everything should now be set up to start with the first steps in image processing.

Latest Reviews (1 reviews total)
calidad de impresión mala
Image Processing with ImageJ - Second Edition
Unlock this book and the full library FREE for 7 days
Start now