Area and size calculations using ImageJ

UPDATE! This small guide now is edited and published in UV4Plant Bulletin. Check it out here.

After learnt from Pedro, I have been using ImageJ to calculate leaf area and stomatal size. Here I write it down step by step and hope it would help.

My ImageJ version is ImageJ 1.43o. The plugins I am talking about here should be already installed once the whole software is settled down. You always can check if there are more suitable plugins for your own purpose. (http://rsbweb.nih.gov/ij/plugins/index.html)

Scale bar

For all kinds of calculation, you always need scale bar for ImageJ to convert the actual pixels on the picture into the unit you need. It should be set in the beginning so no matter what treatments you do on the image, it won’t affect the the scale in the calculation.

1. An item, e.g. a line or a cube, whose unit is clear, should be photographed with your object together. They should be kept at the same height. Then it will be the scale bar for your image.

leaf area sample

Area calculation sample image

2. Select straight line tool on tool bar in ImageJ. Drag a line along the scale bar. Enlarge your image to do it if you want more acurate result.

3. Menu>Analyze>Set Scale. In the dialog, Known Distance is the real length of the scale bar and Unit of Length the real unit. Tick “Global” if the scale bar is applied on all the images you are analyzing.

For the microsope pictures, a scale bar can also be set into the image. I am using Leica Application Suit as the software for Leica DM2500. When acquiring the image, the right lens magnification should be set and right scale bar needs to be calculated. If you are using “Default” in the calculation part, it should be just fine. One needs to go to “process” part to merge a scale bar into the saved image. Tick “Show” in Scale Bar settings. Change the length and endings if you want. In Fonts, you can select colour and size for the bar. And press “Merge” and “OK”, you will get the image with the scale bar. You can use one image merged with scale bar for all the pictures in ImageJ, choosing “Global” when setting the scale bar. But if you want to save onto every image, then go to Preference on the top of Leica Application Suit software. There is an option for the actions after saving the image. You can choose “Open in Process” so that everytime after you acquire an image, it turns to Process directly.

Lengh

It is quite simple. Select Straight line tool in the tool bar and draw the line on the object you want to measure. Go to Analyze and Measure. If you have lots of items on the image and want to mark after measuring, go to Pugins>Analyze>Measure and Label. You can set a shortcut for Measure and Label in Plugins>Shortcuts>Creat a Shortcut. A single key on the keyboard can be set. Check in Plugins>Utilities>List shortcuts to see what keys are still available. Usually all the letters and 1-5 are taken.

Area

Usually a RGB image is difficult for area calculation. So try to photograph your object on a white background shown in the sample image.

1. Split into red, green and blue channels. Image>Colour>Split Channels. It generates three individual images from the original, looking like black and white. Image titles will show each one’s channel. Usually red one is the best for analyzing.

2. Image>Adjust>Threshold. Adjust the second bar to change the colourful area which covers the area you want to calculate.

leaf area sample.jpg (red)

3. Select Rectangular tool in the tool bar to restrict the area you want to calculate. For instance, in the sample image, if no selection is made, ImageJ will caculate all the red area.

4. Analyze>Analyze Particles. I usually tick Display Results (show every lable’s area) and Summarize (the sum area of the selected). “Exclude on the edges” will eliminate the holes on the edge and “Include Holes” will add up the hole inside the area. In the Summary box, Total Area is the final result.

I tried the plugin Pedro mentioned in the comment. It is pretty handy.

  1. Install the SIOX plugin.
  2. Open the image you want to analyze, set scale and tickGlobal.
  3. Plugins>SIOX Segmentation. An individual window called SIOX Segmentation is generated
  4. Rectangular tool to select a small area on the leaf area added known as Foreground. Selection in the center of foreground area works best for me. (Any other selecting tools and smooth if you like)
  5. Press Segment. The background is darkened and the whole plant is selected. Refine if needed and then create mask. A new black and white window will jump out. Selete the area and Analyze>Analyze Particles.
  6. It can only handle one image segmentation so remember to close all the SIOX windows to begin next analysis.

In the Plugins, there are plenty of useful applications. Cell Counter, for example, would be quite a relief for cell microscope plates.

Advertisements

24 thoughts on “Area and size calculations using ImageJ

  1. Can you describe a method to measure lesion areas on a leaf using imageJ, for example leaf spots or blight caused by fungal pathogens? Thanks.

    1. I tried two sample images online.

      1. Simple colour combination: brownish lesion and green leaf. http://chatham.ces.ncsu.edu/growingsmallfarms/GSFgraphics/IMG_5390.jpg
      The version now I am using is 1.46r, slightly different from what I wrote in the post only about Plugins part. Likely, one doesn’t need to install SIOX Segmentation by themselves anymore.
      Just follow every step for scale bar set and then go to Plugins>Segmentation>SIOX Segmentation. Use select tools (I used Rectangular) to select the brown area>Segment. There it is.
      2. More colourful background: http://3.bp.blogspot.com/-YMrzd62FQlc/UDyS4-5iSdI/AAAAAAAAAO4/8K08ZdZfjts/s1600/GLS-Coalesced+lesions-42.jpg
      SIOX Segmentation doesn’t handle it very well. I splitted the colour channels into red, green and blue, as I did in the post before SIOX Segmentation. In green one, the lesion is separated from the background nicely.

  2. Thank you for these steps they have worked well. My issue now is that I’m trying to calculate the Area% of a certain particle within a certain Area (ROI). Given the leaf example above, pretend you had two leaves and both had the red threshhold within the leaf. What would you do if you wanted to measure what percentage of the red area is taking up in one leaf (and ignore the other leaf)? I tried using the magic wand to select only the particular area (i.e. leaf) but the other leaf keeps getting calculated as well when I run the ‘Analyze Particles’. I’m also getting a 0% on the %Area Result table even though the threshhold (red) area is being measured properly.

    Thanks in advance!

    Jerome

    1. You simply could try Rectangular select tool and select the area (leaf for instance) you want to measure, and then go to “Analyze Particles”. In the summary, it gives you the area the threshold occupies. Try “Add to Manager”, then it gives you the results where the particles are located. Be careful the background of your image matters severely. If the colour threshold is not sharp, you probably get lots of noise inside the image, which would be a long list in ROI manager. You can always check ROI Manager and the numbers marked on the image and select the exact area you are interested. If you are very confused, welcome to send me your sample image. I can have a look.

      1. Thanks for the reply. I’ve attached the sample image. There are 2 tumors (black) on 2 mouse outlines. I need to measure the area % of the tumor per mouse outline.

        My goal is to measure the black dot (tumor) area and divide it by the Area of the mouse outline it is located in (yellow outline). I believe this is the Area% function of ImageJ correct?

        The Area has to be precise because I need to get the area percentage of the black dot within the certain mouse outline. When I split the color channels and use the ‘Red’ channel per your instructions, I am then unable to use the Magic Wand to trace the yellow outline. I can trace the area with the ‘Freehand’ selector but it is cumbersome and I have over 100 of these to do.

        Thank you in advance for your assistance.

        thanks,

        Jerome Geronimo, RLATg jeromeg@stanford.edu

    1. Hello Jerome,
      I am terribly sorry I replied so late. I was on a trip for rather long time.

      I assume it is about rat. Forgive me if I am wrong.

      So about your sample image, either Threshold or Segmentation is doing the same trick: Turn the background (green in the sample image) and tumor (black in the image) into separate colour than the rats (yellow colour). This is the only solution I could figure out now: Calculate the size of rats and tumors separately and do the ratio by yourselves. If this is already what you figured out before, skip the followings.

      I guess you have ruler in other images and just skip Set Scale part here.

      Calculate rats one by one.
      Open the image > Process > Binary > Convert to mask > Make binary > Rectangular tool to select the rat > Analyze > Analyze particles.
      If you choose Display results and Add to the manager, it has number marking every piece; Results show the size of every piece and Summary shows the size of the area you select. If you don’t select certain rat, it turns back results of all the pieces on the entire image.

      Calculate tumors.
      Process > Binary > Make binary > Rectangular tool to select the tumor > Analyze > Analyze particles.
      Here you don’t have to convert the image. The tumors are separated directly from the the others.

      I don’t play with ROI manager at all so sorry I don’t know too much about it.

      What I wrote might be bit clumsy but this is so far what I could think out.

  3. Thank you for your good posting!!
    I also tried to measurement for the white radish leaf area.
    So I wonder about the accuracy of ImageJ tool.
    If you know that some antecedent study (paper), please let me know.

    Thanks Fang for reading my question.

    1. Thanks for reading the post! The calculation relies on the photograph pixels. Thus the accuracy is relative. If all the calculations are done in the same way, the statistic results should be trusted. Of course, if the absolute area is pursued (which sometimes is even not possible due to the imperfection of different methods), one could try the different methods to measure the area (e.g. leaf area meter) and compare the result from ImageJ. That would tell you how relatively your result from ImageJ is.

  4. Hi Fang

    I am trying to measure percentage of chlorotic area of a leaf (light green color). I need to calculate the light green color area of the leaf from the whole dark green color area? I am quite new in imagej and think threshold method could be used to do that. Can you help me please in this regard showing the steps?

    1. Hi Sabib!
      I think it is well explained in SIOX webpage:
      http://fiji.sc/SIOX:_Simple_Interactive_Object_Extraction

      About installation of SIOX, you just need to put the file into the local folder “Plugins” within your ImageJ folder.

      If you still want to use threshold, just follow the steps I explained, starting from splitting RGB channels. Green channel then might be the best in your case. But if that is not working, feel free to send me sample image.

      1. Hi Fang
        I would like to send you a sample image for analysis. how should I send it to you?

        Regards Sabib (sabib_bau@yahoo.com)

  5. Hey there!
    I’m measuring melanisation percentage coverage in ladybirds, so I need to get the area of the whole ladybird and then the area of the spots etc to work out overall percentage coverage, I’m just wondering how i’d do this? ive tried the threshold method that youve suggested but it doesnt seem to get the right parts of the ladybird, maybe due to the way ive photographed it, just wondering if you could give assistance please?

    1. The difficulty might be the surface is round instead of flat. You may not get an accurate size of the ladybug. Of course, ImageJ calculation always relies on the quality of the image. If you are taking a studio photograph on the ladybugs, larger aperture and low iso helps you have the full focus on the whole area of the ladybug. Also you could use grey card for the white balance if the light source is not very “white”, e.g. in the early morning image will be very blue or in florescent lamp irradiance image will be very yellow. You may also have shiny spots if the bug shell is waxy?

      I would not assume it is difficult for ImageJ to tell black apart from red background. Again, I don’t know how to answer properly until I could see your image…

    1. I guess “lighter” is judged by your eyes? You can use “Split the channels” to see how the feature is separated from the background in each three channels, to get some idea how to separate the object.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s