Petiole Pro Blog

Stomata Count with AI: How to Measure Stomatal Density from Microscope Images in Seconds

How AI counts stomata on leaf micrographs: stomatal density and index formulas, sample preparation, confidence scores, on-device counting, accuracy limits and use cases.

Published on 22 October 2026 by Dr Maryna Kuzmenko

Petiole Pro cover: a smartphone showing the Count Stomata screen with a microscope image of a leaf surface, set against a larger micrograph of leaf epidermis.

Stomata count guide

Short answer: AI stomata counting uses a computer-vision model to find and count every stoma in a microscope image of a leaf surface. You give it a photo of the epidermis, often a clear nail-varnish impression of the leaf, and the model marks each stoma, gives each detection a confidence score and returns the total. Divide that total by the area of the field of view and you have stomatal density (stomata per mm²). A count that takes minutes of clicking per image by hand comes back in seconds. The stomata module we are building into Petiole Pro runs on a phone or tablet with no internet connection, so stomata can be counted where the plants grow.

The image above shows that module: a microscope image of the leaf surface goes in, a stomata count comes out. It is not publicly available yet; see early access at the end of this guide.

Key takeaways
  • Stomata are the plant's gas-exchange valves. How many there are, and how they open and close, decide how much CO₂ a leaf can take in and how much water it loses. That makes stomatal density one of the few hard physiological traits linked to water use, drought and heat tolerance.
  • The measurement is simple; the volume is not. Stomatal density = stomata ÷ area. The bottleneck is counting thousands of stomata across many fields of view, leaves, plants and treatments, consistently.
  • AI turns counting into a review task. The model detects every stoma it can find. You check the low-confidence detections rather than clicking every single one.
  • Confidence scores matter. Where you set the confidence threshold changes the count. In the example below, the total ranges from 61 to 83 stomata depending on the cut-off, so the threshold should be checked against hand counts.
  • Edge AI brings counting to the field. A model running on a phone or tablet needs no connection, keeps trial data on the device and gives a count during the same visit.
  • Validate on your own material. Species, leaf surface, impression method, microscope and magnification all affect accuracy. Hand-count a set of images and compare before relying on the numbers.
Watch: AI stomata count from photos (5 minutes). In this episode of “AI in Agriculture: One Idea a Day”, Dr Maryna Kuzmenko demonstrates the on-device stomata counting module being developed for the Petiole Pro mobile app and explains why stomata matter for plant stress, water use and climate-smart agriculture.

What are stomata?

Stomata (singular: stoma) are microscopic pores in the epidermis of leaves and stems. Each stoma is a pore flanked by two guard cells that change shape to open or close it.

Stomata do two jobs at once:

  • Gas exchange. When open, they let CO₂ into the leaf for photosynthesis and release O₂.
  • Water regulation. The same pores let water vapour escape through transpiration. That cools the leaf and pulls water and nutrients up from the roots, but it also costs the plant water.

Guard cells respond to light, CO₂ concentration and the plant's water status. When water is plentiful they swell and the pore opens; when the plant is short of water they lose turgor and the pore closes. Every open stoma is a trade-off between carbon gained and water lost, and much of crop physiology comes down to managing that trade-off.

In grasses such as wheat, barley and maize, guard cells are dumbbell-shaped and sit in rows that run parallel to the leaf veins. That regular, row-by-row layout is clearly visible in the microscope images later in this article. Wheat leaves carry stomata on both surfaces, so the upper (adaxial) and lower (abaxial) sides are usually counted separately.

Why count stomata?

Stomatal traits are set during leaf development and respond to the environment the plant grows in, so they carry information about how a plant is built to handle water, heat and CO₂. People count stomata to:

  • Breed for water-use efficiency. In bread wheat, Dunn and colleagues (2019) reduced stomatal density by over-expressing an epidermal patterning factor (EPF) gene. Plants with moderate reductions kept yields comparable with controls, including under drought and elevated CO₂, while their intrinsic water-use efficiency increased. Severe reductions cut yield. In barley, Hughes and colleagues (2017) found that lines with significantly fewer stomata had better drought tolerance and water-use efficiency with no loss of grain yield.
  • Screen genotypes and treatments. Stomatal density varies between varieties and responds to treatments, so it is a useful trait for phenotyping trials. A 2025 field study of spring wheat in Estonia found that varieties with more stomata on the upper leaf surface tended to give lower grain yields.
  • Study plant stress. Heat, drought, over-irrigation and CO₂ all affect stomatal behaviour. Linking stomatal counts to these variables turns them into a signal of how the plant is responding.
  • Reconstruct past climate. In a classic 1987 study, Woodward compared herbarium leaves collected over the past two centuries and found that stomatal numbers fell as atmospheric CO₂ rose from pre-industrial levels. Fossil-leaf stomata are now used as a proxy for ancient CO₂.
“Can you count stomata?” Dr Maryna Kuzmenko, 31 March 2025. If the post doesn't load, view it on LinkedIn.

What is stomatal density, and how is it calculated?

Two numbers describe how many stomata a leaf has.

Stomatal density (SD) is the number of stomata per unit of leaf area, usually per square millimetre:

Stomatal density (stomata/mm²) = number of stomata in the field of view ÷ area of the field of view (mm²)

For example, if a field of view covers 0.40 mm² and contains 30 stomata, SD = 30 ÷ 0.40 = 75 stomata/mm². The field-of-view area depends on your microscope and magnification, so measure it with a stage micrometer or a scale bar rather than assuming it.

Stomatal index (SI) is the proportion of epidermal cells that are stomata, introduced by Salisbury in 1927:

Stomatal index (%) = S ÷ (S + E) × 100

where S is the number of stomata and E the number of other epidermal cells in the same area. Because leaves expand by cells getting bigger as well as more numerous, SD changes with leaf expansion while SI is more stable. Researchers interested in development often report both.

Stomata counting AI is most directly useful for density, because detection and counting is exactly what object-detection models do well. Each detection also gives a position, so patterning can be analysed from the same output.

How are stomata counted by hand, and why is it a bottleneck?

The classic workflow has three stages.

  1. Make an image of the leaf surface. The most common low-cost method is the leaf impression: paint a thin layer of clear nail varnish on the leaf, let it dry, lift the film with clear tape and stick it on a glass slide. Rothamsted Research's bioimaging guide describes this method and notes that some leaves are damaged by the solvent in the varnish. Alternatives include silicone dental impression material (useful for delicate leaves or repeated sampling of the same leaf), epidermal peels, and imaging the leaf directly with a microscope.
  2. Photograph several fields of view per impression under the microscope.
  3. Count the stomata in each image, usually by clicking each one in an image-analysis program or with a hand tally counter, then convert the counts to density in a spreadsheet.

The method is cheap and well proven. The problem is scale:

  • The numbers add up quickly. Several fields of view per leaf, both leaf surfaces, several leaves per plant, several plants per plot, and several genotypes, treatments and dates soon means thousands of images and tens of thousands of stomata.
  • Counting is tiring and drifts. Is a half-visible stoma at the edge of the frame counted? Is a blurred shape a stoma or an air bubble in the varnish? Different people decide differently, and so does the same person at the end of a long day.
  • The data gets scattered. Images are sent by email or messaging apps, counts live in one spreadsheet, the trial design in another, and the conclusions in a PDF. Matching each image with the right plant, treatment and date becomes a job of its own.

This is why many groups measure fewer plants or fewer fields of view than they would like, which reduces the statistical power of the very trials stomatal traits are meant to inform.

How does AI count stomata?

Automatic stomata counting is an object-detection problem: find every instance of one type of object, a stoma, in an image. The process breaks down into a few steps.

  1. Train a detection model. A deep-learning model is trained on microscope images in which people have marked every stoma. It learns the visual pattern of a stoma (the pair of guard cells around a pore, in the context of the surrounding epidermis) and learns to ignore look-alikes such as cell walls, hairs, debris and air bubbles. Petiole's model was fine-tuned on microscope images of wheat stomata.
  2. Detect every stoma in a new image. When you give the model a new image, it proposes a location for every stoma it finds, along with a confidence score between 0 and 1: how sure it is that the detection is a real stoma.
  3. Show the detections. Each detection is drawn on the image, so you can see at a glance what the model counted and what it missed.
  4. Count, filter and summarise. Detections above a chosen confidence threshold are counted. The result is reported as a total, a breakdown by confidence level and, with the image area, stomatal density.
The Leaf Stomata Counter web app: on the left, a greyscale microscope image of a wheat leaf surface with rows of stomata; on the right, the same image with a green circle on every detected stoma; below, the counting results.
The Leaf Stomata Counter demo: the original micrograph (left), the detections (right) and the counting results (below).
Close-up of the detection output: a green circle over each stoma found by the AI on a darkened microscope image of the leaf surface, following the rows of stomata along the leaf.
Every green circle is one detected stoma. The detections follow the rows that are typical of a grass leaf.

What does the AI output look like?

Here is a real result from one wheat micrograph, as shown in our March 2025 demo.

Counting results panel showing a total of 83 stomata, the number of detections in each confidence range and an average confidence of 0.78, above a gallery of cropped detections.
The counting results panel: total count, confidence ranges and average confidence, followed by every detection as a small crop.

Average confidence: 0.78.

Two-thirds of the detections (56 of 83) have a confidence of 0.8 or more. These are clear, textbook stomata. The rest are where human judgement still helps.

This is also why the confidence threshold matters. With these detections:

  • counting everything gives 83 stomata;
  • counting only detections at 0.5 or above gives 69;
  • counting only detections at 0.7 or above gives 61.

None of these is automatically “right”. The best threshold for your material is the one whose counts agree best with careful hand counts of the same images, which is why validation is part of the workflow.

Reviewing detections, not counting them

Every detection is also shown as a small crop, sorted from highest to lowest confidence.

Gallery of small image crops, one for each detected stoma, sorted by confidence score from highest to lowest.
Each crop is one detection, labelled with its confidence score. The clearest stomata come first.
A gallery of cropped detections with confidence scores from 0.91 down to 0.70, each showing a stoma in the leaf epidermis.
Detections in the 0.91–0.70 range: still recognisable stomata, but worth a glance.

The crop gallery changes the job. Instead of clicking every stoma in every image, you scroll down to where the confidence drops and decide whether those few detections are real stomata (for example, ones that are slightly out of focus) or look-alikes. That keeps a person in control of the result while removing most of the repetitive work.

Stomata counting on your phone, offline

The obvious objection to mobile stomata counting is that “labs aren't run on phones”. That's true, but many decisions about plants are made in the field and the greenhouse, not in the lab. If a stomata count only arrives weeks after sampling, the moment to act on it has often passed.

That is why the stomata counting module we are building for the Petiole Pro mobile app runs on the device:

  • Edge AI. The detection model runs on the phone or tablet's own processor. There is no upload to the cloud and no waiting for a server.
  • No internet required. Many fields, glasshouses and growth facilities have no reliable mobile signal. The count works anyway.
  • Data stays with you. Images from sensitive breeding or commercial trials don't have to leave the device.
  • One visit: capture, analyse, act. You can compare genotypes or treatments the same day, flag plants that look stressed before wilting is visible, and decide which plots to irrigate, protect or prioritise.

The images still come from a microscope. The phone does the analysis and keeps the results with the context.

“Stomata count on a mobile device? Why on earth would anyone need that?” Dr Maryna Kuzmenko, 30 November 2025. If the post doesn't load, view it on LinkedIn.

From counting to connected data

Counting is only the first step. The module is designed so that each image stays linked to its metadata: plant variety, treatment, trial, date, location and experimental design. The count, the image and the context stay together, ready for analysis, instead of being spread across emails, chat groups, spreadsheets and PDFs.

The bigger goal is to connect stomatal density with the other variables in an experiment or production cycle, such as heat stress, water deficit or excess, CO₂ concentration and other environmental changes, so that stomata become a measurable signal of how the plant is responding.

How do you get images that count accurately?

Most counting errors start with the sample or the image, not the model. A checklist:

  1. Sample consistently. Use the same leaf (for example the flag leaf or the youngest fully expanded leaf), the same position on the leaf (often mid-way between base and tip, avoiding the midrib) and the same leaf surface for every plant you compare. Record which surface you sampled.
  2. Make thin, even impressions. A thin coat of clear varnish gives sharper detail than a thick one. Let it dry completely and avoid trapping air bubbles, which can look like stomata.
  3. Keep the impression flat on the slide, without wrinkles or folds in the tape.
  4. Focus carefully. Stomata out of focus get lower confidence scores and are more likely to be missed. If your microscope allows it, focus on the plane where the guard cells are sharpest.
  5. Use the same magnification and settings for all images in a trial. The model and your density calculations both rely on a consistent scale.
  6. Know your field-of-view area. Calibrate it once with a stage micrometer for each objective, and use that area to convert counts to stomata per mm².
  7. Take several fields of view per sample and average them. Stomatal density varies across a leaf, so one image is rarely representative.
  8. Use a consistent rule for stomata on the edge of the image, for example: count those touching the top and left edges, but not those touching the bottom and right. Apply it the same way whether the counting is done by a person or by the software.

How accurate is AI stomata counting, and what are its limits?

Published work shows that automatic stomata counting can match people closely, as long as the model has seen material like yours.

  • StomataCounter (Fetter and colleagues, New Phytologist, 2019) was trained on 4,618 images from more than 700 plant species. It identified stomata with 94.2% accuracy on species it had not been trained on, with a precision of 0.99 and a recall of 0.93 on the combined datasets. Its counts on poplar images correlated very closely with human counts (r² = 0.96), while agreement was weaker on more varied image collections.
  • StomaAI (Sai and colleagues, New Phytologist, 2023) measures stomatal pores as well as density in Arabidopsis and barley, and produces measurements consistent with those of human experts in a fraction of the time.

The lesson from both is the same: accuracy is highest on material similar to the training data and drops on unfamiliar species, image types or magnifications. Situations to watch for:

  • A new species or leaf type. A model fine-tuned on wheat will perform best on wheat and other grasses with similar stomata. Leaves with randomly oriented stomata, such as many broadleaf crops, look different.
  • Look-alikes: air bubbles and debris in the varnish, hairs (trichomes), dust on the slide and torn impressions.
  • Blur and poor focus, which push real stomata to low confidence scores.
  • Crowded or overlapping stomata, which can merge into one detection.
  • Partial stomata at image edges, which need the same counting rule as above.
  • Changes in microscope, camera or magnification between training and use.

How to validate it for your setup: choose 20–30 images that cover the range of your material: different genotypes, treatments, leaf surfaces and image quality. Count them carefully by hand, ideally with two people working independently. Then compare the hand counts with the AI counts at a few confidence thresholds. Plot AI count against hand count: a slope close to 1 and a high r² mean the model is reliable for your material at that threshold. If the differences are systematic, such as consistently missing stomata on one leaf surface, adjust the sampling or imaging, or send us examples so we can improve the model.

Who uses AI stomata counting?

  • Plant physiologists and researchers studying gas exchange, water-use efficiency, drought, heat and CO₂ responses.
  • Plant breeders and pre-breeding teams screening many lines for stomatal traits linked to water use and yield.
  • Agronomists and trial managers comparing treatments such as irrigation regimes, biostimulants or crop protection products in the field and glasshouse.
  • Greenhouse and controlled-environment growers exploring data-driven irrigation and climate control.
  • Universities and teaching labs for whom stomatal density is a classic practical exercise that is quicker to teach when counting is automated.
  • Palaeobotanists and climate scientists using stomatal density and index in fossil or herbarium leaves as a record of past CO₂.

Stomata counting in Petiole Pro

Petiole's stomata counter started as the Leaf Stomata Counter web demo shown above and is being built into the Petiole Pro mobile app as a module, alongside our other image-based phenotyping tools. It is not publicly available yet. The planned workflow is:

  1. Make a leaf impression (or prepare an epidermal sample) and photograph it under the microscope.
  2. Load the image into Petiole Pro on your phone or tablet.
  3. The on-device AI marks every stoma and returns the count with confidence scores, with no internet needed.
  4. Review the low-confidence detections in the crop gallery.
  5. Keep the image, the count and the trial metadata together, and export the results for analysis.

Petiole Pro is designed as a modular toolkit: you choose the measurements you need. Stomata counting works on microscope images, while modules such as leaf area work on ordinary photos of whole leaves next to a calibration plate. When the stomata module is released, access will be free for research organisations and universities; for commercial organisations we will agree terms to suit the project.

Frequently asked questions

What is AI stomata counting?

AI stomata counting uses a computer-vision model to detect and count stomata in microscope images of a leaf surface. The model marks each stoma, gives it a confidence score and returns the total, which can be converted to stomatal density using the area of the image.

How do you calculate stomatal density?

Divide the number of stomata in a field of view by the area of that field of view in square millimetres. For example, 30 stomata in a 0.40 mm² field of view is 75 stomata/mm². Measure the field-of-view area with a stage micrometer or scale bar for each microscope objective.

What is the difference between stomatal density and stomatal index?

Stomatal density is the number of stomata per unit area of leaf (stomata/mm²). Stomatal index is the percentage of epidermal cells that are stomata: S ÷ (S + E) × 100, where S is stomata and E is other epidermal cells. Stomatal index is less affected by how much the leaf cells have expanded.

How do you make a leaf impression for counting stomata?

Paint a thin layer of clear nail varnish on the leaf surface, let it dry, lift the film with clear tape and stick it on a glass slide. Then photograph several fields of view under a microscope. Some leaves are damaged by the solvent in nail varnish; silicone dental impression material is an alternative.

Can I count stomata on my phone?

The images are taken with a microscope, but the counting can run on a phone or tablet. The stomata module being developed for Petiole Pro runs the detection model on the device itself, so it works without an internet connection and keeps trial images on the device. It is not publicly available yet.

How accurate is automatic stomata counting?

Published tools report high accuracy: StomataCounter identified stomata with 94.2% accuracy on species outside its training data. Accuracy depends on how similar your images are to the training data, so compare AI counts with careful hand counts on 20–30 of your own images before relying on them.

What does the confidence score mean?

Each detection has a confidence score between 0 and 1 that shows how sure the model is that it has found a real stoma. Detections with high scores are almost always stomata; low-scoring ones are worth checking by eye. The threshold you choose changes the final count, so set it by comparing with hand counts.

Why does stomatal density matter for crops?

Stomatal density affects how much water a plant loses through transpiration and how much CO₂ it can take in. Studies in wheat and barley have shown that moderately reducing stomatal density can increase water-use efficiency and drought tolerance without reducing yield, so stomatal density is a useful trait for breeding and for monitoring plant stress.

Which plants can AI stomata counting be used on?

In principle any plant with visible stomata in microscope images. In practice, a model performs best on species and image types similar to its training data. Petiole's model was fine-tuned on wheat stomata, so it is best suited to wheat and other grasses with similar row-arranged stomata; other species should be validated first.

About the author

Dr Maryna Kuzmenko, founder of Petiole, smiling outdoors in front of a willow covered in catkins.

Dr Maryna Kuzmenko is the founder of Petiole, a UK company building AI and computer-vision tools that turn images into plant measurements for growers, breeders and researchers. She hosts a weekly LinkedIn Live on understanding agricultural AI, writes a LinkedIn newsletter on AI in agriculture, publishes the YouTube series AI in Agriculture: One Idea a Day and teaches the Udemy course AI in agriculture.

Early access

Stop counting stomata by hand

The stomata counting module in Petiole Pro is not publicly available yet. If you work with stomatal traits and want to try it on your own images before release, we would like to hear from you. Research organisations and universities will be able to use it free of charge.

For breeding programmes, companies and larger trials, Petiole offers pilots: get in touch at [email protected] and tell us about your species, your imaging setup and how many images you analyse each season.

References

  1. Fetter K. C., Eberhardt S., Barclay R. S., Wing S., Keller S. R. (2019). StomataCounter: a neural network for automatic stomata identification and counting. New Phytologist. doi:10.1111/nph.15892
  2. Sai N., Bockman J. P., Chen H., Watson-Haigh N., Xu B., Feng X., Piechatzek A., Shen C., Gilliham M. (2023). StomaAI: an efficient and user-friendly tool for measurement of stomatal pores and density using deep computer vision. New Phytologist 238(2), 904–915. University of Adelaide repository
  3. Dunn J., Hunt L., Afsharinafar M., Meselmani M. A., Mitchell A., Howells R., Wallington E., Fleming A. J., Gray J. E. (2019). Reduced stomatal density in bread wheat leads to increased water-use efficiency. Journal of Experimental Botany 70(18), 4737–4748. doi:10.1093/jxb/erz248
  4. Hughes J., Hepworth C., Dutton C., Dunn J. A., Hunt L., Stephens J., Waugh R., Cameron D. D., Gray J. E. (2017). Reducing stomatal density in barley improves drought tolerance without impacting on yield. Plant Physiology 174(2), 776–787. doi:10.1104/pp.16.01844
  5. Higher adaxial stomatal density is associated with lower grain yield in spring wheat (2025). bioRxiv preprint. doi:10.1101/2025.01.07.631641
  6. Woodward F. I. (1987). Stomatal numbers are sensitive to increases in CO₂ from pre-industrial levels. Nature 327, 617–618. doi:10.1038/327617a0
  7. Salisbury E. J. (1927). On the causes and ecological significance of stomatal frequency, with special reference to the woodland flora. Philosophical Transactions of the Royal Society of London B 216, 1–65.
  8. Rothamsted Research Bioimaging (2017). Measuring stomatal density using nail varnish. PDF