Image Analysis Basics 2012

26
8/13/2019 Image Analysis Basics 2012 http://slidepdf.com/reader/full/image-analysis-basics-2012 1/26 1 . ImageJ: Introduction to Image Analysis 3 May 2012 Jacqui Ross Image analysis questions 1. What do you want to measure in order to get meaningful data? Area Number of particles (e.g. cells) Intensity Size/distribution of particles Colour Particle shape Orientation Colocalisation Distance, velocity, etc. 2. Do you need to work in colour or grayscale? RGB split channels Colour thresholding Convert to 8bit grayscale 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 Median filter Edge detection Unsharp Mask/Sharpen Enhance contrast 5. Do you need to fill holes or separate joining particles? Fill holes/Erosion/Dilation/Open/Close Watershed Biomedical Imaging Research Unit School of Medical Sciences Faculty of Medical and Health Sciences The University of Auckland Private Bag 92019 Auckland 1142, NZ Ph: 373 7599 ext. 87438 http://www.fmhs.auckland.ac.nz/sms/biru/ [email protected]

Transcript of Image Analysis Basics 2012

Page 1: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 1/26

1

.

ImageJ: Introduction to Image Analysis 3 May 2012

Jacqui Ross

Image analysis questions

1. What do you want to measure in order to get meaningful data?

• Area • Number of particles (e.g. cells)

• Intensity • Size/distribution of particles

• Colour • Particle shape• Orientation • Colocalisation

• Distance, velocity, etc.

2. Do you need to work in colour or grayscale?

• RGB split channels • Colour thresholding

• Convert to 8bit grayscale • 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 i t to another?

• Regions of Interest (ROI) and ROI Manager

4. Do you need to use processing filters to facilitate segmentation?

• Background subtraction • Median filter

• Edge detection • Unsharp Mask/Sharpen

• Enhance contrast

5. Do you need to fill holes or separate joining particles?

• Fill holes/Erosion/Dilation/Open/Close

• Watershed

Biomedical Imaging Research UnitSchool of Medical Sciences

Faculty of Medical and Health SciencesThe University of Auckland

Private Bag 92019 Auckland 1142, NZ

Ph: 373 7599 ext. 87438

http://www.fmhs.auckland.ac.nz/sms/biru/ [email protected]

Page 2: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 2/26

2

AREA MEASUREMENTS

Manual approach: measure the area of s tructures by drawing a region of interest (ROI)

around them wi th one of the drawing tools , e.g. freehand, ellipse, rectangle tool.

1. Open the image. Draw the ROI.

2. Go to Analyze-ROI Manager.

3. 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 fo llowed 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 Spli t .

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/confocal image. The threshold defines the objects

that you want to measure (red overlay).

Note that if the Auto setting works well for you, you could omit this step and go straight to

Process – Binary – Make Binary ).

Page 3: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 3/26

3

3. Click Apply to make the image binary if you are not interested in intensity values. The

areas overlaid with red will be changed to 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 Fract ion in

addition to Area. Make sure that you include Display Label .

Page 4: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 4/26

4

5. Go to Analyze – Measure . The Results table will come up and you can then save this.

You can also save the binary image if you want to.

Page 5: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 5/26

5

MEASUREMENT OF NUMBER OF PARTICLES/OBJECTS

Manual approach: measure the number of objects by using the Point Selection tool.

Necessary if you are unable to threshold your images or if you need to count cells but the cellsare overlapping and will be measured as one object.

1. Click on the Point Selection tool.

2. If you have an RGB image, you can choose the colour that you want to use for the

selections by going to Edit – Options - Colors – Selection . Make sure you choose a

colour that stands out on your image.

3. You should also make the Foreground colour the same as your selection colour. This is

because once you have made the selection and clicked on another object, the selection

point will be filled with the foreground colour.4. If you have a grayscale image, you will see the colour in gray so you should choose

white/black as your selection and drawing colour. Alternatively, you could change the

image to RGB colour so that the mark is in colour. If you want to measure intensities

(grayscale) at each point, then you need to keep the image in grayscale.

5. Go to Edit – Options – Point Tool and turn on Auto-Measure . You can also choose the

size of the point you want to make to label each object. This size required will depend on

the resolution of your image. You just need it to be big enough to be able to see it. If you

don’t want to automatically label the points, you could select the option to Add to ROI

Manager . In this case, each point selection is added to the ROI Manager and you can

save the selections, etc. and make measurements as you can for any other ROIs.

Page 6: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 6/26

6

6. Now every time you click on the image, a dot will appear and the data will be entered into

the Results window. This includes the x, y z positions and the grayscale value.

7. Use the Magnifying tool if necessary to make the objects (cells) look bigger and the

Hand tool to navigate.

8. When you have completed all your measurements, you can save the image with the

marks on it.

Page 7: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 7/26

7

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. A plugin for a Chalkley grid is also available (25 random spots).

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.

1. Open the image. Change to grayscale ( Image – Type – 8bit ) or go to Image – Color -

RGB Spli t .

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.

3. Click Apply to binarise the image if you are not interested in intensity values. The stainedareas 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.

Page 8: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 8/26

8

4. Go to Analyze – Set Measurements . Choose the parameters you want to measure. You

may be interested in Shape Descriptors or Feret’s Diameter as well as the number of

particles in the images. Make sure that you include Display Label .

Page 9: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 9/26

9

5. Go to Analyze – Analyze Part icles . The success of this depends on the individual objects

being able to be clearly distinguished. Note that you can exclude based on size and

circularity. If you have calibrated your image, then this size will be in whatever unit you are

using (e.g. microns squared). You can also Exclude on Edges , which is the usual

approach since you won’t have the whole particle in the image. Record Starts combined

with Add to Manager , adds all the particle outlines into the ROI Manager.

6. Click on OK to run the analysis.

Page 10: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 10/26

10

7. If you have holes in your particles as shown below, which will affect your measurements,

you could fill these holes by going to Process – Binary – Fill Holes . 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 - Binary menu.

8. If two particles are joined together, you can use processing filters such as Process –

Binary – Watershed to separate them.

Page 11: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 11/26

11

9. You can use enhancement tools such as Brightness/Contrast or Window/Level to make

the particles easier to segment. There is also a large range of image processing filters and

operations available in ImageJ that can help to enhance contrast, etc. to make the

segmentation easier.

Note : If you don’t want the data for each individual particle, you can just save the Summary .The outline/mask image can also be saved as a record.

Classify Partic les Plugin: Gabriel Landini

This is a plugin that works very well, which allows you to classify particles based on certain

morphological attributes such as size, circularity, etc.

This plugin and information about it are available here:

http://www.dentistry.bham.ac.uk/landinig/software/classify/classify.html

Page 12: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 12/26

12

INTENSITY MEASUREMENTS

Use thresholding to select the stained area which you wish to measure

1. Open the image. Change to grayscale if necessary ( Image – Type – 8bit /16bit or Image

– Color – Spli t Channels ).

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. The displayed histogram

gives you some assistance with this.

Page 13: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 13/26

13

3. Choose Dark background for fluorescence images.

Page 14: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 14/26

14

4. Click Set to set the threshold of the image. If you want to use a consistent threshold (e.g.

based on your background value), you can type in values.

5. Go to Analyze – Set Measurements . Choose the parameters you want to measure. Make

sure that you select all the gray level measurements. You can change the number of

decimal places if you think you need more than the default (3). You should also select

Limit to Threshold . If you don’t select Limit to Threshold , then the entire image will be

measured, not just the selected area. In some cases, you do want the intensity

measurements for entire image.

6. Go to Analyze – Measure . The Results table will come up and you can then save this.

7. Intensity measurements can also be done within Regions Of Interest (ROIs), e.g. 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. In this case, you add each ROI into the ROI Manager andthen once they are all there, click Measure .

Use thresholding to select the particles which you wish to measure

Follow Steps 1-5 above then go to Analyze – Analyze Part ic les as described earlier. In this

case, the image is not converted to binary.

Page 15: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 15/26

15

USING PARTICLE ANALYSIS TO CREATE ROIS

Use enhancement filters followed by binarising to segment the objects which you wish to

measure. You can also use i t to create regions of interest (ROI), that you then apply to a

second image.

1. Open your first image (the one you want to use to create the ROIs).

2. 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.

3. Go to Image – Adjust Brightness/Contrast to improve the differentiation between the

edges of the objects and the background. You could also use Image – Adjust –

Window/Level .

4. Remove any speckle/noise by using a filter, e.g. Process – Filters – Median .

5. Go to Process – Find Edges to define the boundaries of the objects. (Various other

options such as Process – Enhance contrast can also be used prior to this operation).

(You can also try Process – Filters – Variance , e.g. radius 2 pixels for a similar result).

Page 16: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 16/26

Page 17: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 17/26

17

7. Now go to Process – Binary – Fill Holes .

8. These gaps in the outlines of the objects can be filled by going to Process – Binary –

Close . This performs a dilation and erosion operation to fill in the outline and small holes

in objects. You can also do the operations separately, i.e. Process – Binary – Dilate .

Then Fill Holes , followed by Process – Binary – Erode . You need to do the opposite

operation, i.e. if you erode, you must then dilate.

If any are not filled as

shown, it means that

some boundaries were not

complete.

Don’t worry about any

objects that are on the

image boundary. These

should not be included in

your analysis.

Page 18: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 18/26

Page 19: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 19/26

19

13. Use the Preview option to show how this will affect the image. Select Dark for a binarised

image.

Page 20: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 20/26

20

14. If you want to analyse the particles, go to Analyze – Analyze Part ic les . This also will

allow you to add the outline of each nucleus into the ROI Manager to use on the second

image.

15. Now all the measured particles are outlined and each outline is added into the ROI

Manager as a ROI.

16. Another option if you don’t want to go through the Analyse Part ic les window is simply to

go to Edit – Selection – Create Mask. You then go to Edit - Selection – Create

Selection and add that into the ROI Manager . However, in this case, you will only get one

measurement, since the selection combines all the outlines.

Page 21: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 21/26

21

Page 22: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 22/26

22

17. Now go to your second image. Convert it to grayscale.

18. Click on Show All in the ROI Manager . You will see all the ROIs on your second image

as shown below.

19. Make sure that you have all the grayscale measurement parameters selected in Analyze

– Set Measurements .

20.

Page 23: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 23/26

Page 24: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 24/26

24

Magic Wand

Using the Magic Wand and ROI Manager.

1. Open up ROI Manager by going to Analyze – Tools – ROI Manager .

2. Using the binarised image that you have already created, go to the Wand Tool, and click

on one of the filled in objects: The object should then be outlined. Click Add in the ROI

Manager window. There is a tolerance value that you can alter to expand the selection

more according to the

3. Continue until all the nuclei have had ROIs created for them.

4. Then click Save . The ROIs will be saved as a zip file called ROISet. You can change the

name if you like. These ROIs can then be applied to your second image.

5. You can also use the Magic Wand to select grayscale values.

There is a more flexible magic wand tool available at:

http://imagejdocu.tudor.lu/doku.php?id=plugin:segmentation:versatile_wand:start

There is another one which also works in 3D called YAWI at: http://yawi3d.sourceforge.net/

Page 25: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 25/26

25

COLOUR DECONVOLUTION

Notes on BIRU website:

http://www.fmhs.auckland.ac.nz/sms/biru/facilities/analysis_resources.aspx

• Allows you to segment standard histological stain combinations such as Haematoxylin &

Eosin (H & E), and DAB with counterstains such as Haematoxylin or Methyl Green.

• You can also create your own matrices using stained sections or sample areas of your

stained section using a ROI to create the matrices.

• Following deconvolution, 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.

EXAMPLE

1. Open the image. Use Process – Subtract Background if necessary to correct shadow or

colour effects.

2. Go to Plugins – Colour – Colour Deconvolution (or wherever you have placed the

Plugin).

Page 26: Image Analysis Basics 2012

8/13/2019 Image Analysis Basics 2012

http://slidepdf.com/reader/full/image-analysis-basics-2012 26/26

26

3. Select the stain of interest, e.g. H & E . Then click OK.

4. The image will then be split into 3 components. If you have a 2 colour stain, then one

image should be white.

5. You can then use thresholding (or make the images binary) and make your

measurements.