Biomedical Imaging Research Unit School of Medical Sciences Faculty of Medical and Health Sciences The University of AucklandPrivate Bag 92019 Auckland, NZ Ph: 373 7599 ext. 87438 www.auckland.ac.nz/biru/ [email protected] . ImageJ Seminar: Introduction to Image Analysis Jacqui Ross Image analysis questions 1. What do you want to measure in order to get meaningful data? • • • • • Area Intensity Colour Orientation Distance, velocity, etc. • • • • 13 October 2009 Number of particles (e.g. cells) Size/distribution of particles Particle shape Colocalisation 2. • • Do you need to work in colour or grayscale? RGB split channels Convert to 8bit grayscale • • Colour thresholding Colour deconvolution 3. • Do you want to measure the whole image or specific regions? Do you need to select the regions using one image and apply it to another? Regions of Interest (ROI) and ROI Manager 4. Do you need to use processing filters to facilitate segmentation? • • • Background subtraction Edge detection Enhance contrast • • Median filter Unsharp Mask/Sharpen 5. • • Do you need to fill holes or separate joining particles? Fill holes/Erosion/Dilation/Open/Close Watershed 6. • Are you measuring relative intensities or do you need to calibrate using standards? Calibration 1 AREA MEASUREMENTS Manual approach: measure the area of structures by drawing a region of interest (ROI) around them with one of the drawing tools, e.g. freehand, ellipse, rectangle tool. 1. 2. 3. Open the image. Draw the ROI. Go to Analyze-ROI Manager. Then go to Analyze-Set Measurements to select the parameters that you want to measure. 4. Click on Measure in the ROI Manager window. Results will appear in a Results window. These results can be saved and are .xls files, i.e. can be opened in Excel. If you go to Analyze – Measure instead of using the ROI Manager, then you will get results for the entire image, not just the ROI. 5. You can draw multiple ROIs and add them to the ROI Manager. You can move the ROIs and update them, rename them, etc. You can also save the set of ROIs. This is a really good idea as a record of what you have measured. That allows you to reload them or use them on another image. You can also draw the ROIs onto the image and save it as a record. Note: measuring lines or angles manually works the same way except that you select one of the line tools or the angle tool. Threshold approach: use thresholding followed by binarising to segment the stained area which you wish to measure (for area measurements where you are not interested in intensity). 1. Open the image. Change to grayscale (Image – Type – 8bit) or go to Image – Color RGB Split. 2. Go to Image – Adjust – Threshold. You can select the Auto setting or alternatively move the sliders yourself until you have all the stained areas selected. You should select dark background if you have a fluorescence or confocal image. (If the Auto setting works well for you, you could go straight to Process – Binary – Make Binary). 2 3. Click Apply to binarise the image if you are not interested in intensity values. The stained areas which you want to measure will be black. You should not change the defaults unless you want to measure the unstained areas. ImageJ regards the black areas as the areas/objects of interest. 4. Go to Analyze – Set Measurements. Choose the parameters you want to measure. If you are interested in the proportion of area labelled, you may want to select Area Fraction in addition to Area. Make sure that you include Display Label. 3 4 . Go to Analyze – Measure. The Results table will come up and you can then save this. You can also save the binarised image if you want to.5. Colors – Selection. This size required will depend on the resolution of your image. If you want to measure intensities (grayscale) at each point. 2. Make sure you choose a colour that stands out on your image. etc. and make measurements as you can for any other ROIs. 1. then you need to keep the image in grayscale. 5 . If you don’t want to automatically label the points. This is because once you have made the selection and clicked on another object. 5. 4. Click on the Point Selection tool. You can also choose the size of the point you want to make to label each object. you can choose the colour that you want to use for the selections by going to Edit – Options . Alternatively. you could change the image to RGB colour so that the mark is in colour. In this case. If you have a grayscale image. Go to Edit – Options – Point Tool and turn on Auto-Measure. You just need it to be big enough to be able to see it. the selection point will be filled with the foreground colour. Necessary if you are unable to threshold your images or if you need to count cells but the cells are overlapping and will be measured as one object. you could select the option to Add to ROI Manager. 3.MEASUREMENT OF NUMBER OF PARTICLES/OBJECTS Manual approach: measure the number of objects by using the Point Selection tool. You should also make the Foreground colour the same as your selection colour. If you have an RGB image. you will see the colour in gray so you should choose white/black as your selection and drawing colour. each point selection is added to the ROI Manager and you can save the selections. 8. When you have completed all your measurements. 6 . y z positions and the grayscale value. you can save the image with the marks on it. This includes the x. Now every time you click on the image. 7.6. a dot will appear and the data will be entered into the Results window. Use the Magnifying tool if necessary to make the objects (cells) look bigger and the Hand tool to navigate. A plugin for a Chalkley grid is also available (25 random spots). 3. You should select dark background if you have a fluorescence or confocal image. Threshold approach: use thresholding followed by binarising to segment the objects which you wish to measure. The first part of the procedure is the same as that detailed for Area measurements. You should not change the defaults unless you want to measure the unstained areas. 1. The stained areas which you want to measure will be black. Go to Image – Adjust – Threshold. You can select the Auto setting or alternatively move the sliders yourself until you have all the stained areas selected. ImageJ regards the black areas as the areas/objects of interest. Click Apply to binarise the image if you are not interested in intensity values. 2.Grids You can also use a grid if necessary by going to Plugins – Analysis – Grid. You can define the size of the grid and the points. Change to grayscale (Image – Type – 8bit) or go to Image – Color RGB Split. Open the image. 7 . 4. Go to Analyze – Set Measurements. You may be interested in Shape Descriptors or Feret’s Diameter as well as the number of particles in the images. 8 . Choose the parameters you want to measure. Make sure that you include Display Label. Click on OK to run the analysis. Note that you can exclude based on size and circularity. The success of this depends on the individual objects being able to be clearly distinguished. Record Starts combined with Add to Manager. You can also Exclude on Edges. 9 . which is the usual approach since you won’t have the whole particle in the image.g. 6.5. Go to Analyze – Analyze Particles. If you have calibrated your image. then this size will be in whatever unit you are using (e. adds all the particle outlines into the ROI Manager. microns squared). If you have holes in your particles as shown below. 8. 10 . If two particles are joined together. There is also an option within the Particle Analyzer to Include Holes but filling the holes prior to analysis ensures that it is done correctly. Other binary operations such as opening and closing or dilation and erosion. can also be used and are found under Process . which will affect your measurements.Binary menu.7. you can use processing filters such as Process – Binary – Watershed to separate them. you could fill these holes by going to Process – Binary – Fill Holes. bham. to make the segmentation easier. You can use enhancement tools such as Brightness/Contrast or Window/Level to make the particles easier to segment. This plugin and information about it are available here: http://www. etc.ac. Classify Particles Plugin: Gabriel Landini This is a plugin that works very well. etc. The outline/mask image can also be saved as a record.9. Note: If you don’t want the data for each individual particle. which allows you to classify particles based on certain morphological attributes such as size.html 11 .dentistry. There is also a large range of image processing filters and operations available in ImageJ that can help to enhance contrast. you can just save the Summary.uk/landinig/software/classify/classify. circularity. Go to Image – Adjust – Threshold. 12 . 2. Open the image. The displayed histogram gives you some assistance with this.INTENSITY MEASUREMENTS Use thresholding to select the stained area which you wish to measure 1. Change to grayscale if necessary (Image – Type – 8bit/16bit or Image – Color – Split Channels). You can select the Auto setting or alternatively move the sliders yourself until you have all the stained areas selected. Choose Dark background for fluorescence images as shown below. 13 .3. you can type in values. not just the selected area. If you don’t select Limit to Threshold. In this case. the image is not converted to binary. click Measure. you do want the intensity measurements for entire image. The Results table will come up and you can then save this. Go to Analyze – Measure. 7. if you need to exclude an area or if you need to create a number of ROIs of the same size that you apply to multiple images. If you want to use a consistent threshold (e. You can change the number of decimal places if you think you need more than the default (3).g. 6. based on your background value). then the entire image will be measured. Intensity measurements can also be done within Regions Of Interest (ROIs). 5. 14 . You should also select Limit to Threshold. In this case. e.g. Use thresholding to select the particles which you wish to measure Follow Steps 1-5 above then go to Analyze – Analyze Particles as described earlier.4. Go to Analyze – Set Measurements. In some cases. Make sure that you select all the gray level measurements. Choose the parameters you want to measure. Click Set to set the threshold of the image. you add each ROI into the ROI Manager and then once they are all there. Go to Process – Find Edges to define the boundaries of the objects. that you then apply to a second image. Go to Image – Adjust Brightness/Contrast to improve the differentiation between the edges of the objects and the background. 4. Go to Image – Type – 8bit to change the image into grayscale or to Image – Colour – RGB Split and choose the image which has the most contrast. 2. Open your first image (the one you want to use to create the ROIs). 1. radius 2 pixels for a similar result). e.g. 3. You can also use it to create regions of interest (ROI).g. Process – Filters – Median. Remove any speckle/noise by using a filter. 15 . 5.USING PARTICLE ANALYSIS TO CREATE ROIS Use enhancement filters followed by binarising to segment the objects which you wish to measure. (Various other options such as Process – Enhance contrast can also be used prior to this operation). (You can also try Process – Filters – Variance. e. You could also use Image – Adjust – Window/Level. 6. Go to Process – Binary – Threshold to binarise the image or do it manually by going to Image – Adjust Threshold and then clicking on Apply once you are satisfied with the selection. 16 . You can also do the operations separately. You need to do the opposite operation. Then Fill Holes. Don’t worry about any objects that are on the image boundary.7. i.e. This performs a dilation and erosion operation to fill in the outline and small holes in objects. it means that some boundaries were not complete. you must then dilate. 8. i. These gaps in the outlines of the objects can be filled by going to Process – Binary – Close.e. 17 . Process – Binary – Dilate. followed by Process – Binary – Erode. Now go to Process – Binary – Fill Holes. These should not be included in your analysis. If any are not filled as shown. if you erode. try Process – Noise – Remove Outliers as below. then you may want to use Open to remove these. 12. 10.9. If you are really struggling. If you have lots of small particles or particles joined together. 11. which has resulted in all these small black particles (=noise). You can use the Magnifying tool to zoom up so that you can see the gap. You can change the options and preview the effect on your image by going to Process – Binary – Options. Make sure that the Foreground colour selected is black. then you can draw a small line using the pencil tool to fill in the gap in the boundary. 18 . If you have an image like the one below. Note that this is the same image but in this case I have omitted the median filter step. Use the Preview option to show how this will affect the image.13. Select Dark for a binarised image. 19 . 15. Another option if you don’t want to go through the Analyse Particles window is simply to go to Edit – Selection – Create Mask.Selection – Create Selection and add that into the ROI Manager.14. 20 . you will only get one measurement. If you want to analyse the particles. since the selection combines all the outlines. in this case. However. This also will allow you to add the outline of each nucleus into the ROI Manager to use on the second image. Now all the measured particles are outlined and each outline is added into the ROI Manager as a ROI. 16. go to Analyze – Analyze Particles. You then go to Edit . 21 . 22 .17. Make sure that you have all the grayscale measurement parameters selected in Analyze – Set Measurements. Convert it to grayscale. 19. Click on Show All in the ROI Manager. 18. 20. You will see all the ROIs on your second image as shown below. Now go to your second image. move ROIs.21. 4. ROI MANAGER Manual Selections Draw a region by using the ROI tools or you specify a size by going to Edit – Selection Specify. 2. you need to select Limit to Threshold in the Set Measurements window. In this case. If you want to use a threshold within the ROIs to define the grayscale levels of interest. Select the roiSet. 3. draw. These ROIs will then be inserted into the ROI Manager. Loading ROI Sets 1. 22. Go to ROI Manager and click Open. Open your image. etc. Click Measure in the ROI Manager. 23 .zip file that you previously saved. you can go to Image – Adjust threshold. You can then measure. All ROIs can be saved using the ROI Manager and applied to other images. You can also use the Magic Wand to select grayscale values.net/ 24 .sourceforge. Then click Save. These ROIs can then be applied to your second image.Magic Wand Using the Magic Wand and ROI Manager.lu/doku. 1. You can change the name if you like. and click on one of the filled in objects: The object should then be outlined.php?id=plugin:segmentation:versatile_wand:start There is another one which also works in 3D called YAWI at: http://yawi3d. The ROIs will be saved as a zip file called ROISet. There is a more flexible magic wand tool available at: http://imagejdocu. 4. 5. Click Add in the ROI Manager window. 2. There is a tolerance value that you can alter to expand the selection more according to the 3. Using the binarised image that you have already created. Open up ROI Manager by going to Analyze – Tools – ROI Manager. Continue until all the nuclei have had ROIs created for them.tudor. go to the Wand Tool. 25 .tudor. Run background subtraction if necessary to remove uneven background. Keep changing the radius until no dots are evident.php?id=video:analysis:gel_quantification_analysis 1.lu/doku.GEL ANALYSIS Method 1: Gel Plotting Macro: built-in macro available under Analyze – Gels Video tutorial available here: http://imagejdocu. 3. Draw a ROI using the rectangle tool across your first lane. 2. Open your image. Draw a line to define the baseline using the straight line tool.4. 26 . Use CTR-2 to copy the selection and move to the second lane. Go to Analyze – Gels – Select First Lane. Then go to Analyze – Gels – Plot Lanes. Go to Analyze – Gels – Select Next Lane. Continue until all the lanes are selected. 5. 6. 7. 9.8. These values are the relative intensities of the dots. 27 . Make sure the tolerance on the Magic Wand is set to 0. As you click on each peak. Go to Analyze – Gels – Label Peaks. 10. the area under the peak will be calculated as an area and this will go into the Results table. Select each peak using the magic wand tool. you do not make the image binary and select Limit to Threshold in the Set Measurements window.org/journal/2007/08/quantifying-western-blots-without.Method 2: Calculating intensities using ROIs and/or thresholding Some instructions for doing this manually (drawing ROIs) are available here: http://www.html You can also create individual ROIs by hand and then use thresholding to select the grayscale levels or use the Magic Wand to select each blot as a ROI and adding that into the ROI Manager. Another option to analyze the blots is to treat each spot/blot as a particle and use Analyze Particles as shown earlier.lukemiller. 28 . In this case. aspx • • • Allows you to segment standard histological stain combinations such as Haematoxylin & Eosin (H & E).nz/sms/biru/facilities/analysis_resources. Go to Plugins – Colour – Colour Deconvolution (or wherever you have placed the Plugin).ac. and DAB with counterstains such as Haematoxylin or Methyl Green. 2. Following deconvolution.COLOUR DECONVOLUTION Notes on BIRU website: http://www. You can also create your own matrices using stained sections or sample areas of your stained section using a ROI to create the matrices. Open the image. thresholding can be used to select the area of interest for measurements as described above or alternatively the image can be converted straight to a binary image. 29 . Use Process – Subtract Background if necessary to correct shadow or colour effects.fmhs. EXAMPLE 1.auckland. 3. You can then use thresholding (or make the images binary) and make your measurements. The image will then be split into 3 components. 30 . H & E. 5. Select the stain of interest. Then click OK. e. If you have a 2 colour stain. then one image should be white.g. 4.