Sunteți pe pagina 1din 93

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Workshop: Image processing and analysis with ImageJ and MRI Cell Image Analyzer
Montpellier RIO Imaging Volker Baecker 30.04.2010

volker.baecker@mri.cnrs.fr

!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Table of Contents
. Introd$ction.............................................................................................................................% &. Installing ImageJ and MRI Cell Image Analyzer...................................................................% &. Installing ImageJ..............................................................................................................% &.& Memory 'ettings..............................................................................................................% &.# (pgrading ImageJ............................................................................................................) &.% Installing loci*bioformats ................................................................................................) &.) Associating file types with ImageJ...................................................................................) &.+ Installing the Montpellier RI, Imaging pl$gins..............................................................+ #. A -$ick to$r............................................................................................................................+ #. .he tool*b$ttons.............................................................................................................../ #. . .he rectang$lar selection tool.................................................................................../ #. .& Meas$ring and the ImageJ Res$lts .able................................................................./ #. .# 'election br$sh and tool options...............................................................................0 #. .% 1olygon and freehand*selection tools.......................................................................0 #. .) 2ine 'elections ........................................................................................................0 #. .+ 1rofile plots..............................................................................................................." #. ./ Arrow tool3 annotations3 roi*manager and overlays................................................." #. .0 1oint 'elections...................................................................................................... 4 #. ." .he magic wand tool.............................................................................................. #. . 4 .he particle analyzer............................................................................................. & #. . Magnifying glass and scrolling............................................................................. # #. . & 5oregro$nd and 6ackgro$nd Color3 Clear3 5ill3 7raw and Revert....................... # #. . # Macros.................................................................................................................. % #. . % Macro Recorder and batch processing.................................................................. ) #. . ) 1l$gins.................................................................................................................. + #. . ) Image stacks......................................................................................................... / #. . + .he ImageJ #7 8iewer......................................................................................... 0 %. 9elp3 7oc$mentation and :;tensions................................................................................... " %. 9elp and 7oc$mentation................................................................................................ " %.& 1l$gins............................................................................................................................&4 %.# Macros............................................................................................................................&4 %.% .ools...............................................................................................................................& %.) (pdate Macros and .ools...............................................................................................&& ). 7isplay and image enhancements.........................................................................................&# ). <hat is a digital image...................................................................................................&# ).& 6rightness and Contrast ad=$stment...............................................................................&% ).# >on linear display*ad=$stments......................................................................................&+ ).#. ?amma correction.......................................................................................................&/ ).#.& :nhance Contrast.........................................................................................................&" ).#.&. >ormalization or contrast stretching...................................................................#4 ).#.&.& 9istogram :-$alization.......................................................................................# ).% Changing the palettes.....................................................................................................## ).) ,verlay of m$ltiple channels.........................................................................................#+ ).). Aligning channels...................................................................................................%4 ).).& ,verlay of vol$me images......................................................................................%4 volker.baecker@mri.cnrs.fr &!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer ).+ >oise s$ppression...........................................................................................................% ).+. Convol$tion filter...................................................................................................%& ).+. . Mean filter.......................................................................................................%& ).+. .& ?a$ssian bl$r filter..........................................................................................%) ).+. .# :dge enhancing filter......................................................................................%" ).+.& Rank 5ilter..............................................................................................................)4 ).+.# 5iltering in the fre-$ency domain..........................................................................) )./ 6ackgro$nd s$btraction ..............................................................................................)+ )./. Inhomogeneo$s backgro$nd...................................................................................)0 ).0 Increasing the apparent sharpness..................................................................................+ +. 'egmentation.........................................................................................................................+ +. Man$al threshold selection.............................................................................................+ +.& Meas$rements and the R,I*Manager.............................................................................+) +.# Comp$ted thresholds......................................................................................................+0 +.% 'egmentation of more then & ob=ect classes...................................................................+0 +.) <atershed segmentation.................................................................................................+" /. Image types and formats......................................................................................................./ /. 'patial resol$tion............................................................................................................/ /.& Image types...................................................................................................................../ /.&. Conversion from + to 0 bit..................................................................................../& /.&.& R?6 Images.........................................................................................................../& /.&.# 5ile 5ormats............................................................................................................/% 0. Image Analysis....................................................................................................................../% 0. Co$nting ob=ects............................................................................................................./% 0. . Co$nting ob=ects man$ally...................................................................................../% 0. .& Co$nting and meas$ring separated ob=ects a$tomatically....................................../) 0. .# Co$nting and meas$ring ob=ects to$ching each other a$tomatically...................../+ 0. .#. 'tatistical approach........................................................................................./+ 0. .#.& 2ocal .hreshold..............................................................................................// 0. .#.# <atershed.......................................................................................................// 0. .#.% ,ther methods................................................................................................./0 0.& Comparing intensities...................................................................................................../0 0.# Classifying ob=ects........................................................................................................./" ". Annotating images................................................................................................................04 ". 'cale bar3 time stamper and event stamper....................................................................04 ".& Calibration bar................................................................................................................0& 4. <orking with m$lti*dimensional data................................................................................0# 4. .ime series...................................................................................................................0% 4. . Meas$ring velocities..................................................................................................0% . 6iological applications........................................................................................................0) . Colocalization analysis.................................................................................................0) . . 8is$alizing colocalization $sing overlays............................................................0) . .& @$antification of colocalization..........................................................................."4 . .&. Intensity correlation coefficient based methods..........................................."4 . .&. . 1earsonAs coefficient and scatter plot........................................................."4

volker.baecker@mri.cnrs.fr

#!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

! Introd"ction
In this workshop yo$ will learn how to apply image analysis and processing techni-$es3 $sing the p$blic domain software ImageJ and some additions Bpl$ginsC made by Montpellier RI, Imaging and others. ImageJ has been written and is maintained by <ayne Rasband at the >ational Instit$te of Mental 9ealth3 6ethesda3 Maryland3 ('A. ImageJ is the s$ccessor of the Macintosh software >I9 Image written by <ayne Rasband. ImageJ is written in Java3 which means that it can be r$n on any system for which a =ava r$ntime environment B=reC e;ists. It can be r$n $nder <indows3 Mac3 2in$; and other systems. It can be r$n as a browser pl$gin3 on a website or as a standalone application. 6eca$se of the easy way in which ImageJ can be e;tended3 $sing macros and pl$gins3 a lot of f$nctionality is available today3 especially in the fields of microscopy and biology.

#! Installing ImageJ and MRI Cell Image Analyzer


2.1 Installing ImageJ
.he ImageJ homepage is httpD!!rsb.info.nih.gov!i=!. ?o to the download page and download the appropriate version for yo$r operating system. In this workshop we will only $se winE1. 5or windows there are two versions availableD ImageJ b$ndled with the =ava r$ntime environment ImageJ witho$t a =ava r$ntime environment .o $se the last version the =ava r$ntime environment m$st already be installed on yo$r comp$ter. 5or this t$torial we download the first ImageJ b$ndle. R$n the installer and follow the instr$ctions on the screen. .he first time ImageJ is started a config$ration file for yo$r installation will be created. .he installer will create a -$ick*start icon and a desktop icon. Fo$ can $se these to start ImageJ. Fo$ can open images by dropping them onto the desktop icon.

2.2 Memory Settings


Java applications will only $se the memory allocated to them. (nder Edit>Options>Memory & Threads... yo$ can config$re the memory available to ImageJ.

Illustration 1: The memory and threads settings of ImageJ .he ma;im$m memory sho$ld be set to G of the available memory on yo$r machine. .o find o$t how m$ch memory yo$r machine has3 open the properties of My Computer and look for the amo$nt of available RAM. A dialog tells yo$ that the change will be applied the ne;t time yo$ start ImageJ. .he config$ration is stored in the file ImageJ.cfg in the ImageJ folder. 'ho$ld ImageJ not start after yo$ changed the memory settings3 delete the file ImageJ.cfg3 restart ImageJ and set the volker.baecker@mri.cnrs.fr %!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer ma;im$m memory to a lower val$e. A do$ble*click on the lower part of the ImageJ la$ncher window displays the amo$nt of $sed and available memory. Fo$ can $se lugins>!tilities>Monitor Memory...to monitor the memory $sage.

Illustration ": # dou$le clic% on the &indo& displays memory information. .he n$mber of parallel threads for stac%s is by defa$lt set to the n$mber of processors or cores available in yo$r system.

2.3 Upgrading ImageJ


.o $pgrade ImageJ3 start ImageJ and go to 'elp>!pdate ImageJ... 'elect the latest version from the list. ImageJ will be closed. ,pen it again and look at help>a$out ImageJ to see the c$rrent version n$mber. Alternatively yo$ can download the latest pre*release version of ImageJ from httpD!!rsb.info.nih.gov!i=!$pgrade! 7ownload the file i(.(ar and replace the version in the ImageJ home folder with the new version.

2.4 Installing loci-bioformats


ImageJ can read a n$mber of image formats like tiff Band tiff stacksC3 dicom3 fits3 pgm3 =peg3 bmp or gif images. It can not read other formats like ics or lsm by itself. If yo$ want to work with these file formats yo$ need pl$gins that can handle them. 2oci bio*formats is a pro=ect that implements a library which can read many biological image formats. H6io*5ormats is a standalone Java library for reading and writing life sciences image file formats. It is capable of parsing both pi;els and metadata for a large n$mber of formats3 as well as writing to several formats.I. ImageJ can take advantage of the bioformats library. Fo$ only have to download the file lociJtools.=ar from httpD!!www.loci.wisc.ed$!bio* formats!downloads and to p$t it into the pl$gins folder of yo$r ImageJ installation. ImageJ will a$tomatically $se it when it can not open an image itself. .he easiest way to install the pl$gin is to drag the link to the =ar file directly from the website onto the ImageJ la$ncher window. .his will download the pl$gin and ask yo$ where $nder the pl$gins folder yo$ want to save it. In this case yo$ can save it directly into the pl$gins folder.

2.5 Associating file types

it! ImageJ

.o open images by do$ble*clicking we have to associate the file type with the ImageJ program. 7ownload the zip*archive of e;ample images from the mri website httpD!!www.mri.cnrs.fr!inde;.phpKmL++ and $nzip the archive. Right*click on a tif*image3 select Hopen withI and Hchoose the programI from the conte;t men$. ,n the dialog click the browse b$tton and select ImageJ.e)e from the ImageJ home directory. Check the Hal&ays use this program to open files of this typeI option and click o% on the dialog. In the same way associate =pg*images with ImageJ.

volker.baecker@mri.cnrs.fr

)!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

2." Installing t!e Montpellier #I$ Imaging pl%gins


<e are going to $se some pl$gins from Montpellier RI, Imaging3 for D .he vis$al scripting pl$gin .he toolbo; pl$gin .he slide show control pl$gin .he look$p table pl$gin .hese are available at httpD!!www.mri.cnrs.fr!inde;.phpKmL#0. .o find them yo$ can go to the homepage of Montpellier RI, ImagingD www.mri.cnrs.fr. Click *esearch and de+elopment>M*I,*&-,.oft&are>M*I Cell Image #naly/er. 5ollow the -o&nload M*I Cell Image #naly/er link at the bottom of the page. 7ownload the two zip*archives mri* pl$gins*base.zip and mri*all*pl$gins.zip. .o install them they m$st be e;tracted in the ImageJ home folder. .he A$toR$n macro in the file 'tart$pMacros.t;t in the macros folder is r$n each time ImageJ is started. <e can $se it to switch to the MRI tool set at start$p. ,pen the file from lugins>Macros>.tartup Macros.... 5ind the A$toR$n macro. Fo$ might need to $n* comment it by removing the !! characters. Add the line
call("gui.CellImageAnalyzer.switchToMRIToolset");

'ave the changed 'tart$pMacros.t;t file. Any men$ command that can be fo$nd in the ImageJ la$ncher window can be $sed as an arg$ment to the r$n command and any static =ava method can be called $sing the call command.

$! A %"ick to"r
6efore e;plaining the image analysis tools in ImageJ in more detail3 we will make a -$ick to$r to get an overview of the most important tools. 7ownload and $nzip the images from httpD!!www.mri.cnrs.fr!mriwiki!$ploads!images.zip ,pen the image #0 dapi 1.tif. Fo$ can drag an image from yo$r operating system browser to the ImageJ window to open it.<e will $se this image as an e;ample in the whole chapter #.

figure 1: The e)ample image for chapter 1. Move the mo$se*pointer over image and watch the lower part of the ImageJ window. .he position of the mo$se*pointer and the intensity at that position are displayed in the lower part of the window.

volker.baecker@mri.cnrs.fr

+!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

figure 0: osition and intensity are displayed in the launcher &indo&.

3.1 &!e tool-b%ttons


>ow look at the tool*b$ttons in the ImageJ window. .he twelve tools $pto the color pic%er are basic tools that are always displayed. .he remaining tools belong to a toolset that can be changed $sing the rightmost b$tton. .ry this and than switch back to the startup macros toolset. <hen yo$ click on a tool b$tton the b$tton remains pressed and the corresponding tool will be active $ntil yo$ press another tool*b$tton. >otice that the name of the tool is displayed when the mo$se*pointer is over a tool*b$tton.

$! ! The rectang"lar selection tool


Make s$re that the rectang$lar selection tool is active. Fo$ can now make a rectang$lar selection in the image by clicking at a point and dragging the mo$se. <hile doing this the width3 the height and the aspect ratio of the selection are displayed. ,nce yo$ release the mo$se b$tton yo$ made a selection on the image. Fo$ can still change its position by clicking into it and dragging and its size by $sing the handles.

figure 2: # rectangular selection.

$! !# Meas"ring and the ImageJ Res"lts Table


.ry to make a selection that contains e;actly one n$cle$s. .hen press the key m on the keyboard. .his is the shortc$t for the measure command that can be fo$nd in the analy/e men$. .he ImageJ results ta$le will be opened. .he table contains the res$lts of the meas$rements. All meas$rements will be stored in this global table. In the edit men$ yo$ have the possibility to d$plicate the table to keep meas$rements and to remove everything from the system table with the command clear results. .he set measurements command allows to define which properties will be meas$red. >ote that the change will only be active for f$t$re meas$rements3 the corresponding col$mns for already e;isting meas$rements will be filled with zero val$es.

volker.baecker@mri.cnrs.fr

/!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

figure 3: The ImageJ results ta$le.

$! !$ &election br"sh and tool options


6ehind tool*b$ttons that have a small3 red triangle in the lower right corner yo$ can find a list of tools by right*clicking on the b$tton. Remove all selections from the image. Fo$ can do this by clicking somewhere in the image while the rectang$lar selection tool is active or by pressing shift a Ba is the shortc$t for select all3 shift,a for select none from the men$ edit, >selectionC. Right*click on the elliptical,selection tool $utton and select the selection $rush tool. Click in the image and move the mo$se3 keeping the b$tton down. Fo$ can paint a selection onto the image. ,nce yo$ released the b$tton3 yo$ can add to the selection by holding down the shift key while painting. Fo$ can remove from a selection by holding down the alt key. .hese two modifier keys work for all kinds of selections in ImageJ.

figure 4: The options of the selection $rush tool. .ools can have options. Fo$ can access them by do$ble*clicking on the tool b$tton. Change the size of the br$sh $sed by the selection br$sh tool.

$! !' (olygon and freehand)selection tools


.ry the polygon and freehand*selection tools. >ote that yo$ do not have to close the selections at the end. 5or the polygon selection yo$ can finish the process by right clicking and the selection will a$tomatically be closed. .he freehand selection will be closed as soon as yo$ release the mo$se b$tton.

$! !* +ine &elections
.he line selection toolsD straight line5 segmented line and freehand line can be $sed to meas$re length and angles with the horizontal ;*a;is. (se a right click to finish a segmented volker.baecker@mri.cnrs.fr 0!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer line. .he angle tool can be $sed to meas$re arbitrary angles. 9owever the line tools have the line width as a parameter. If the line width is bigger than one the selection is an area and all area meas$rements can be applied.

$! !, (rofile plots
Fo$ can $se the line selection tools to create profile plots. 5irst make a line selection across a n$cle$s3 then press the key % Bthe shortc$t for #naly/e,> lot profileC. >ote that when the line width is bigger than one the profile will be averaged over the width. If yo$ want averaged line profiles of horizontal or vertical lines3 yo$ can $se the rectang$lar selection tool instead. If yo$ want to $se vertical lines yo$ have to press alt,% instead of % in this case.

figure 6: # profile plot along a line crossing a nucleus. A profile plot can be $sed to meas$re properties like for e;ample the diameter of an ob=ect by taking into acco$nt only intensity val$es above a baseline3 that is visible in the plot. >ote that the plot is an image itself and that yo$ can make selections on it and meas$re them.

$! !- Arrow tool. annotations. roi)manager and o/erlays


'elect the arro& tool from the straight line tool b$tton. 7o$ble click to open the options dialog and set magenta as foregro$nd color. Click in the image and drag the mo$se to create an arrow. <ith the shift modifier key yo$ can restrain the arrows to horizontal and vertical ones. If yo$ want to have m$ltiple arrows yo$ can add them to the overlay by pressing the $ key Bshortc$t for Image>O+erlay>#dd .electionC. Fo$ can $se the te)t tool to add an annotation to an arrow. 7o not draw the te;t into the image $sing ctrl7d as the te;t tool proposes. Instead $se ctrlMaltMb to add it to the overlay as well.

volker.baecker@mri.cnrs.fr

"!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

figure 8: # non,destructi+e o+erlay of arro&s and annotations. If yo$ want to be able to modify ob=ects in the overlay3 yo$ have to add them to the roi* manager. Roi stands for region of interest and the roi*manager is the tool that allows to manage m$ltiple selections. (se Image,>O+erlay,>To *OI Manager to add the ob=ects in the overlay to the roi*manager. >ote that yo$ find the roi*manager $nder #naly/e,>Tools.Make s$re that 'ho& #ll and Edit Mode are selected. Fo$ can now select a selection ob=ect by clicking on its n$mber in the image or by selecting it in the list in the roi*manager. Fo$ can modify the selected selection ob=ect and make the change permanent by pressing update on the roi*manager. .o create an rgb*snapshot of yo$r image with overlay $se the flatten command from the roi*manager. >ote that overlay and roi*manager can be $sed with all kinds of selection3 not only arrows and te;t. 7elete all overlays and all seletions in the roi*manager. Make some area selections on the image and add each to the roi*manager. Make s$re that no roi is selected and press the meas$re b$tton. :ach selection will be meas$red independently.

$! !0 (oint &elections
Fo$ can $se the point selection tools to man$ally co$nt ob=ects in an image. <ith the point selection tool $se shift to add points. Fo$ can delete points $sing alt. >ote that the n$mbers of the remaining points change accordingly. If make an error and yo$ loose yo$r selection yo$ can get the last selection back $sing shift7e Bthe shortc$t for edit,>selection,>restore selectionC.Fo$ can add the selection to the roi*manager or meas$re it. .he options allow to directly adding each point to the manager or to meas$re it while yo$ are working. If yo$ $se the m$lti*point selection tool3 yo$ do not have to $se shift to add points3 so yo$ are less likely to accidentally delete the selection. As before yo$ can $se flatten on the roi*manager to create an image that permanently contains the point markers. (sing the more b$tton on the roi* manager yo$ can save and load selections3 in case yo$ need a break in the middle of co$nting.

volker.baecker@mri.cnrs.fr

4!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

figure 19: Counting o$(ects &ith the point selection tool.

$! !1 The magic wand tool


(se the wand tool to select all n$clei3 one after the other. Add them to the roi*manager and meas$re them. .o do this yo$ either need to change the tolerance in the wand toolAs options or yo$ need to set a threshold on the image. If a threshold is set on the image the wand tool selects all connected pi;el above the lower and below the $pper threshold val$e. .o define a threshold val$e press shift,t Bthe shortc$t for Image,>#d(ust,>ThresholdC to open the threshold tool. 'elect dar% $ac%ground. If yo$ select the O+er:!nder mode in the right selection bo;3 val$es below the lower threshold will be displayed in bl$e and val$es above the $pper threshold will be displayed in green. Ad=$st the lower threshold and select the n$clei $sing the wand tool.

volker.baecker@mri.cnrs.fr

!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 11: # lo&er threshold is set and the nuclei ha+e $een selected using the &and tool.

$! ! 2 The particle analyzer


Instead of clicking on each ob=ect with the wand tool3 yo$ can let the particle analyzer do the work. As before3 define the lower threshold3 then call #naly/e articles from the men$ #naly/e. Make s$re that only #dd to Manager is selected in the #naly/e articles dialog. .hen click ok. Fo$ can e;cl$de too small or too big ob=ects by s$pplying a minimal and ma;imal size in the article #naly/er dialog.

volker.baecker@mri.cnrs.fr

&!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

$! !

Magnifying glass and scrolling

.he magnifying glass tool allows to change the zoom of the image. A left click zooms in and a right click zooms o$t. <hen the image is bigger than the window the position of the c$rrent view is indicated in the $pper left corner. .he scrolling tool allows to move the image in the window by clicking and dragging. .he keyboard shortc$ts for zooming are M and N and the scrolling can be done by holding down space. 'crolling with the space key down allows to scroll while another tool is active.

figure 1": The position of the current +ie& in the image is indicated.

$! ! # 3oregro"nd and 4ackgro"nd Color. Clear. 3ill. 5raw and Re/ert


.he color picker allows to select the foregro$nd color from an image. 'elect the tool and click somewhere in the image. .he foregro$nd color will be changed. In the options of the color volker.baecker@mri.cnrs.fr #!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer picker the backgro$nd and foregro$nd colors can be swapped and the colors can be selected from a palette. >ote however that only gray*scale val$es will be $sed as long as the image is not a color image. Fo$ can $se Image>Type>*;< Color to convert the image into a color image. .he foregro$nd color will be $sed by the commands fill and dra& from the men$ edit and the backgro$nd color will be $sed by the commands clear and clear outside. After yo$ have changed yo$r image yo$ can reload the original version from disk by pressing the r key Bshortc$t for =ile,>*e+ertC.

$! ! $ Macros
Macros are small programs written either in the ImageJ macro lang$age or in a scripting lang$age3 that can be r$n by ImageJ to a$tomate image analysis tasks. Click on the de+ men$ and select macros. .his will open a list of macros on the ImageJ website. 'earch the macro with the name -isplayTiffInfo.t)t. 7rag the link from the web*page and drop it onto the ImageJ la$ncher window. .his will open the macro in the ImageJ macro editor. Fo$ can r$n it $sing the command *un Macro from the men$ Macros of the macro editor. .his macro will display some information stored in the header of the image.

figure 11: The macro displays information from the header of the image file. <e will try another macro. .he macro R,IJColorJCoder.i=m can mark ob=ects with a color according to the val$e of a given property3 for e;ample area or ro$ndness. ,pen the macro by dropping it on the ImageJ la$ncher window. .o $se the macro we need the selections of the ob=ects in the roi*manager and the corresponding meas$rements in the res$lts table. 'et the threshold and $se the 1article Analyzer and the meas$re command from the roi*manager to achieve this3 then r$n the macro.

volker.baecker@mri.cnrs.fr

%!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

figure 10: The roundness of the o$(ects is mar%ed &ith a color, code.

Illustration 12: The color code for the roundness in the left image.

$! ! ' Macro Recorder and batch processing


Imagine we want to meas$re some properties like size and form of the n$clei in o$r image3 b$t in many images3 not only in one. <e co$ld r$n all the commands needed on each image3 one after the other to achieve this. 6$t we can do betterD <e can record the commands needed to analyze one image and create a macro from them. 'tart the macro recorder $nder lugins,>Macros,>*ecord. (nder #naly/e,>.et Measurements select the properties yo$ want to meas$re. >ow set the threshold and r$n the particle analy/er. In the particle analy/er select display results only. .hen r$n analy/e, >la$el to add labels to the image that indicate which ob=ects have been fo$nd. Remove $nneeded commands from the macro recorder3 then click create and close the recorder window. Fo$ sho$ld now have a macro similar to the followingD
run("Set Measurements...", "area mean stan ar mo al min centroi center !erimeter is!lay re irect"#one ecimal"$"); setAutoThreshol ("%e&ault ar'"); run("Analyze (articles...", "size")*+In&inity circularity"*.**+).** show"#othing is!lay"); run(",a-el");

,pen the first image from the folder 11,$atch and r$n the macro. 1ress shift,o Bthe shortc$t for 5ile*O,pen >e;tC to open the ne;t image in the folder and r$n the macro again. Repeat this $ntil all images are analyzed. ,f co$rse we can still do better. <e do not have to load each image man$ally. Copy the te;t of the macro3 then open 1rocess,><atch,>Macro and paste it into the te;t part of the dialog. volker.baecker@mri.cnrs.fr )!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer 'elect the inp$t folder. Create a new folder and select it as res$lt folder3 then press the process b$tton. As a res$lt yo$ will get the meas$rements in the results ta$le and the labeled images in the res$lts folder.

figure 13: The ImageJ $atch processor.

$! ! * (l"gins
1l$gins are =ava mod$les that can be $sed to add f$nctionality to ImageJ. A large n$mber of pl$gins concerning microscopy is available. 'elect 1lugins from the -e+ men$ b$tton. .his will open the pl$gins page on the ImageJ website in yo$r browser. 2ook for the 'I,E B'imple Interactive ,b=ect :;tractionC pl$gin and click on the link. .his pl$gin will allow to segment color images by giving e;amples of backgro$nd and foregro$nd areas. .o install the pl$gin drag the sio;J.=ar link from the webpage and drop it onto the ImageJ la$ncher window. A file*save dialog will pop*$p. (se it to create a s$bfolder .egmentation of the folder plugins and save the pl$gin into this s$bfolder. It will now be available in the lugins men$ in ImageJ. ,pen one of the images from the 90 > plant ?ro$oter@ folder. R$n the sio;*pl$gin from the plugins men$. (se a selection tool and select m$ltiple foregro$nd zones holding down the shift key. .hen switch to backgro$nd and select m$ltiple backgro$nd zones. 1ress the segment b$tton. If yo$ want yo$ can create a mask for f$rther processing.

volker.baecker@mri.cnrs.fr

+!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 14: The .IOA .egmentation plugin.

$! ! * Image stacks
'tacks can either represent vol$me data or time series. ,pen the e;ample stack T1 'ead from the .t% men$ b$tton. >ote the slider below the image. Fo$ can $se it to select the visible slice of the stack.

volker.baecker@mri.cnrs.fr

/!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

figure 16: # stac% of images in ImageJ .he play and pa$se b$tton ne;t to the slider allow to start and stop the animation of the stack. A right click on the same b$tton opens the options*dialog for the animation. .ry the commands / pro(ect3 1d,pro(ect and ma%e montage. Com$ine allows to combine to stacks one ne;t to the other or one above the other3 while concatenate allows to add the slices of one stack at the end of another.

$! ! , The ImageJ $5 6iewer


Change the c$rrent tool*set to the lugins tool*set. 5rom the 1- men$ b$tton select ImageJ 1- Bie&er. If yo$ do not have =ava#7 installed3 yo$ will be asked if ImageJ sho$ld install it for yo$. If yo$ get this -$estion answer yes. Fo$ need to restart ImageJ. ,pen the T1 'ead again and start the mageJ 1- Bie&er a second time. 5rom the viewer window $se the =ile, >#dd Content men$ to add the head to the #d scene. As long as the scrolling tool is selected yo$ can t$rn the #d scene by dragging with the mo$se. Make a freehand*selection that covers a part of the head in the #7*scene. 'elect the head*ob=ect from the select men$. (se Edit, >=ill to remove a part of the image data. Reselect the scrolling tool and t$rn the head so that yo$ can see the area that yo$ c$t.

volker.baecker@mri.cnrs.fr

0!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 18: # 1d scene. art of the data has $een cut, off &ith the fill command.

'! 7elp. 5oc"mentation and 89tensions


4.1 'elp and (oc%mentation
At the page httpD!!rsb.info.nih.gov!i=!docs!inde;.html yo$ can find help for the men$ commands as well as a link to the M65 ImageJ man$al. .he page can be accessed from within ImageJ via the men$ 'elp>-ocumentation.... .he ImageJ $ser g$ide written by .iago A. 5erreira can be fo$nd $nderD httpD!!rsbweb.nih.gov!i=!docs!$ser*g$ide.pdf 5$rther information can be fo$nd at the ImageJ 7oc$mentation <ikiD httpD!!image=doc$.t$dor.l$!dok$.php .he new image=dev.org BhttpD!!image=dev.org!C is s$pposed to become the new home of the ImageJ comm$nity in the f$t$re. .he book H7igital Image 1rocessing N An Algorithmic Introd$ction $sing JavaI can be fo$nd hereD httpD!!www.imagingbook.com!inde;.phpKidL ) <ilhelm 6(R?:R P Mark J. 6(R?: 7igital Image 1rocessing N An Algorithmic Introd$ction $sing Java .e;tbook with )+4 pages3 &/ fig$res and / tables volker.baecker@mri.cnrs.fr "!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer Q 'pringer &440 I'6>D "/0* *0%+&0*#/"*+ .he McMaster 6iophotonics 5acility offers an ImageJ man$al and a collection of pl$gins $nderD httpD!!www.macbiophotonics.ca!image=! Fo$ can find more detailed e;planation of some image processing techni-$es in the hyperlink image processing resso$rce BhiprC atD httpD!!homepages.inf.ed.ac.$k!rbf!9I1R&!inde;.htm

4.2 )l%gins
>ew f$nctions can be added to ImageJ by installing pl$gins. 1l$gins either add commands to some men$s or they can be r$n from the lugins men$ and its s$b*men$s once they have been installed. Fo$ can access the ImageJ pl$gin*site from the men$ 'elp> lugins.... If the pl$gin is available as a .=ar or a .class file3 yo$ can install it by dragging the link directly from yo$r web*browser onto the ImageJ la$ncher window. .his will ca$se ImageJ to download the pl$gin. It then opens a dialog that lets yo$ copy the pl$gin into the pl$gins folder or into one of its s$b*folders. As an e;ample we will install a pl$gin that draws random ovals into a new image. (se the help men$ to go to the pl$gin site. 'croll down to the category ;raphics and click on the link *andom O+als. 7rag the link *andomCO+als.class onto the ImageJ la$ncher window. 'elect the folder ;raphics in the .a+e lugin... dialog or create it if it doesnAt e;ist. Fo$ can now directly r$n the newly installed pl$gin from the lugins men$3 $sing lugins>;raphics>*andom O+als.

Illustration "9: The result of running the D *andom O+als E plugin. 'ho$ld the pl$gin come as a zip file3 $nzip it into a temporary folder. If the content consists of .(ar or .class files3 yo$ can drag them to the ImageJ la$ncher window in the same way to install them. ,therwise follow the instr$ctions on the web*site from which yo$ downloaded the pl$gin.

4.3 Macros
Macros are scripts in the ImageJ*macro lang$age. A n$mber of macros is available in the folder macros in the ImageJ base*folder. Fo$ open them by dragging them onto the ImageJ la$ncher window or by $sing 1lugins>Macros>Edit.... volker.baecker@mri.cnrs.fr &4!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer Fo$ can access the ImageJ macro site from the men$ 'elp>Macros. Fo$ can directly drag a link to a macro from the web*browser onto the ImageJ la$ncher window. .his will open the macro in the ImageJ macro editor3 from which yo$ can r$n the macro $sing the men$ Macros>*un Macro Bor ctrl7rC. .ry to r$n the macro Mandel$rot.t)t this way.

Illustration "1: The result of running the Mandel$rot.t)t macro.

'!' Tools
.ools are macros that add a tool b$tton to ImageJAs toolbar. >ote that the name of the tool is displayed in the stat$s line3 when yo$ move the mo$se over a tool*b$tton. .here is a difference between action*tools and tools. Action*tools e;ec$te a single command. .hey do not change the active tool. <hen yo$ press the b$tton of a tool3 that is not an action tool3 yo$ change the active tool. .he active tool will $s$ally do something when yo$ click in an image. An e;ample of a tool is the *ectangular .election tool. An e;ample of an action tool is the a$ort macro or sample tool. .here can be m$ltiple tools hidden behind one tool*b$tton. If this is the case a small red arrow is displayed on the b$tton. A right*click on the b$tton shows the list of tools and allows to change the tool. 2ook for e;ample at the second b$tton from the left. .his is the elliptical selection tool. A right*click on the b$tton gives access to the selection $rush tool.

Illustration "": # right clic% allo&s to select $et&een different tools. A tool or a gro$p of tools Bthose that share the same b$ttonC can have options. .he options can be accessed by a do$ble*click on the tool*b$tton.

volker.baecker@mri.cnrs.fr

& !"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration "1: The options of the selection $rush tool. 5rom the men$ 'elp select Macros. ,n the web*page scroll down to the tools folder and enter the folder. 'earch for *;< rofilesTool.t)t and drag the link onto the ImageJ toolbar. All tools right of the color pic%er will disappear and there will be a new tool b$tton for the rg$ profiles tool.

Illustration "0: #n rg$ e)ample Illustration "2: The rg$ profile along image. the line in the image.

'!* :pdate Macros and Tools


.here is a tool available that a$tomatically downloads and $pdates the macros and tools from the ImageJ website to yo$r local machine. ?o again to the macros part of the ImageJ website for e;ample by $sing the men$ 'elp>Macros. 'croll down and enter the tools folder. 'earch for Macros#ndTools!pdater.t)t and drag the link onto the ImageJ la$ncher window. Click on the new update b$tton and answer the -$estions in the dialog.

>ew macros and tools will be downloaded into the ImageJ:macros and ImageJ:macros:tools folders. :;isting macros and tools will be $pdated if a newer version is available on the website. volker.baecker@mri.cnrs.fr &&!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

*! 5isplay and image enhancements


5.1 *!at is a digital image
6efore we start to work on images we sho$ld answer a simple -$estionD H<hat is a digital imageKI. .here are different kinds of images3 of co$rse. Images can for e;ample be two or three dimensional and they can have one or more color channels. In the simplest case a digital image is a two dimensional grid of width ; height cells. :ach cell is a s-$are with sides of length p. .he s-$ares are called pi;els and p is called the pi;el size. .o each pi;el3 an integer val$e between 4 and a ma;im$m val$e is associated. .hese val$es are interpreted as intensities. 4 $s$ally means no intensity3 yielding a black pi;el. 9igher val$es $s$ally mean lighter pi;els and lower val$es mean darker pi;els. .he word pi;el is b$ild from Hpi; elementI. 1i; is a common abbreviation for pict$re. ,pen the image e)ample1. Fo$ can either do$ble click the image or $se 5ileOopen from the ImageJ window. <hen an ImageJ window is active yo$ can $se keyboard shortc$ts to call commands from the ImageJ men$s. .o get the open dialog3 click on an ImageJ window and press RoS.

Illustration "3: The first e)ample image. (se the magnifying glass tool from the tool*bo; and click m$ltiple times on the image to get the ma;im$m zoom. Fo$ can now see the individ$al pi;els. If the zoomed image appears bl$rred3 deselect Interpolate Foomed Images in the men$ Edit>Options>#ppearance.

Illustration "4: Gith a higher /oom5 indi+idual pi)els can $e distinguished.

volker.baecker@mri.cnrs.fr

&#!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer .he coordinates and the intensity val$e of the pi;el $nder the mo$se pointer are displayed at the bottom of the ImageJ window. Fo$ can $se the right mo$se b$tton to zoom o$t again. .o scroll the image hold down space*bar3 press the left mo$se b$tton and move the mo$se. Remark that the origin of the coordinate system is in the $pper left corner of the image with increasing coordinates from left to right and top to bottom. 'ave the image as a te;t image to the desktop and open it with a te;t editor or drop it on the ImageJ window. Fo$ see the image as a matri; of intensity val$es.

Illustration "6: The image as a matri) of intensity +alues.

5.2 +rig!tness and ,ontrast ad-%stment


,pen the image $c,ad(ust.tif. .he image is dark and the contrast is very low. ,pen the 6rightness and Contrast Ad=$ster from the men$ Image>#d(ust><rightness:Contrast or press .hift7C or r$n the 6!C*Ad=$ster from the 2ook$p .ables tool set.

volker.baecker@mri.cnrs.fr

&%!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration "8: The intensities are to lo& to distinguish details in the Illustration 19: image. The $rightness and contrast ad(uster.

Illustration 11: The image after the auto, ad(ustment.

Illustration 1": #fter the ad(ustment intensities $elo& 1 &ill $e displayed as $lac% and intensities a$o+e "3 as the "22.

1ress the #uto b$tton to make an a$tomatic ad=$stment. <ith *eset yo$ can go back to the original display. (se the fo$r sliders to ad=$st brightness and contrast man$ally. Remark that only the displayed intensities are changed3 the pi;el val$es remain $nchanged. 1ress the meas$re b$tton on the toolbo; or select the image and press Ctrl7m3 then change the brightness!contrast and meas$re again. Compare the val$es mean and Int-en3 which give the average and total intensity in the image. If yo$ canSt find mean or Int-en in the res$lts table3 open the dialog #naly/e>.et Measurements... and check Mean ;ray Balue and Integrated -ensity.

Illustration 11: The ImageJ results ta$le. 9ow does the ad=$stment workK <hen the image is displayed two points are stored together with the image. .he point Bmin3 4C and the point Bma)3 ma)IntensityC. All intensity val$es below min are displayed with the intensity zero3 all intensity val$es above ma) will be displayed with the intensity val$e ma)Intensity. 8al$es between min and ma) are mapped by the line e-$ation that is defined by the two points Bmin34C and Bma)3 ma)IntensityC. volker.baecker@mri.cnrs.fr &)!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer In the beginning when we opened the e;ample image3 min was 4 and ma) was &)) and the ma)Intensity is &)). 'ince this defines a line with the gradient 3 each intensity val$e is mapped to itself. After we applied the a$to ad=$stment3 min becomes & and ma) &/3 so pi;els that have the intensity &/ are displayed with the val$e &))3 pi;els that have the intensity &4 with the val$e 0%3 and so on. >ow look at the image in the $pper part of the 6TC window. <hat yo$ see there is the histogram of the image. ,n the ;*a;is are the intensity val$es from 4 to &)). ,n the y*a;is yo$ find the co$nt of pi;els in the image that have the intensity ;. <eSll come back to the histogram later when we talk abo$t thresholding. 5or the brightness and contrast ad=$stment it shows yo$ how many pi;els yo$ set to the ma; intensity and to zero. ,n the left yo$ find the min display val$e and on the right the ma) display val$e. .he line that is drawn in the histogram shows the mapping of the val$es between min and ma). If yo$ move the brightness slider to the right the whole line will move to the left and lower intensity val$es will be mapped to higher display val$es3 making the display brighter. If yo$ move the contrast slider to the right the gradient of the line increases so the intensity val$es closer together will be mapped to display val$es with a bigger distance. Fo$ can $se the set b$tton to enter the min and ma; val$e directly. If yo$ press apply3 the pi;el intensity val$es in the image will be changed to the val$es displayed. .he a$to ad=$stment will look at the histogram of the image and ad=$st the min and ma; val$es in a way that a small percentage of the pi;els become zero and ma)Intensity. 'ometimes this doesnSt yield the desired res$lts3 especially when the ob=ect is very small compared to the backgro$nd. In this case yo$ can make a selection on the image and the a$to ad=$ster will $se the histogram of the selection to comp$te the min and ma) val$es that are then applied to the whole image. (se the rectang$lar selection tool from the toolbo; to make a selection on the image and press the a$to b$tton. .ry this for different regions in the image.

Another way to ad=$st the display is the Gindo&&He+el ad(uster. In this case yo$ choose a middle val$e Bthe levelC and a range aro$nd the middle val$e Bthe windowC. If yo$ choose for e;ample le+el ) and &indo& &% yo$ get a min val$e of # and a ma) of &/.

5.3 .on linear display-ad-%stments


In the brightness and contrast ad=$stments in the last chapter3 intensity val$es are mapped to display val$es by a linear f$nction3 meaning small intensities are changed by the same factor as big val$es. In cases where very high and very low intensities sho$ld become visible a non* linear display ad=$stment is needed3 so that small val$es can become bigger witho$t sat$rating already big val$es.

volker.baecker@mri.cnrs.fr

&+!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 10: The lo& intensities are in+isi$le in the original image.

Illustration 12: # linear display ad(ustment ma%es lo& intensities +isi$le $ut saturates high intensities.

5.3.1 /amma correction


Instead of a linear f$nction we will map intensities to display val$es $sing a f$nction of the form .

Illustration 13: gamma I 9.0

Illustration 14: gamma I ".2

,pen the image cells.tif or cells&.tif. (se rocess>Math>;amma to ad=$st the image intensities $sing a gamma*f$nction. Fo$ can select the re+ie& checkbo; and try different val$es. <hen yo$ click o% the gamma f$nction is applied to the image3 i.e. the pi;el val$es are modified accordingly.

Illustration 16: The dialog for applying a gamma,correction. .he e;act f$nction $sed by this command isD

Illustration 18: The gamma, correction has $een applied to the image.

volker.baecker@mri.cnrs.fr

&/!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer f i =e
log i &))

&))

.his command in the men$ Math is there to modify the pi;el val$es of the image not to make a display ad=$stment. .o ad=$st the display witho$t affecting the pi;el val$es the macro H?ammaCorrection.oolI can be $sed. ImageJ provides a convenient way to r$n macros and pl$gins from a toolset. <e will install the tool on a new toolset3 so that it can be r$n by pressing a tool b$tton. 2ook at the rightmost b$tton on the ImageJ la$ncher window. Clicking on it allows to change the c$rrent tool*set.

Illustration 09: The $utton >> on the ImageJ launcher displays the list of a+aila$le toolsets 5irst we need to get the macro from the ImageJ website. (se 'elp>-e+. *esources... to open the developer reso$rces page on the ImageJ website. Click on Macro Tools. 'croll down to ;ammaCorrectionTool.t)t and click on the link. Fo$ sho$ld now see the macro code in yo$r web*browser B7onAt worry yo$ donAt need to $nderstand the code3 at least not right nowC. 'elect the macro te;t BctrlMaC and copy it into the system clipboard BctrlMcC. >ow go back to ImageJ. 5rom the toolset list Bclick on the rightmost b$tton to get itC select Toolset Creator.

Illustration 01: Creating a ne& toolset. :nter -isplay #d(ustments as the name of the new toolset and enter as the n$mber of tools. .he Toolset Creator is normally there to create toolsets from the pl$gins in the pl$gins men$. <e will =$st $se it to create a new toolset and we will overwrite the created content. >ormally yo$ wo$ld now enter information for each tool on the toolset. Fo$ can ignore this and press ok. Close the log window. <e will now open the code of the newly created toolset. 9old volker.baecker@mri.cnrs.fr &0!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer down the shift*key3 display the toolset*list and select -isplay #d(ustments. .he code of the toolset is now displayed in a te;t window. Replace the content with the content of the macro. .o do so click in the te;t window3 press ctrlMa to select all and ctrlMv to paste the code of the macro that we copied into the clipboard before. 'ave the changed file $sing the =ile men$ from the te;t window Bor ctrlMsC. .o $pdate the display3 reselect the -isplay #d(ustments toolset again. Fo$ sho$ld see a b$tton with the ?reek letter gamma. ,pen the image cells.tif or cells&.tif again or $se =ile>*e+ert to reload it. >ow select the gamma*correction tool by pressing the b$tton with the letter gamma and click in the image. .he gamma f$nction is displayed on the image and yo$ can change the val$e of gamma by moving the mo$se. <hen yo$ have fo$nd a good val$e $se ctrlMshiftMa to get rid of the f$nction display in the image. 6e caref$l to not click into the image again3 before yo$ selected another tool. In contrast to the command above this macro only changes the display3 not the pi;el val$es.

Illustration 0": The gamma function is displayed on the image. Fo$ might have noticed that $sing the same gamma val$e with the 1rocessingOMathO?amma command and with the ;ammaCorrectionTool macro yields different res$lts. .his is beca$se the later $ses a different gamma f$nctionD i f i = &)) &))

5.3.2 0n!ance ,ontrast


.he enhance contrast tool3 that can be fo$nd $nder rocess>Enhance Contrast3 has three different f$nctions. <hen neither >ormalize nor :-$alize is selected3 the display is ad=$sted in a way3 that the given n$mber of pi;els becomes sat$rated. In this case the intensity val$es in the image are not changed. <hen >ormalize is selected3 a contrast stretching or normalization is done. .he third f$nction is the histogram e-$alization.

volker.baecker@mri.cnrs.fr

&"!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 01: The enhance contrast dialog.

*!$!#! ;ormalization or contrast stretching


.he normalization stretches the range of intensity val$es3 so that the given percentage of pi;els becomes sat$rated. After a normalization the min and ma; val$es for the given image type will be present in the image. If for e;ample the minim$m and ma;im$m val$e in an image are 4 and &4 the val$es can be mapped to $se the whole range between 4 and &)) byD iJ I ?i,imageCmin : ?imageCma) > imageCmin@@ K rangeCma) iJ?19@ I ?19,19@ : ?"9,19@ K "22 I 9 iJ?"9@ I ?"9,19@ : ?"9,19@ K "22 I "22 iJ?12@ I ?12,19@ : ?"9,19@ K"22 I 1"4.2 9owever this wo$ld be very sensible to o$tliers. A better way is to determine imageCminJ and imageJma;A so that a given percentage of pi;els is below imageJminA and above imageCma)J.

Illustration 00: 'istogram $efore normali/ation.

Illustration 02: 'istogram after normali/ation.

volker.baecker@mri.cnrs.fr

#4!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 03: The image after histogram normali/ation. (sing the enhance contrast tool with the normalize option has the same effect as $sing it witho$t the normalize option and then pressing apply on the brightness and contrast ad=$ster.

*!$!#!# 7istogram 8%"alization


In the histogram e-$alization each intensity val$e i is replaced with the the s$m of the histogram val$es for all intensities $p to i Bincl$ding h?i@ itselfC. .he res$lt is then normalized to the min and ma) intensities of the image type. If yo$ check e-$alize histogram in the enhance contrast dialog3 the other inp$t in the dialog is ignored. If yo$ hold down alt3 the classical histogram e-$alization will be e;ec$ted. ,therwise a modified version3 $sing the s-$are root of the histogram val$es will be $sed. If a selection e;ists on the image3 the calc$lation will be based on the histogram of the selection only.

volker.baecker@mri.cnrs.fr

# !"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 04: The input image. Illustration 06: The histogram of the input image.

Illustration 08: The image after histogram eLuali/ation in the Illustration 29: The histogram sLuare root +ersion. of the image after histogram eLuali/ation in the sLuare root +ersion.

Illustration 21: The image after histogram eLuali/ation in the Illustration 2": The histogram standard +ersion ?alt %ey do&n@. of the image after histogram eLuali/ation in the standard +ersion ?alt %ey do&n@. 9istogram e-$alization a$gments the local contrast and is most $sef$l when ob=ects and backgro$nd contain high and low intensities3 as for e;ample in brightfield microscopy. Compare the res$lts of a linear ad=$stment a gamma ad=$stment and the histogram e-$alization on the image cells".tif. .ry the histogram e-$alization on the image roots.tif. volker.baecker@mri.cnrs.fr #&!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

5.4 ,!anging t!e palettes


<e will now change the display of o$r image by mapping the intensity val$es to colors. .his is done by the $se of look$p tables. A look$p table is a table that maps the &)) intensity val$es to &)) arbitrary colors. 'ince colors are e;pressed by the proportion of the three basic colors red3 green and bl$e3 an entry that wo$ld map the intensity &)) to white wo$ld for e;ample beD &)) *O &))3 &))3 &)) .o map the intensity 4 to red the look$p*table entry wo$ld beD 4 *O &))3 4 3 4 'elect the Hoo%up Ta$les tool set. Click on the H!T b$tton and open the *ain$o& *;< l$t. Fo$ see an image that shows the mapping of the intensity val$es to the colors. :ach intensity val$e is represented by a col$mn with the width of pi;el3 painted in the corresponding color. Can yo$ tell in which color the intensity val$e &44 is displayedK

Illustration 21: # graphical representation of the loo%up, ta$le. ?o to the men$ image>color>sho& lut. Above the color table yo$ see how each color of the l$t is mi;ed from the red3 green and bl$e components.

Illustration 20: The red5 green and $lue components for each inde) of the loo%up, ta$le. If yo$ click on the list b$tton3 yo$ get the look$p*table in n$merical form. <hat are the R?6* components of the intensity 44K

volker.baecker@mri.cnrs.fr

##!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 22: art of the loo%up,ta$le. ,pen the image cells and click on *ain$o& *;< l$t again. <hen images are opened the look$p*table will be applied to the active image. .ry different look$p tables.

Illustration 23: The rain$o& *;< loo%up, ta$le applied to an image.

Illustration 24: The grey loo%up,ta$le applied to an image.

Illustration 26: The 1, 1," *;< loo%up ta$le applied to an image.

.he look$p table 'iHo is $sef$l to ad=$st the display of o$r image. 4 will be displayed in bl$e3 &)) in red and val$es in between will be displayed in gray. Can yo$ describe how this look$p table looks likeK

Illustration 28: The hilo loo%up, ta$le. Apply it to the image and ad=$st the brightness and contrast in a way that most of the backgro$nd is zero and only a small portion of pi;els becomes sat$rated.

volker.baecker@mri.cnrs.fr

#%!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 39: !se the hilo lut to ad(ust $rightness and contrast.

Illustration 31: The $rightness and contrast ad(ustment has $een applied and the lut has $een changed $ac% to grays.

?o to image>color>edit>lut or press the Edit H!T b$tton from the 2ook$p .ables tool set. Change the look$p table in a way that 4 will be displayed in green3 &)) in yellow and val$es between 44 and &4 in different shades of red3 becoming lighter with higher intensity. 'ave the look$p table $nder a new name3 apply it to the image and ad=$st the <&C again.

Illustration 3": The lut editor.

Illustration 31: The ne&ly created lut applied to an image.

,pen the M*IHoo%upTa$leTool $nder lugins>Montpellier *IO Imaging. .he tool allows yo$ to see the look$p tables and to apply them either to the active image or to all open images. Remark that the e;ternal look$p tables listed in the tool m$st be in the folder Clut.

volker.baecker@mri.cnrs.fr

#)!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 30: The M*I loo%,up ta$le tool. Another convenient way to access all look$p tables is to tear off the Image>Hoo%up Ta$les men$ by $sing lugins>!tilities>Control anel.

Illustration 32: Menus can $e %ept on the screen using the Control anel.

5.5 $1erlay of m%ltiple c!annels


A common task in fl$orescent microscopy is to create a combined image from the different channels. .he task consists in creating an overlay of the different channels3 in ad=$sting the display of each channel and event$ally in transferring the settings from one overlay to another3 to allow a vis$al comparison. In ImageJ this can be accomplished $sing so called volker.baecker@mri.cnrs.fr #+!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer hyperstacks. 9yperstacks allow to work with m$ltidimensional images. .he different dimensions are the ;3y and z a;is3 the time and the channel Brepresenting the color or wavelengthC. ,pen the images dapi 1.tif and rhod 1.tif from the folder 11 > o+erlay.

Illustration 33: The first channel contains the dapi staining.

Illustration 34: The second channel contains the rhodamine staining.

R$n the Merge Channels... command from the men$ Image>Color.

Illustration 36: -ialog to create hyperstac%s5 i.e. multidimensional images. 'elect Create Composite and press o%. Fo$ now see an overlay of the two channels. ,pen the Channels dialog from the men$ Image>'yper.tac%s and the 6rightness and Contrast Ad=$ster by pressing shift7c on the image. <ith the slider on the bottom of the stack window yo$ select the channel to manip$late. If yo$ move it to the right the histogram in the 6rightness and Contrast tool becomes green indicating that the green channel is selected. If yo$ move the slider back to the left the histogram becomes red again. Fo$ can change the colors by applying look$p tables from the H!T menu. Ad=$st the display of the two channels volker.baecker@mri.cnrs.fr #/!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer $sing the <&C tool. Remark that the display ad=$stment of one channel remains when yo$ change to the other channel. Fo$ donAt need to press the apply b$tton. Fo$ can save a hyperstack and reload it witho$t loosing the display ad=$stment. 'ave it in tif format $sing =ile>.a+e or =ile>.a+e #s. Close the hyperstack window and reload the saved file $sing =ile>Open. If yo$ want to create a snapshot of the overlay click on the More b$tton in the Channels window BImage>'yperstac%s>Channels Tool...C and select Con+ert to *;<.

volker.baecker@mri.cnrs.fr

#0!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 38: The o+erlay of t&o channels.

Illustration 49: The channel dialog allo&s to sho& and hide selected channels.

Illustration 41: Illustration 4": The <&C tool Changing the &or%s on the selected channel selected channel automatically and displays the changes the histogram in the channel on &hich color of the the <&C tool selected channel. &or%s. Create a second hyperstack from the images dapi 2 and rhod 2. Imagine that yo$ want to compare the intensities in the two images. .o be able to do this yo$ need to set the same display ad=$stments for both images. 'elect the red channel in both images. Ad=$st the display for the first image Bfor e;ample by pressing reset followed by a$toC3 then press the b$tton set. 'elect ropagate to all open images and press o%. .he display of the red channel in the volker.baecker@mri.cnrs.fr #"!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer second image has been ad=$sted in the same way as the one in the first image now. 'elect the green channel in both images and repeat the proced$re.

Illustration 41: The display settings can $e propagated to all open images ?same channel@.

Illustration 40: The display settings ha+e Illustration 42: The display settings ha+e $een optimi/ed for the first image. $een transferred to the second image. Create an overlay from the three images $"*= Cgem-eltaC"C$lue.tif3 $"*= Cgem-eltaC"Cgreen.tif and $"*= Cgem-eltaC"Cred.tif and ad=$st the display.

*!*! Aligning channels


Fo$ can $se the composite display to align two channels. ,pen the images dapi %.tif and Rhod %.tif and create a hyperstack. As yo$ can see the to channels have been shifted against each other. (se ctrlMa to select the image with the first channel selected3 then press ctrlM; to c$t the channel and ctrlMv to paste it again. Fo$ can now move the image of the first channel aro$nd. Correct the alignment then select a rectangle aro$nd the not empty area of the image and call ImageOCrop to get rid of the border.

*!*!# </erlay of /ol"me images


<e will now display an image with )% z*slices and # channels. ,pen the images 7api.stk3 the ?t$b.stk and the Actine.stk. Create the Composite image $sing Image>Color>*;< Merge... volker.baecker@mri.cnrs.fr %4!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer Fo$ now have a window with two sliders3 one to select the channel and one to select the slice in the stack.

Illustration 43: # hyperstac% of a +olume image &ith three channels. .wo create a composite with more than fo$r channels yo$ can $se the command Image>'yperstac%s>.tac% to 'yperstac%.

Illustration 44: Gith the .tac% to 'yperstac% command hyperstac%s &ith more than 0 channels can $e created.

5." .oise s%ppression


,pen the image plant,noise.tif. .he image contains a high level of noise. Uoom into the image. .he backgro$nd sho$ld be homogeneo$s3 b$t it contains a random distrib$tion of intensities. .he same random distrib$tion is added to the signal.

volker.baecker@mri.cnrs.fr

% !"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 48: i)el +alues in $ac%ground and o$(ect are changed in a random manner. Illustration 46: #n image &ith a high le+el of noise. .here are different possible so$rces of noise in an image. ,ne kind of noise stems for e;ample from the digital camera. In the camera incoming photons are transformed into an electrical charge by a charge co$pled device or CC7. 9owever some electrons are created within the CC7 randomly. Another so$rce of noise is the random emission of photons from yo$r specimen3 which is a -$ant$m physical phenomenon. .he noise can pose a problem for the analysis of the image3 for e;ample in the separation of the ob=ects from the backgro$nd. If we have a light ob=ect on a dark backgro$nd we co$ld for e;ample look for the lowest intensity val$e in the ob=ect and separate the ob=ect from the backgro$nd by searching all pi;els that have an intensity val$e higher than this threshold val$e. 9owever the noise has changed the intensities in the backgro$nd and in the ob=ect3 so that there are very high intensities within the backgro$nd and very low intensities in the ob=ect. <e might have to pre*process o$r image to red$ce the dist$rbing effect of noise.

*!,! Con/ol"tion filter

5.6.1.1 Mean filter


An evident way to smooth o$r image and to red$ce the impact of the noise is to replace each pi;el in the image by an average of the intensities in its neighborhood. .his is called a mean filter in ImageJ. Fo$ can find it $nder 1rocessO5iltersOMean. Fo$ have to enter the radi$s of the neighborhood in which the average for each pi;el is comp$ted. If the radi$s is the neighborhood has a size of #;# pi;els. R$n the filter with different val$es for the radi$s and compare the res$lts by zooming into the images. .o r$n a mean filter with the radi$s yo$ can $se 1rocessO'mooth or 'hiftM'.

volker.baecker@mri.cnrs.fr

%&!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 69: #n image containing noise.

Illustration 61: The image filtered &ith a mean filter of radius 1.

,pen the image rectangle. Fo$ see a filled rectangle with intensity val$es &)) on a black backgro$nd. <hat will be the intensity val$es of the edge and corner pi;els after applying a mean filter with radi$s K

Illustration 6": # &hite rectangle.

Illustration 61: The &hite rectangle after applying a mean filter of radius 1.

Compare the histograms of the original plant image and the plant image after a mean filter has been applied. (se a large radi$s3 for e;ample ). 1ress h on the image or $se AnalyzeO9istogram to display the histograms of the images. (se the brightness and contrast ad=$ster to make the backgro$nd as dark as possible and the plant as light as possible.

volker.baecker@mri.cnrs.fr

%#!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 60: .eparation of o$(ect and $ac%ground is impossi$le in the noisy image.

Illustration 62: The separation $ecomes possi$le after application of a mean filter.

Illustration 63: The histogram of the noisy image.

Illustration 64: The histogram after a mean filter of radius 12 has $een applied.

A mean filter can be applied in the following wayD 5or radi$s r create a matri; of size > L &rM ; &rM filled with val$es !>. .he matri; is called the kernel of the filter. Move the center of the kernel across the image. 5or each positionD o M$ltiply each matri; element with the corresponding intensity val$e and calc$late the s$m of the res$lts. o In the res$lt image replace the intensity of the c$rrent pi;el with the calc$lated res$lt. A generalization of this techni-$e is called convol$tion. A convol$tion is an operation that calc$lates the overlap of two f$nctions. In the general case the kernel and the image can have infinite size. Instead of simply calc$lating the average3 we can calc$late a weighted average by $sing different val$es in the matri;. Convol$tion filters can not only be $sed for smoothing b$t also for other p$rposes3 for e;ample to enhance edges. .o apply a convol$tion filter go to 1rocessO5iltersOConvolve and enter the matri; in the dialog. .o create a mean filter of radi$s p$t in a #;# matri;3 in which all elements are . volker.baecker@mri.cnrs.fr %%!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer >ormally we wo$ld have to $se !"3 b$t we can select the Hnormalize kernelI option and the comp$ter will do this for $s.

Illustration 66: #pplying a mean filter $y doing a con+olution. Apply the convol$tion filter. Compare the res$lt with the res$lt from the mean filter. .o test whether the res$lts are absol$tely identical yo$ can s$btract one res$lt image from the other. If the images were identical the res$lt image m$st be all black. (se 1rocessOImageCalc$lator to s$btract one image from the other. Apply the hilo l$t to the res$lt to see if intensities other than 4 are present.

Illustration 68: .u$tracting one image from another image. .he smoothing red$ces the deranging effect of noise b$t in the same time bl$rs the ob=ect3 so that less details are visible.

5.6.1.2 Gaussian blur filter


A ?a$ssian bl$r filter is similar to the mean filter3 b$t instead of $sing $niform weights in the kernel3 the weights are the val$es of a normal distrib$tion3 also called ?a$ssian distrib$tion. volker.baecker@mri.cnrs.fr %)!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer A normal distrib$tion is $sed to describe random processes. .hrow a coin 44 times and co$nt the times the head is $p. Repeat this 444 times and draw a histogram of the o$tcomes. Most of the time yo$Sll get val$es aro$nd )43 res$lting in high bars aro$nd )4 in the histogram. .he case that in 44 throws only head t$rns $p will not occ$r very often. .he same will be the case for 44 heads in 44 throws. If yo$ connect the top points of the bars yo$ get a c$rve that looks like a normal distrib$tion and if instead of throwing the coin 444 times yo$ throw it an infinite n$mber of times yo$Sll get a normal distrib$tion. A two dimensional normal distrib$tion has the form of a bell.

Illustration 89: # gaussian function. In older versions of ImageJ the ?a$ssian 6l$r filter had the radi$s as a parameter. In newer versions Bfrom .#0-C the parameter is sigma3 the standard deviation of the distrib$tion. .o get the same res$lts the val$es in the old version have to be m$ltiplied by &.). ,pen the file ;aussian.t)t. 9ere yo$ see the val$es of a normal distrib$tion. 9ow does it look like as an imageK ,pen the file as an image by $sing =ile>Import>Te)t Image. Apply the ice l$t. >ow go to #naly/e>.urface lot or $se the Interacti+e 1- surface plot pl$gin B1l$ginsO#7C to get an impression of the #7 form. 6eca$se of the discrete nat$re3 what yo$ see looks less smooth then the real form. 6esides the real c$rve never drops down to zero3 b$t val$es will be very low o$tside the central area so that we can $se a tr$ncated ?a$ssian as an appro;imation.

Illustration 81: Con+olution %ernel for a ?truncated@ gaussian $lur filter.

Illustration 81: The %ernel as surface plot. Illustration 8": The %ernel as image.

volker.baecker@mri.cnrs.fr

%+!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 80: The %ernel as a surface plot created &ith the Dinteracti+e 1surface plotE plugin. Apply the ?a$ssian bl$r filter with sigma .& from rocess>=ilters>;aussian $lur to the rectangle image and compare the res$lt with the res$lt of the mean filter with radi$s #.

Illustration 82: Mean filter &ith radius 1 applied to the rectangle image.

Illustration 83: ;aussian $lur filter &ith sigma 1." applied to the rectangle image.

Altho$gh both images are bl$rred3 the res$lt from the ?a$ssian filter looks more like the original form. .he ?a$ssian filter while removing noise as well3 keeps edges better. Apply a ?a$ssian bl$r filter with a sigma of + and a Mean filter of radi$s ) to the image roots and compare the res$lts.

volker.baecker@mri.cnrs.fr

%/!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 84: The roots image.

Illustration 86: # mean filter of radius 12 has $een applied to the image.

Illustration 88: # gaussian $lur filter of radius 3 has $een applied to the image.

,pen the plant*noise image. ,pen the convol$tion tool and load the ?a$ssian.t;t into it. R$n the convol$tion filter on the image.

Illustration 199: The plant image after the con+olution &ith the gaussian %ernel has $een applied.

volker.baecker@mri.cnrs.fr

%0!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

5.6.1.3 Edge enhancing filter


Create a convol$tion filter of radi$s . 1$t * in the first row and in the last row3 and & in the middle row. Apply it to the rectangle image and to the roots image. .o see the effect of the filter3 create an overlay of the original and the filtered image3 by $sing Image>Color>*;< Merge. 1$t the filtered image in the red channel3 the original image in the green channel and choose none for the bl$e channel.

Illustration 191: The con+olution %ernal for an edge enhancing filter.

Illustration 19": *;<, merge of the original image and the result after application of the filter.

Illustration 191: -etail of the rg$,merge of the roots image and the result from the con+olution that detects hori/ontal lines. 9ow will a filter that enhances vertical or %) degree edges look likeK volker.baecker@mri.cnrs.fr %"!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

*!,!# Rank 3ilter


Rank filters are another class of filters. Again we look at a neighborhood of radi$s r for each pi;el. 6$t this time the intensity val$es are sorted and the pi;el is replaced with the val$e in a specific position. If we $se the middle position we get a median filter. If we $se the first position we get a minim$m filter and $sing the last position we get a ma;im$m filter. ,pen the image plant,sp,noise.tif. Uoom in to the image. Fo$ see that in this case the noise consists of the addition of white and black pi;els to the image. .his kind of noise is called salt*and*pepper noise.

Illustration 190: The plant image &ith salt,and, pepper noise.

Illustration 192: .alt,and, pepper noise consisits of the addition of &hite and $lac% pi)els to the image.

Apply a median filter of radi$s # from 1rocessO5iltersOMedian to the image. Compare the res$lt with the res$lt from the mean filter. .he median filter is more effective in removing salt*and*pepper noise.

volker.baecker@mri.cnrs.fr

)4!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 193: # median filter effecti+ely remo+es salt,and,pepper noise.

Illustration 194: # mean filter is not so effecti+e on salt,and,pepper noise.

Fo$ can r$n a median filter with radi$s $sing rocess>Moise>-espec%le. In rocess>Moise>*emo+e Outliers3 yo$ find a selective median filter3 that replaces a pi;el by the median in the neighborhood if the val$e of the pi;el differs more than a threshold val$e from the median. (se it to remove the dark and light components of the salt and pepper noise separately.

*!,!$ 3iltering in the fre%"ency domain


In its normal representation an image consists of an intensity val$e for each spatial coordinate. <e call this the spatial domain. .he same information can be represented in other ways. 'ome operations are easier to apply with a different representation. ,ne important representation is to transform the image into the BspatialC fre-$ency domain. 9ere each val$e represents the fre-$ency of change of the intensity val$e. 2arge str$ct$res have a low fre-$ency3 small repeating str$ct$res have a high fre-$ency. .he 5o$rier transform transforms the image from the spatial to the fre-$ency domain. .he transform is based on the fact that each signal can be presented as a s$m of harmonic BsinoidC f$nctions of different phase and amplit$de. .he res$lt is an image of comple; n$mbers that can be divided in a real part3 the power spectr$m and an imaginary part3 the phase information. 5rom the res$lt the original image can be reconstr$cted witho$t any loss by applying the inverse 5o$rier transform. (s$ally only the power spectr$m is shown3 since it contains most of the interesting information. 9owever to reconstr$ct the original image3 both3 the power spectr$m and the phase image are needed. .here e;ists an efficient way to comp$te a 5o$rier .ransform. It is called the 5ast 5o$rier .ransform or 55.. <e can $se the 5o$rier .ransform to filter o$r image in the fre-$ency domain. ,ne reason why the fre-$ency domain is interesting is beca$se we will be able to recognize fre-$encies that appear as cl$sters vis$ally. <e can $se this to filter o$t fre-$encies that correspond to ob=ects or patterns of different size in the image. 2ow fre-$encies will be displayed in the middle of the power spectr$m and the higher the fre-$encies are3 the bigger is their distance to the center. If we filter o$t the low fre-$encies in the middle3 we apply a high pass filter. .his can be $sed as an edge enhancing filter since the edges information is in the high fre-$encies. volker.baecker@mri.cnrs.fr ) !"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer If we filter o$t the high fre-$encies3 we apply a low pass filter. .his has a smoothing effect on the image3 since the fine details have a high fre-$ency. Another reason why the 5o$rier .ransform is important is beca$se we can calc$late a convol$tion more efficiently in the 5o$rier 7omain. .he Convol$tion .heorem states that a convol$tion in the spatial domain is e-$ivalent to a m$ltiplication in the fre-$ency domain. ,pen the image ierre.tif. Apply the 5o$rier transform from rocess>==T>==T.

Illustration 196: #n image.

Illustration 198: The po&er spectrum of the image.

Fo$ can $se the l$t tool to make visible different cl$sters of fre-$encies. 7o yo$ see the two cl$sters in the $pper left and lower right -$adrant. 7raw a selection aro$nd the first. .hen add a selection aro$nd the second by pressing shift when yo$ start the selection. Fo$ can release the shift key once yo$ started the second selection. >ow r$n the fill command from Edit>=ill or press CT*H7f.1 <e have set the intensities in the selection to zero and in this way s$ppressed the corresponding fre-$encies. Apply the inverse 5o$rier transform from rocess>==T>In+erse ==T. At first look the image doesnSt seem to have changed. Uoom in on the image and on the res$lt image behind the ear. Fo$ see that the lines of the window blinds have disappeared in the filtered image3 since we s$ppressed the corresponding fre-$encies.

5ill act$ally $ses the c$rrent foregro$nd color. 7o$ble click on the color picker tool and set the c$rrent foregro$nd color to black.

volker.baecker@mri.cnrs.fr

)&!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 119: =illing parts of the po&er spectrum image &ith the $ac%ground color filters out the corresponding freLuencies.

Illustration 111: -etail of the original image.

Illustration 11": -etail of the filtered image.

'$btract the filtered image from the inp$t image to see what e;actly has been filtered o$t. Instead of b$ilding the difference yo$ can as well go back to the power spectr$m and fill the inverse of the mask.

Illustration 111: The difference of the original image and the filtered image. (se rocess>==T>*edisplay o&erspectrum to redisplay the original power spectr$m. .ry to smooth the plant*noise image. <hich fre-$encies do yo$ have to filter o$tK

volker.baecker@mri.cnrs.fr

)#!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 110: !sing clear instead of fill lets the corresponding freLuencies pass.

Illustration 112: The original image.

Illustration 113: The image after filtering in the freLuency domain.

.ry to enhance the edges in the roots image. Always b$ild the difference of the original image and the filtered image to see what e;actly has been filtered o$t.

Illustration 114: The roots image after a high pass filter has $een applied.

Illustration 116: The difference of the original and the filtered image.

volker.baecker@mri.cnrs.fr

)%!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer If we set everything3 e;cept for a ring3 to zero in the power spectr$m3 we will filter o$t all fre-$encies higher then a certain val$e and all fre-$encies lower then a certain val$e. .his is called a band*pass filter3 since the only fre-$encies that pass are those within the ring. .ry it for e;ample with the image pierre.tif. 7raw a circ$lar selection and then remove a second circle from within the selection by pressing the alt key while making the second selection. (se the I from the toolbo; to invert the selection and apply fill from the conte;t men$.

Illustration 118: -efining a $andpass filter.

Illustration 1"9: The $andpass filter applied to an image.

volker.baecker@mri.cnrs.fr

))!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

5.2 +ac3gro%nd s%btraction


,pen the image nuclei,rhod.tif. Apply the hilo lut. As yo$ see no pi;els become bl$e3 meaning that the backgro$nd is not zero. 'ince this image is from fl$orescent microscopy3 normally the backgro$nd sho$ld be black3 in reality however there is some intensity in the backgro$nd. In this e;ample the backgro$nd is low and3 e;cept for the noise3 homogeneo$s. A high backgro$nd can make it harder to clearly disting$ish ob=ects. 5$rthermore if we want to compare intensities between images with different backgro$nd levels we have to compensate for the backgro$nd. (se the 6TC tool to clearly disting$ish a backgro$nd region. 7raw a line selection on the backgro$nd and create a profile plot $sing AnalyzeO1lot profile or select the image and press k. .he profile plot shows the intensity val$es along the line selection. Fo$ see that the val$es vary somewhere between and " d$e to noise and that the average is somewhere aro$nd #. 1ress the meas$re b$tton on the toolbo; or select the image and press ctrlMm to get the e;act mean val$e.

Illustration 1"1: The $ac%ground should $e $lac%5 $ut contains some intensity in reality.

Illustration 1"": The line plot displays the intensities along the selected line.

?o to 1rocessOMathOs$btract and s$btract the mean backgro$nd val$e from the image. (se the R b$tton from the toolbo; to get back the line selection and create the profile plot again. .his time the val$es go down to zero. .he command lugins>*OI><; .u$traction from *oi volker.baecker@mri.cnrs.fr )+!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer s$btracts the ne;t integer val$e3 above the mean intensity within the selection3 from the image.

Illustration 1"0: The line plot goes do&n to /ero no&. Illustration 1"1: The image after the +alue 1 has $een su$tracted from each pi)el +alue.. Another way to get rid of the backgro$nd is to divide the image by the average backgro$nd val$e. Most backgro$nd val$es will be afterwards and yo$ can s$btract from the image to set them to zero. .ry it with rocess>Math>di+ide.

Illustration 1"2: The image after it has $een di+ided $y 1.1 and 1 has $een su$tracted. .here is an a$tomatic operation that tries to find and s$btract the backgro$nd. ,pen the vis$al scripting pl$gin from lugins>Montpellier *IO Imaging>M*I Bisual.cripting. ?o to Operations>#ll and search the 5ind and '$btract 6ackgro$nd operation. 7rag it from the list and press the ,ptions b$tton B,C. 'et the n$mber of iterations to . R$n the operation by pressing the b$tton in the middle. .he operation searches for the highest intensity val$e aro$nd the intensity minima and s$btracts it from the image. volker.baecker@mri.cnrs.fr )/!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 1"3: The find and su$tract $ac%ground operation.

Illustration 1"4: The options dialog of the operation.

Illustration 1"6: The image after the find and su$tract $ac%ground operation has $een applied.

*!-! Inhomogeneo"s backgro"nd


,pen the image root".tif. 7raw a vertical line on the backgro$nd again and create the profile plot. As yo$ see this time the backgro$nd baseline is not constant. .he image is darker in the top area and lighter in the bottom area. Meas$re the mean and s$btract it from the image. Create the profile plot again. Fo$ see that3 altho$gh the backgro$nd val$e is lower now3 the gradient is still present.

volker.baecker@mri.cnrs.fr

)0!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 119: The line plot re+eals a gradient from the top to the $ottom of the image.

Illustration 1"8: #n image &ith an inhomogeneous $ac%ground.

Illustration 111: #fter su$traction of the a+erage $ac%ground intensity the gradient is still present.

Apply the operation rocess>.u$tract <ac%ground to the image and create the profile plot. .he gradient has disappeared. .he command $ses a rolling ball algorithm that3 ro$ghly described3 moves a sphere along the image and considers intensity val$es o$tside the radi$s to be backgro$nd. In this way the local information is taken into acco$nt.

Illustration 11": The options dialog of the su$tract $ac%ground command. Illustration 111: The su$tract $ac%ground command remo+es the gradient using a rolling $all algorithm. ,ne very elegant way to remove backgro$nd is to make an image of the empty scene along with the image of the specimen. ,ne can than divide the specimen image by the backgro$nd image and m$ltiply the res$lt with the mean intensity in the backgro$nd image . .his is often volker.baecker@mri.cnrs.fr )"!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer possible in microscopy and the techni-$e is called flat field correction. If it is not possible to take the HemptyI image we can sim$late the process by applying a very large filter that will remove the ob=ect from the image. <e then have to divide the res$lt from the original image and m$ltiply with the average intensity of the filtered image. .his can be done with rocess>=ilters> seudo =lat =ield. 'elect the keep flat field bo; to see the generated backgro$nd image. 2ook at the profile plot from the res$lt. Again the gradient has disappeared. .he 1se$do 5lat 5ield correction applies a mean filter to the image. Fo$ can do the same thing $sing other filters. .ry a ?a$ssian bl$r filter for e;ample.

Illustration 110: The pseudo flatdield correction options dialog.

Illustration 114: The line plot of the generated $ac%ground.

Illustration 112: The image after pseudo flatfield correction.

Illustration 113: The generated $ac%ground that is su$tracted from the image.

Illustration 116: Hine plot after pseudo flatfield correction. The gradient has disappeared.

volker.baecker@mri.cnrs.fr

+4!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

5.4 Increasing t!e apparent s!arpness


,pen the image hst&.tif from the folder Hcells in str$ct$resI. Uoom in & or # times. .he image appears somewhat bl$rred or $nsharp. 7$plicate the image with the d$plicate b$tton from the tool bo; and apply a ?a$ssian bl$r with sigma 4.0. M$ltiply the res$lt with the factor 4.+ and s$btract the res$lt from the original image. .his techni-$e is called $nsharp masking. Fo$ can $se rocess>=ilters>!nsharp Mask to do it in one step.

Illustration 118: The image appears some&hat unsharp or $lurred.

Illustration 109: #fter applying the unsharp mas% filter the image appears less $lurred.

,! &egmentation
'egmentation is the process of separating the ob=ects from the backgro$nd and from one another. .he simplest way of segmentation is based on the difference in the intensities of ob=ects and backgro$nd. ,ne looks for a minim$m and ma;im$m intensity val$e3 so that all pi;els belonging to the ob=ects one is interested in have intensities between min and ma; and all other pi;els have intensity val$es below min or above ma;. .he res$lt of a segmentation is often represented as a binary mask. A binary mask is an image that contains only two val$es. .he first val$e signifies that the pi;el belongs to the backgro$nd and the second signifies that a pi;el belongs to the ob=ect. In ImageJ the val$es 4 and &)) are $sed. ,nce we created a masked3 we can combine it with the original image3 for e;ample to s$ppress everything b$t the ob=ects we are interested in. Another way of presenting the res$lt of a segmentation is a selection. .he selection represents the borders of the ob=ects we are interested in. A selection itself is not an image. ImageJ stores the selection together with the image. A selection is called a region of interest or R,I in ImageJ. <e can t$rn a mask into a selection and vice versa and $se the representation the most practical for a given task. A selection can be created from a mask with the help of the magic wand or tracing tool. ?iven a selection3 a mask can be created by $sing fill on the mask3 then inverting the mask and $sing clear. .he command Edit>.election>Create mas% can be $sed to create a mask from a selection in one step. .he command Edit>.election>Create .election can be $sed to create a selection from a mask or from an image on which the lower and $pper threshold are set in one step.

".1 Man%al t!res!old selection


.he threshold val$eBsC can be either chosen man$ally or a$tomatically by an algorithm. .he most simple a$tomatic thresholding algorithms try to find a threshold that divides the histogram in a meaningf$l way. volker.baecker@mri.cnrs.fr + !"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer ,pen the image plant.tif. ,pen the threshold ad=$ster from Image>#d(ust>Threshold or click shiftMt on the image. Fo$ can choose between three modes in the threshold tool. .he first displays selected pi;el in red and pi;els not selected with their original intensities. .he second displays the mask that will be the res$lt after applying the threshold3 i.e. backgro$nd in white and ob=ects in black. In the third mode3 selected pi;els are displayed with their intensities3 pi;els below the lower threshold are displayed in bl$e and pi;els above the $pper threshold are displayed in green.

Illustration 101: The threshold ad(uster.

Illustration 10": Illustration 101: Illustration 100: O$(ect O$(ect red5 O$(ect $lac%5 grayle+els5 $ac%ground $ac%ground $ac%ground $lue $lac%. &hite. ?$elo& first threshold@ and green ?a$o+e second threshold@ .

Ad=$st the threshold to select the plant. .he wand tool works together with the threshold tool. 'o if yo$ want to select the plant3 there is no need to create the mask. (se the wand tool to select the plant. (se the alt key to keep o$t the two holes between the leaves. Fo$ can add to a selection by $sing shift and s$btract from a selection by $sing alt. Alternatively yo$ can $se Edit>.election>Create .election after yo$ changed the lower and $pper threshold with the threshold ad=$ster. In contrast to the create selection command3 $sing the wand tool allows to select one separated ob=ect in an image containing m$ltiple ob=ects. If yo$ press the meas$re b$tton on the toolbo; or the m key on the image3 yo$ get a res$lt table with meas$rements of the selection.

volker.baecker@mri.cnrs.fr

+&!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 103: *esults ta$le &ith the measurements from the selection. Illustration 102: .election created &ith the threshold ad(uster and the &and tool. Remove the selection by clicking on the > b$tton in the toolbo;. R$n the 1article Analyzer to meas$re all ob=ects with intensities between the selected thresholds. (se the Apply b$tton if yo$ want to create a mask.

Illustration 104: The particle analy/er. Fo$ can filter o$t ob=ects by their size and circ$larity and yo$ can create a mask image or an o$tline image containing the conto$rs of the meas$red ob=ects. In the later image the ob=ects will be n$mbered3 as well. Fo$ can choose to e;cl$de ob=ects to$ching the image borders and to incl$de or not incl$de holes in the ob=ects in the mask.

volker.baecker@mri.cnrs.fr

+#!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 106: # mas% for the plant image.

Illustration 108: #n outline of the plant created &ith the particle analy/er.

Fo$ can config$re the val$es that will be meas$red by the 1article Analyzer $nder #naly/e>.et Measurements or $nder Options>Measurements on the toolbo;. 9ere yo$ can as well config$re a redirect image. In this way yo$ can $se a mask b$t the intensities will be meas$red in the redirect image3 for e;ample the original image the mask was created from. (se the 1article Analyzer to meas$re the plant with the intensity val$es from the original image and display the o$tline res$lt.

Illustration 129: The set measurements dialog. The settings are used $y the measure command and $y the particle analy/er. Another way to $se a mask to meas$re in another image3 is by $sing the wand tool on the mask and then transferring the mask to the other image by activating the image and pressing R on the toolbo; or shiftMe on the image. Fo$ can then $se the meas$re command to meas$re the content of the selection. volker.baecker@mri.cnrs.fr +%!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer ,pen the plant,noise.tif image and try to segment it with the help of the threshold ad=$ster. Fo$ will see that the noise prevents yo$ from making a good segmentation. .ry one of the noise s$ppression techni-$es we disc$ssed and try the segmentation again.

".2 Meas%rements and t!e #$I-Manager


,pen the image #0 dapi1.tif. 'et a threshold that separates the n$clei from the backgro$nd. R$n the article #naly/er. 'elect the #dd to Manager option. 5or each particle detected by the 1article Analyzer3 a roi is added to the R,I*Manager. .he .ho& #ll b$tton shows or hides all rois in the manager on the active image. If yo$ click on one roi in the list3 it will be set to the active image. Clicking on a label of a roi in the image3 selects the roi in the list. >ow deselect all rois and press the meas$re b$tton. Fo$ get a res$lts table with the meas$rements of all rois. If yo$ select a n$mber of rois $sing shift3 only the selected rois will be meas$red. In general the commands in the roi manager are either applied to the selected rois or to all rois if there is no selection.

Illustration 121: The roi manager displays the rois of all particles.

Illustration 12": The rois of the particles ha+e $een added to the roi manager.

Illustration 121: The measurements of the rois in the roi manager. Remove particle 4 and ". (se the wand tool to select particle 4 again and add it again to the roi manager. 'ave all rois3 then close and re*open the roi*manager and open the saved rois again.

volker.baecker@mri.cnrs.fr

+)!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer Compare the meas$red val$es of different particles. <hat is the meaning of the meas$red val$esK
Area: The sur&ace o& the roi. It is measure Mean: The a0erage gray 0alue within the roi. StdDev: The stan ar e0iation o& the mean gray 0alue within the roi. in s.uare+!i/el i& no s!acial scale is set.

Mode: The most &re.uently occurring gray 0alue within the roi. This corres!on s to the highest !ea' in the histogram o& the roi. I& you is!lay the histogram the mo e will -e shown together with the num-er o& occurrences. Min: The minimal gray 0alue within the roi. Max: The ma/imum gray 0alue within the roi. X: The /+coor inate o& the centroi . This is the a0erage o& the /+coor inates o& the !i/els in the roi. Y: The y+coor inate o& the centroi . This is the a0erage o& the y+coor inates o& the !i/els in the roi. XM: The /+coor inate o& the center o& mass. This is the -rightness weighte coor inates o& the !i/els in the roi. YM: The /+coor inate o& the center o& mass. This is the -rightness weighte coor inates o& the !i/els in the roi. Perim.: The length o& the outsi e -oun ary o& the roi. BX: The /+coor inate o& the u!!er+le&t corner o& the -oun ing -o/ o& the roi. The -oun ing -o/ is the smallest rectangle, that entirely contains the roi. BY: The y+coor inate o& the u!!er+le&t corner o& the -oun ing -o/ o& the roi. Width: The wi th o& the -oun ing -o/ o& the roi. Height: The height o& the -oun ing -o/ o& the roi. Major: The length o& the ma1or a/is o& the -est &itting elli!se. The elli!se has the same area, orientation an centroi as the original selection. Minor: The length o& the minor a/is o& the -est &itting elli!se. Angle: The angle o& the ma1or a/is o& the -est &itting elli!se against the /+a/is o& the image. Circularity: 42(area/perimeter^2). A 0alue o& ) in icates a !er&ect circle. As the 0alue a!!roaches *, it in icates an increasingly elongate !olygon. 3alues may not -e 0ali &or 0ery small !articles. The !erimeter o& a circle is ! " 42r an the area is a " 2r5. a0erage o& the /+

a0erage o& the y+

volker.baecker@mri.cnrs.fr

++!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer
eret:! The longest istance -etween two !oints on the -oun ary o& the roi. 6ou can use the macro Draw Ferets Diameter to raw the &eret iameter o& a selection into the image. 7se Plugins>Macros>Install an select the macro &rom the macros &ol er in the Image8 -ase+&ol er. Ma'e a selection in the image an call the macro &rom the Plugins>Macros menu. "ntDen:! The integrate ensity is the sum o& the gray+0alues o& all !i/els within the roi.

Median: The me ian gray 0alue o& the !i/els within the roi, i.e. The gray 0alue that lies in the mi le or the 0alue -etween the two 0alues in the mi le, when all gray+0alues are sorte their numerical 0alue. S#e$ne%%: A measure o& the asymmetry o& the roi. istri-ution o& the gray 0alues aroun

-y

the mean within the

Illustration 120: The measured s%e&ness is 9.991

Illustration 122: The measured s%e&ness is 9.102

Illustration 123: The measured s%e&ness is ,9.102

&urto%i%: A measure o& the "!ea'e ness" o& the istri-ution o& the gray 0alues aroun the mean within the roi. 9igher 'urtosis means more o& the 0ariance is ue to in&re.uent e/treme e0iations, as o!!ose to &re.uent mo estly+size e0iations. 'Area: The !ercentage o& the sur&ace that has an intensity 0alue a-o0e the min+threshol or a-o0e * i& no min+threshol is set. ,oosely s!ea'ing this is the !ercentage o& !i/els within the o-1ect that o not -elong to holes. eretAngle: The angle o& the &eret iameter with the /+a/is o& the image (*+):*).

Min eret: This is a measure o& the !article;s wi th. It is calle the minimum cali!er iameter as well. It is e&ine as the shortes istance -etween two !arallel !lanes touching the !article on o!!osite sites, &or any orientation o& the !article. A(: The as!ect ratio o& the !article. This is the length o& the ma1or a/is o& the minor a/is o& the &itte elli!se. i0i e -y the length

(ound: The roun ness o& the !article, e&ine as< =>area?2>(ma1or a/is)5. The roun ness is ) &or a circle an a!!roaches * &or 0ery alongate o-1ects. The ma1or a/is o& a circle is ! " 4r an the area is a " 2r5. Solidity: The area o& the !article i0i e -y the area o& the con0e/ hull o& the !article. 6ou can see the con0e/ hull that is use -y creating it &rom a selection using Edit> election>!on"e# $ull.

volker.baecker@mri.cnrs.fr

+/!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

".3 ,omp%ted t!res!olds


,pen the plant.tif image again. <e will now have a look at the a$tomatic threshold operations. ,pen the MRI 8is$al 'cripting .ool. ?o to Operations>$asic>segmentation. .ry the a$to*threshold3 the entropy*threshold3 the mean*threshold and the ots$*threshold. <hich one gives the best res$ltK .ry them on the root".tif image. <hich one gives the best res$lt for this imageK

Illustration 124: *esult of the auto, threshold.

Illustration 126: *esult of the entropy,threshold.

Illustration 128: *esult of the mean, threshold.

Illustration 139: *esult of the Otsu, threshold.

.he a$to*threshold separates the histogram in a way that the threshold val$e e-$als half of the s$m3 of the average backgro$nd and the average ob=ect intensity. In other words it is trying to find a threshold in a way that half of the average intensity belongs to backgro$nd and half of it to ob=ects. .he entropy threshold searches a threshold val$e for which the inter class entropy is ma;imal. .he ,ts$ threshold $ses a threshold val$e for which the inter class variance is ma;imal. .he mean threshold $ses the mean intensity of the image as threshold val$e.

".4 Segmentation of more t!en 2 ob-ect classes


<e can have more then two classes for backgro$nd and ob=ects. <e co$ld for e;ample have backgro$nd3 dark ob=ects and light ob=ects. ?o to lugins>.egmentation>%,means,clustering and apply it to the plant image3 $sing % classes. .he res$lt is an image with the intensities 3 &3 # and %. 1i;els with a similar intensity are marked with the same n$mber. <e co$ld now m$ltiply the image with +4 and then $se the threshold ad=$ster to create a mask from each of the n$mbers. .wo binary masks can be combined by $sing 1rocessOImage Calc$latorOAnd.

volker.baecker@mri.cnrs.fr

+0!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 131: Image segmented into four classes: 1. $ac%ground , $lac%5 ". dar% areas , $lue5 1. $righter areas , read5 $rightest areas , green. .he k*means cl$stering works for color images as well. .ry it on the image flamingo.png and on one of the images from the plant robot folder. (se a bigger n$mber of classes Babo$t )C on the later. .he k*means*cl$stering interprets the intensity val$es in n*colors as coordinates in an n* dimensional space. :ach cl$ster is represented by its centroid. Centroids are initially randomly set and optimized afterwards. 1i;els are gro$ped by their pro;imity to a cl$sterSs centroid.

".5 *aters!ed segmentation


,pen the image t&o,circles.tif. Apply a threshold. >ow there are two ob=ects to$ching each other and we want them to be separated. .his can be done $sing a binary watershed. Apply it from rocess><inary>Gatershed.

Illustration 13": The thresholded image contains t&o o$(ects touching each other. volker.baecker@mri.cnrs.fr

Illustration 131: The $inary &atershed algorithm separated the t&o o$(ects. +"!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer 'tarting from the binary image a distance map is comp$ted. .his gives a grayscale image where the intensities represent the distance from the border for each ob=ect. Fo$ can create the distance map from the original image with rocess><inary>-istance Map. Imagine the intensity val$es as height above the gro$nd. .his way the image becomes a landscape with mo$ntains in places of high intensities and valleys in places of low intensities. Apply #naly/e>.urface lot or $se Interacti+e 1- surface plot pl$gin B lugins>1dC the to see the image this way. .he watershed slowly fills the image with water starting from the level 4 and going $p one level in each step. In the beginning some separated basins will be created. <henever the rising water $nites two basins a dam is b$ild and remembered.

Illustration 130: The distance map5 pi)els &ithin the o$(ect are dar%er5 the further a&ay from the $order they are.

Illustration 132: The distance map as a surface plot.

.he watershed can be $sed with a grayscale image directly. .o try this we need to install the watershed pl$gin from httpD!!bigwww.epfl.ch!sage!soft!watershed!. 7ownload the zip3 copy it into the pl$gins folder and $nzip it. Restart ImageJ. >ow letSs try to segment the image compartments* .=pg with the help of the watershed. ,pen the image and start the pl$gin from lugins>Gatershed>Gatershed. (se a high val$e for the smoothing. 1ress the 'mooth b$tton. Invert the res$lt image so that the basins are dark3 $sing :ditOInvert or shiftMI on the image. 'elect 0*connected. .his means every pi;el has 0 neighbors3 & above3 & below and the % corners. R$n the watershed.

volker.baecker@mri.cnrs.fr

/4!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 133: The red lines represent the dams found $y the &atershed. The image is slightly o+ersegmented. Can yo$ get a better res$lt by applying an edge enhancing filterK .ry 1rocessO5ind :dges or shiftMf on the image before $sing the watershed.

-! Image types and formats


2.1 Spatial resol%tion
.he optical resol$tion is defined as the shortest distance between two points on a specimen that can still be disting$ished by the observer or camera system. 5or a microscope the resol$tion depends on the wavelength and the n$merical apert$re of the ob=ective. .he resol$tion is the wavelength divided by & times the n$merical apert$re. 'maller wavelength and higher n$merical apert$re yield higher resol$tion. .he pi;el size in an image taken with a microscope and a ccd camera is the prod$ct of the size of a single ccd element m$ltiplied by the binning $sed and divided by the overall magnification factor. .he more pi;els an image has3 the higher can be the resol$tion3 tho$gh the n$mber of pi;els alone doesnSt tell anything abo$t the act$al resol$tion. .he more pi;els an image has3 the larger will be the file size in the same time. 6y how m$ch the file size grows with the n$mber of pi;els3 depends on the bit*depth of the image. :ight*bit images store intensity val$es between 4 and &)). :ach pi;el is stored in 0 bits or one byte. If the image has %44;%44 pi;els the size will be %44V%44 L +4444 bytes or abo$t )+kb B kb L 4&%bC. If we do$ble the size of the image to 044;044 pi;els the file size will be fo$r times as large3 i.e. +&)kb. If we take fo$r times the pi;els in ; and y direction the file size will be + times as large.

2.2 Image types


In ImageJ there are the following basic image types availableD 0 bit grayscale images Bval$es from 4 to &))C + bit grayscale images Bval$es from 4 to +))#)C volker.baecker@mri.cnrs.fr / !"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer #& bit floating point n$mber images B$ses signed floating point n$mbersC 0*bit color Bval$es from 4 to &))C3 an 0 bit image with a look$p table R?6 Color B# channels of val$es from 4 to &))3 bit depth &%C

<hat happens if we convert an 0*bit grayscale image into a +*bit grayscale imageK .ry itW ,pen the image cells&.tif and look at the histogram Bpress h on the imageC. .hen convert it to +bit $sing ImageO.ypeO + bit. 7isplay the histogram again. As yo$ see the intensity val$es have not been changed.

-!#! Con/ersion from , to 0 bit


,pen the image 1AEJ>oc#4.tif now. 7isplay the histogram. .his is a + bit image containing val$es from 444 to #)+/0. <hat will happen when we convert it to 0bitK (se Image>Type>6 $it. .he val$es have been scaled down from the min!ma; val$es 444 and #)+/0 to 4 and &)).

Illustration 134: The 13,$it images contains intensity +alues from 1999 to 12346.

Illustration 136: The histogram of the 13,$it image.

Illustration 138: The histogram after con+ersion to 6,$it.

In Edit>Options>Con+ersions yo$ can t$rn the scaling off. 9owever then all val$es above &)) will simply be tr$ncated when converting to 0 bit. .he res$lt image will be all white3 since the smallest val$e in the original image is 444. Compare the histograms of the res$lts of Converting the + bit image to 0 bit (se rocess>Enhance Contrast>Mormali/e on the + bit image before converting to 0 bit. Convert the + bit image to 0 bit and do the normalization

-!#!# R=4 Images


,pen an image from the plant robot folder. 5or color images there is a profile tool as well. 7raw a line across the plant and the earth and call lugins>Color =unctions>*;< rofiler.

volker.baecker@mri.cnrs.fr

/&!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 141: The color profile along the line. Illustration 149: #n *;<,color image. An R?6 image can be split into its three components with Image>Color>*;< .plit and two or three 0*bit grayscale images can be combined into an R?6 color image. 6esides this3 an R?6 image can be converted into a R?6 stack or into a 9'6 stack $sing the type men$. 9'6 stands for h$e3 sat$ration and brightness.

Illustration 14": *ed Illustration 141: ;reen Illustration 140: <lue component of the component of the component of the image. image. image.

Illustration 142: 'ue component of the image.

Illustration 144: Illustration 143: .aturation component <rightness component of the image. of the image.

An R?6 image can be converted into an inde;ed color image. Fo$ can choose the n$mber of colors that will be $sed and a look$p table will be created accordingly.

volker.baecker@mri.cnrs.fr

/#!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer Create two images of same size and draw a white rectangle on a dark gro$nd into the two images in a way that the two rectangles are overlapping when the images are combined. Apply rgb merge and p$t the images into the red and into the green channels. <hat will be the color of the overlapping regionK

Illustration 146: ;reen and red mi) to yello& in an additi+e color model.

-!#!$ 3ile 3ormats


,pen an image and save it as =pg3 $sing =ile>.a+e#s>Jpeg. ,pen the =pg file3 and calc$late the difference between the =pg version and the original image. <hat has happenedK If yo$ look at the file sizes yo$Sll see that the =pg version is smaller than the tiff version. Jpg is a compressed format. .here are lossless and not lossless compressions. Jpg $ses the first scheme. 'ome information is sacrificed in order to achieve a smaller image in which the difference is not too m$ch visible for h$man beings. .his is similar to mp# a$dio compression.

0! Image Analysis
5or o$r p$rpose we can define the term image analysis in the following wayD Image analysis is the e)traction of meaningful information from digital images $y means of digital image processing techniLues.

4.1 ,o%nting ob-ects


0! ! Co"nting ob>ects man"ally
,pen the image nuclei.tif. 9ow many n$clei are there in the imageK .he cell co$nter pl$gin3 written by X$rt 7e 8os helps to co$nt ob=ects man$ally. ,pen the cell co$nter from lugins> aricle #nalysis>Cell Counter. Fo$ first have to press the initialize b$tton to activate the cell co$nter on the c$rrent image. Fo$ can co$nt different classes of ob=ects in the same image. 'elect a co$nter type and click on a n$cle$s in the image. .he n$cle$s will be marked with a n$mber corresponding to the selected class and the co$nt of the class will be incremented by one. If yo$ select delete mode a click deletes the nearest marker of the selected class and decrements the co$nter of that class. ,nce yo$ marked all ob=ects yo$ can $se res$lts to get a table with the co$nt for the different classes. Fo$ can save the markers independent from the image and load them later on again3 volker.baecker@mri.cnrs.fr /%!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer either on the same3 or on another image. :;port image creates an image where the markers are drawn into the image. Fo$ can save this image to show which cells yo$ co$nted3 however in contrast to saving the markers3 yo$ canAt contin$e the co$nting later on with the e;ported image.

Illustration 148: Muclei mar%ed &ith the cell counter tool.

Illustration 169: The cell counter tool.

0! !# Co"nting and meas"ring separated ob>ects a"tomatically


(se the threshold ad=$ster to create a mask from the n$clei image. .hen go to AnalyzeO'et Meas$rements and make s$re that centroids is selected. ,pen the 1article Analyzer from #naly/e>#naly/e articles or from the toolbo;.

Illustration 161: The mas% created &ith the tres(old ad(uster.

Illustration 16": The particle analy/er. /)!"#

volker.baecker@mri.cnrs.fr

Image processing and analysis with ImageJ and MRI Cell Image Analyzer Fo$ can e;cl$de particles by their size and circ$larity. 1$t in a minim$m size of 444. 'elect outlines in the show field and select -isplay *esult3 .ummari/e and Include 'oles. As a res$lt yo$ get a res$lts table with the meas$rements for each particle3 a res$lts table with the s$mmary and an image of the n$mbered o$tlines of the particles taken into acco$nt. Fo$ find the total n$mber of ob=ects in the s$mmary res$lts table.

Illustration 161: -etail of the o+erlay of the original image and the outlines of the particles ta%en into account $y the particle analy/er.

Illustration 160: The summary of the measurements includes the total count.

As an alternative to $sing the o$tlines to mark which particles have been taken into acco$nt3 yo$ can $se the #naly/e>Ha$el command to stick a n$mber to each ob=ect. .his is only possible if yo$ config$red the particle analyzer to meas$re the centroids of particles.

0! !$ Co"nting and meas"ring ob>ects to"ching each other a"tomatically

8.1.3.1 Statistical approach


It can be diffic$lt to separate ob=ects to$ching each other. ,ne approach to co$nt them is not to try to separate them3 b$t to meas$re the total area and to divide the res$lt by the average area of a particle. ,pen the image si1ChoechstC1.tif from the co$nt cells folder. Convert the image to 0 bit and apply a threshold. .o estimate the average size of a particle $se the wand tool to select sing$lar particles and meas$re their area. Fo$ can $se #naly/e>distri$ution to get the average of a col$mn of the res$lts table. .hen $se the particle analyzer to meas$re the total area of all particles. In case yo$ donAt need to e;cl$de small particles that donAt represent cells3 yo$ can $se Edit>.election>Create .election and meas$re the selected area.

volker.baecker@mri.cnrs.fr

/+!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 162: articles $igger then the a+erage pariticle si/e are counted multiple times.

8.1.3.2 Local Threshold


'ometimes $nsharp masking can help to separate particles. .ry the local threshold pl$gin from lugins>.egmentation>Hocal Threshold on the image hst,9.tif in the cells in str$ct$res folder. .he pl$gin applies a median filter and s$btracts the res$lt from the original image. .he res$lt image is a #& bit image. It then lets the $ser choose a threshold val$e.

Illustration 163: The original image &ith a threshold.

Illustration 164: The image after application of the local threshold plugin.

8.1.3.3

atershed

<e can $se the greyscale watershed pl$gin to separate the cells in the hst,9.tif image. Invert the image3 so that the n$clei are dark and the space aro$nd them is bright. (se a small radi$s for the smoothing filter. 'elect the show the watershed dams only option. R$n the watershed. Invert the watershed image and s$btract it from the original hst,9.tif image. .he borders between the cells are now set to zero and yo$ can $se the threshold ad=$ster to get a mask for the separated cells.

volker.baecker@mri.cnrs.fr

//!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 166: The original image.

Illustration 168: Cells separated $y the &atershed plugin.

Illustration 189: Image &ith &atershed dams.

8.1.3.! "ther #ethods


,ther methods $se for e;ample first or second order gradients of the image or mathematical morphology.

4.2 ,omparing intensities


,pen the image #0 *hod 1.tif. <e want to compare the total intensity in the n$clei with the total intensity in the cytoplasm. .he image #0 dapi 1.tif helps $s to find the n$clei. Apply the hilo l$t to the rhod image and s$btract a baseline val$e3 so that the empty backgro$nd becomes zero. .hreshold the dapi image. If there are holes in the mask of the n$clei $se 1rocessO6inaryO5ill 9oles to close them. Create a selection from the mask and if necessary modify the selection3 so that it only contains the n$clei. .ransfer the selection from the mask image to the rhod image $sing Edit>.election>restore or CT*H7.hift7e. Config$re the meas$rements to incl$de the total intensity. And meas$re the intensity in the selection Bctrl7mC. Inverse the selection BEdit>.election>Ma%e In+erseC and meas$re again.

volker.baecker@mri.cnrs.fr

/0!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 181: Measuring the intensity in the nuclei and in the cytoplasm.

4.3 ,lassifying ob-ects


'ometimes yo$ might not only want to separate ob=ects from the backgro$nd and from each other b$t also to disting$ish between different kinds of ob=ects in the image. ,ne co$ld for e;ample be interested in disting$ishing between normal and apoptotic cells. .o do so yo$ need to find a set of feat$res that separates the different classes of ob=ects yo$ are looking for. 2oad the image ovals and triangles and try to separate the ovals from the triangles. In this case the two classes can be disting$ished by the feat$re ro$ndness. (se the particle analyzer to separate the two classes of ob=ects.

Illustration 18": -ifferent %inds of o$(ects in one image.

Illustration 181: O+als ha+e a high roundness.

Illustration 180: Triangles ha+e a lo& roundness.

In general more then one feat$re might be necessary to classify ob=ects. ,ne $sef$l set of feat$res are the moments of ob=ects and val$es derived from moments of ob=ects. Fo$ can $se the Moment Calc$lator pl$gin B lugins> article #nalysis>Moment CalculatorC to comp$te them. volker.baecker@mri.cnrs.fr /"!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 182: =eatures $ased on moments of the circles ?first 1 ro&s@ and triangles ?last three ro&s@ . 5$rther feat$res can for e;ample be calc$lated with the 1article0 1l$s or other morphological pl$gins from ?abriel 2andini B lugins>morphology> articles6 lusC.

Illustration 183: =urther features of the circles ?ro&s 15 05 3@ and triangles ?ro&s "5 15 2@.

1! Annotating images
5.1 Scale bar6 time stamper and e1ent stamper
,pen the image ot.tif. .his opens a stack of image which represents a time series. Fo$ can cycle thro$gh the images with the slider at the bottom of the window. <e want to add three annotations to the imagesD A scale bar indicating the length of a known distance3 the time point from the beginning of the series and a marker for images in which the flower appears. .o add a scale bar we first have to calibrate the image. <e either need to know the pi;el size or the length of an ob=ect in the image. 2etAs say that the diameter of the pot is +cm. Make a line selection from one side of the pot to the opposite side. .hen open #naly/e>.et .cale.... :nter the distance + and the $nit cm and press ok. <hen the scale is set ImageJ will $se for all meas$rements3 i.e. res$lts will now no longer be in pi;el b$t in cm.

volker.baecker@mri.cnrs.fr

04!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration 186: .etting the scale. Illustration 184: .electing a %no&n distance. ?o to #naly/e>Tools>.cale <ar and p$t a black scale bar of &cm length into the lower left corner. 'elect Ha$el all .lices to p$t the scale bar into all images of the series.

Illustration 188: The $lac% line segment has a length of t&o centimeter.

Illustration "99: #dding a scale $ar to each image of the series.

<e will now add a te;t indicating the time when the image was made. 2etAs say the image have been made with an interval of day between to images. Make a rectang$lar selection in the place where the stamp sho$ld appear. 7o$ble click the pipette icon and set the foregro$nd color to the color yo$ want the stamp to have. .hen open the time stamper from lugins>Mo+ie>Time .tamper.

volker.baecker@mri.cnrs.fr

0 !"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration "91: The time stamper dialog.

Illustration "9": The time stamp has $een added to each image of the series.

5inally add a label $looming on the slices % to /. .his is done in a similar way as adding the time stamp3 only that the command lugins>Mo+ie>E+ent .tamper is $sed.

Illustration "91: The e+ent stamper dialog. Illustration "90: # te)t has $een added to some images of the series.

5.2 ,alibration bar


(sing a look$p table on a greyscale image3 we want to provide a bar that shows which colors represent which intensities3 normalized to a range between 4 and 3 in the image. ,pen the image #0 *hod 1.tif and apply the look$p table *ain$o& *;<. .here are two ways to achieve o$r goal. ,ne way is to make a selection in the image and r$n lugin>H!T>#dd

volker.baecker@mri.cnrs.fr

0&!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer *amp. .his will add a ramp with the colors of the l$t from the bottom with the val$e 4 to the top with the val$e &)). It only works for 0 bit images.

Illustration "92: # ramp sho&s &hich color represents &hich intensity. .he other way is to first calibrate the image intensities $sing #naly/e>Cali$rate... A calibration bar can then be stamped into the image $sing #naly/e>Tools>Cali$ration <ar... .o calibrate the image yo$ have to enter a n$mber of pairs of $ncalibrated and calibrated val$es. Fo$ can select the form of a c$rve that will be fitted to the entered data. 5or a calibrated image3 intensity val$es will be displayed in the calibrated form3 followed by the greylevel val$e in brackets. Meas$rements will be in calibrated form. Call #naly/e>Cali$rate... and enter the points 43 4 and &))3 . 'elect the f$nction straight line. .hen $se #naly/e>Tools>Cali$ration <ar... stamp the calibration bar into the image.

2! Working with m"lti)dimensional data


In general image data can have m$ltiple dimensions. # spacial dimensions3 the time dimension and many channels Bfor e;ample different wavelengthsC.

volker.baecker@mri.cnrs.fr

0#!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

17.1 &ime series


,pen the image pot.tif. Fo$ can play the image se-$ence $sing Image>.tac%s>.tart #nimation. Fo$ can $se the last b$tton in the ImageJ la$ncher window to switch the c$rrent tool set to the stack tools. .his will display b$ttons toD animate the stack Bclick again ti stopC3 go to first and last slice3 go one slice forwards ! backwards add a slice after the c$rrent slice ! delete c$rrent slice

Illustration "93: ImageJ &ith the stac% tool set selected. As yo$ see the camera position is not e;actly the same for each image which makes the plant somewhat =$mp aro$nd. (se lugins>.tac% .huffling>#lign slices for an a$tomatic stack registration. Choose either rigid body or translation as transformation. Make a rectang$lar selection3 so that the black borders that have been created by the stack registration are o$tside of the selection and d$plicate the stack Bctrl7shift7dC. Fo$ can e;port the series as a movie in one of the following formatsD animated gif avi movie -$icktime movie (se =ile>.a+e #s and one of these formats to e;port the series as a movie. If yo$r image se-$ence is to big to fit into memory at once3 yo$ can still create a movie from it by $sing the virt$al stack opener B=ile>Import>Birtual .tac%C.

17.1.1 Meas%ring 1elocities


,pen the image moving*particles. Fo$ see two circles that move from the lower left to the $pper left side of the image. <e want to meas$re the lengths of the paths they traveled.

Illustration "94: T&o mo+ing particles.

Illustration "96: # pro(ection of the time series.

volker.baecker@mri.cnrs.fr

0%!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer In principal this co$ld be done man$ally $sing for e;ample the polygon selection tool. ?o to the first slice set the first polygon point to the into the first particle3 then go one slice ahead $sing the AOA key and set the ne;t point and so on. <hen the path is finished press ctrl7m to meas$re its length. Another possibility is to create a pro=ection of the stack BImage>.tac%>F ro(ect...C and $se the polygon selection tool on it. .he Mtrac%" pl$gin meas$res the track length a$tomatically. ,pen it from lugins> article #nalysis>Mtrac%".

Illustration "98: The MTrac%" plugin.

Illustration "19: The paths found $y the MTrac%" plugin.

Illustration "11: The plugin ans&ers the distance tra+elled $y the particles ?length@ and the linear distance from the start point to the end point of the trac%.

! 4iological applications
11.1 ,olocali8ation analysis
! ! 6is"alizing colocalization "sing o/erlays
In principle an overlay of the two channels3 $sing two appropriate look$p*tables3 like for e;ample red and green or cyan and magenta3 sho$ld give as a hint if two fl$ochromes are in the same place. In the red!green case places in which the red and green intensities are close to each other will appear yellow in the image. Another possibility is to $se magenta3 green and bl$e. volker.baecker@mri.cnrs.fr 0)!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration "1": The o+erlay of the channels. The green channel has lo&er intensities and is in+isi$le. 6$t there are some problems with this approach. Fellow spots will only become visible if the intensities in both channels are similar3 both channels m$st have similar histograms. 9istogram normalization can be $sed b$t may s$ggest false res$lts since intensities donAt represent the real -$antities of molec$les anymore. ,pen the images coloc,*hod3 coloc,;= and coloc,'oechst from the coloc folder. Create an overlay of the channels that shows the colocalization between gfp and rhodamine. Instead of an additive overlay of channels the diference can be $sed. Apply magenta and cyan look$p tables3 convert the images to R?6 and calc$late the difference $sing the image calc$lator. .he same res$lt can be achieved $sing the Colo$r merge command from the men$ lugins>Colour functions. Check !se difference operator in the dialog.

Illustration "11: The color merge dialog. volker.baecker@mri.cnrs.fr 0+!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration "10: O+erlay of the red and green channel after histogram normali/ation.

Illustration "12: The histogram of the red channel.

Illustration "13: The histogram of the green channel.

volker.baecker@mri.cnrs.fr

0/!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration "14: The histogram Illustration "16: The of the red channel after histogram of the green channel normali/ation. after normali/ation.

Illustration "18: Original o+erlay &ith auto,display, ad(ustment.

volker.baecker@mri.cnrs.fr

00!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration ""9: Original o+erlay &ith auto,display ad(ustment in Magenta:;reen:<lue.

Illustration ""1: Color merge &ith difference of the original channels.

volker.baecker@mri.cnrs.fr

0"!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration """: Color merge &ith difference after histogram normali/ation.

! !# ?"antification of colocalization

11.1.2.1 $ntensit% correlation coefficient based #ethods


In this approach a statistical analysis of the correlation of the intensity val$es in the two channels is performed. .his is mostly done by $sing correlation coefficients that meas$ring the strength of the linear relationship between two variables3 the intensities in the two channels.

11.1.2.1.1 &earson's coefficient and scatter plot


A fl$orogram or scatter plot can help to =$dge if colocalization is present or not. In a scatter plot the ;*a;is represents the intensity val$es of the pi;els in one channel and the y*a;is the intensities in a second channel. .he pi;els of the two images will be compared one by one. If the intensity of pi;el B434C is 4 in the first image and ) in the second image3 the point 43 ) will be marked in the scatter plot. 'ometimes the fre-$ency of the intensity pair is coded by the color or brightness in the scatter plot. A line will be fitted thro$gh the points in the scatter plot. A positive slope indicates a correlation3 a zero slope indicates that the images are $ncorrelated and a negative slope indicates a negative correlation Ba m$t$al e;cl$sionC. .he 1earsonAs Coefficient is a meas$re of the -$ality of the linear fit. It is obtained by dividing the covariance of the two variables by the prod$ct of their standard deviations. Mark that the thickness of the point clo$d and the direction of the line have an infl$ence on the 1C3 b$t not the slope of the line. .he 1C will be near for a positive correlation3 near zero in case of no correclation and near * for a negative correlation.

volker.baecker@mri.cnrs.fr

"4!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration ""1: Illustration ""0: # noisy image. #nother similar noisy image.

Illustration ""2: # Illustration ""3: scatter plot of The color o+erlay correlated images of the input images.

Illustration ""4: Illustration ""6: # noisy image. #nother similar noisy image5 rotated $y 89N.

Illustration ""8: Illustration "19: .catter plot of The color o+erlay uncorrelated images of the input images.

Illustration "11: Illustration "1": # noisy image. #nother similar noisy image5 rotated $y 89N.

Illustration "11: Illustration "10: .catter plot of anti, The color o+erlay correlated images of the input images.

volker.baecker@mri.cnrs.fr

" !"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration "12: earsonJs coefficients for different scatter plots. ,pen the images coloc,;= and coloc,'oechst from the folder 1" , coloc. (se the J#Co pl$gin to calc$late the scatter plot. R$n the pl$gin from the 1l$gins men$3 select the images in the dialog3 select cytofl$ogram and #dd the /ero line. .he scatter plot will be created and the fitted line will be shown. .he 1earsonAs Coefficient will be written to the log window as Correlation Coefficient. If yo$ want to calc$late the 1earsonAs Coefficient witho$t the scatter plot3 check earsonJs coefficient instead of cytofluogram in the dialog.

volker.baecker@mri.cnrs.fr

"&!"#

Image processing and analysis with ImageJ and MRI Cell Image Analyzer

Illustration "14: The o+erlay of the t&o input images. Illustration "16: The scatter plot and the fitted line calculated $y the J#Co plugin.

Illustration "13: The dialog of the J#Co colocali/ation plugin. 'catter plot and 1earsonAs coefficient indicate colocalization3 especially when it is complete. 9owever they rarely discriminate differences between partial colocalization. Mid*range coefficients between *4.) and 4.) do not allow concl$sions to be drawn. .he res$lt is dependent on noise and backgro$nd or the threshold $sed to s$press the backgro$nd. 6leadthro$gh of the fl$orescents can lead to false res$lts as well. 5inally there co$ld be a non linear relationship between the two signals3 that co$ld not be detected $sing this method.

volker.baecker@mri.cnrs.fr

"#!"#

S-ar putea să vă placă și