Automatic stomata phenotyping

Hi everyone,

I’m trying to do an automatic stomata phenotyping based on this paper :

Image-based stomata phenotyping

I don’t have much knowledge in programming and I don’t really know where to begin.

I’m pre-processing images following instructions in the paper :

  • Setting image 8-bit grey scale
  • Applying a gaussian blur
  • Substracting the resulting image to the original one
  • Making it binary

And I end up with this :

Result of 04032019_KO5_RC_2-1.tif (1.3 MB)

Here is the original one :

I can create a macro to easily automate this part and run it in batch using the macro recording tool.

After that step, I’m launching the Template matching pluging from Fiji (

Using templates of Stomata like this one :

Template_KO_test.tif (3.1 KB)

It works just fine but it only counts stomata in the exact same positions. The reference paper advices to multiply templates and make them rotate to have better results. They also implements functions to avoid false positive. But here is the problem, the pluging can only run with one template and once you want to run it again with an another template, it reinitialize all the data. So the solution could be asking Fiji to keep data and overlay until you process all the desired templates with different angle. This is the part that goes beyond my habilities in programmation.

Here is what I manage to understand for the next part, once the pluging recognize stomata they use Plot Profile (Analyze > Plot Profile) within ROIs to obtain certain values like stomata apertures, stomata widths and stomata lenghts. I know how to do it using Fiji but I don’t know how to do it within a macro with Fiji language.

I know that there is a lot of programmation work here but if you have at least intels to help me in this work that could be really great.

Thanks a lot,

Thomas A.

Hello Tamoroso,
The first and main problem is the uneven illumination. ImageJ/Fiji has a plugin available called Polynomial Shading Corrector which will help very much.
I would use it Prior to any other steps with the image.
There are several other things you may try and I will suggest some more after I examine the image in more detail. Do you have several of these type images? In case a macro may be called for.

Hi smith_roberj,

Thank you to spend time on my problem. Yes I’ve noticed the uneven illumination but I’ve tried the plugin Polynomial Shading Corrector. And I can’t find out how to run it. I’ve been following all instructions to a proper installation of the pluging without success.

I have 57 images like this one to analyze and 3 times more to come. So the automation could give me a hand.

For now, i’m using illastik to do object predictions and using the function analyze particles within a macro to automatically count stomata. It’s not perfect yet but it’s doing the job. Unfortunately, that solution doesn’t allow me to precisely measure stomata.

Hello Tamoroso,

Yes it is in need of more documentation but I will try to explain how it works.

In any case this is not a situation where ‘more is better’ due to its sensitivity… The input X-Y perimeters are based on the Aspect Ratio of your image. In your case it is 3 in the Y axis and 3.786 in the X axis. with 1.262 A/R. The Aspect ratio
is determined by the width divided by the height of the image so with a goal of 3 of correction you would set the inputs as indicated. With this type of math it does not take much of a change to impact the leveling of the background. The default values work
for most imaging of small items like cells or smaller. You will want to set Reg to 2% which is ‘how close to the maximum’ you want to correct to. Again, a very small change will make a large different. I used your example to determine these settings and it
made a huge difference.

Afterwards use the Image > Adjust > Brightness/Contrast. I used the Auto mode.

I do not know who wrote the plugin but it has come in very useful in a wide variety of situations and many more would use if it had better documentation.

Now for just exactly do you wish to segment in this image? There are various ways to accomplish that task and all the necessary steps can be put into a macro for mass reproduction if the images are consistant in every way (size, brightness,etc…etc…)

Attached are your reference images Before/After so you can see the difference. The dynamic range of the image is not very great so you have to take care and may need to use a combination of different techniques to accomplish the goal. Let us know
your exact specifications and we will work on that. Remember ‘small changes make big differences’.


Indeed, it’s very poor in documentation. Thank you for this explanation. The result is great. The thing is that I can’t even make the plugin works properly because imageJ threw me an exception. You can find it her :

After correction of images, I would like to isolate stomata


And I would like to measure at least the lenght of each of them. And optionnaly, the aperture in the centre (ostiole) and the width (two guards cells + ostiole) (Sometimes difficult to do because of air bubbles)

I think it could be possible with ilastik to cut out the background of the original image by applying the object prediction. Maybe @ilastik_team know how to do such thing but after several try I’m enable to do it.

Well Hello again,
It seems as though the main and first problem is to smooth out the background which you attempted to do and received an error that I have never seen.
Is your ImageJ/Fiji updated regularly? And did you get the plugin from the ImageJ site?
The measurments you require can certainly be done in the program. Please double check the updates on each and reapply them.
There are also several other plugins to smooth out the background you can try, but may loose accuracy in detail.
I am not very familiar with ilastik but I will look into why you cannot get the plugin to run. I don’t know who wrote it but it should be fixable.

Ilastik indeed performs nicely with that image.

From the label2 prediction image, you could measure the fit ellipses of your stomata and get a good estimate of their length and width.