hilum

Blog · Bench

Light decides the outline

Raking light stretches shadows and merges neighboring seeds. Overhead light causes glare. Between 35° and 65°, with a diffuser, the outline stays clean.

October 30, 2026 · 5 min read · by Enrico S. Ambrosio

Before any algorithm, the light has already decided a good part of the outline. A seed's shadow shows up in the photo as a dark smudge stuck to it. On a light background, the program can merge shadow and seed into one object.

The animation above is a simulation seen from the side. Two model seeds, 1.4 mm tall, sit 2.0 mm apart. Only the height of the light changes.

A bit of trigonometry

The size of the shadow comes from a single formula.

shadow = height ÷ tan(light elevation)

With the 1.4 mm tall seed, the math goes like this.

  • At 45°, the shadow is 1.4 mm, because tan(45°) = 1.
  • At 35°, the shadow reaches 2.0 mm and touches the neighbor.
  • At 18°, the shadow is over 4.3 mm.
  • At 65°, it drops to 0.65 mm.

In a photo at 40 px/mm, the 4.3 mm shadow takes up 172 pixels. That is almost double the width of the model seed, which is 2.3 mm. The scale math is in the post The DPI declares, the ruler measures.

Eratosthenes did the same math

This formula is more than two thousand years old. Around 240 BC, Eratosthenes measured the shadow of a rod in Alexandria on the day when, in Syene, farther south, the noon Sun cast no shadow at the bottom of a well. The shadow gave an angle of 1/50 of a circle, about 7°. Since the two cities were 5,000 stadia apart, the full circle of the Earth would be 250,000 stadia.

Diagram of the Earth with parallel sunrays reaching Alexandria, where a rod casts a shadow, and Syene, where a well has no shadow, with both lines meeting at the center of the Earth and a map of Egypt alongside.
Eratosthenes's calculation. The angle of the shadow in Alexandria equals the angle between the two cities, seen from the center of the Earth (diagram by cmglee, David Monniaux and jimht, CC BY-SA 4.0).

Eratosthenes used the shadow to measure the Earth. At the bench, we want the opposite: a shadow so short it stays out of the seed measurement.

Neither raking nor overhead

Low, raking light stretches the shadow. Below 35°, in the simulation, one seed's shadow touches the next one, and the algorithm may see two seeds as one.

People who study ancient coins, carvings and paintings use raking light on purpose. The long shadow brings out any relief. It is great for reading a worn inscription and terrible for measuring the outline of a seed.

Three photos of the same corroded ancient coin side by side, with light coming from different directions and the relief showing differently.
The same ancient coin photographed three times in raking light, each time from a different side. The relief changes with the direction of the light (photo by Pippa Pearce, British Museum, Portable Antiquities Scheme, CC BY 2.0).

High light, almost overhead, shortens the shadow but creates another problem. The smooth seed coat bounces the light back to the lens, and a white glare appears on top of the seed. That glare can be read as background and open a hole in the outline.

Between 35° and 65° is the range we recommend. A diffuser in front of the lamp spreads the light and softens the edge of the shadow. Two panels on opposite sides balance one shadow against the other.

White wall with a relief artwork and a low lamp casting long, slanted shadows.White light box with lamps covered by diffusers on both sides and on top, and a camera in silhouette in front.
Left, raking light on a wall, with the shadow stretched out (photo by Jonn Leffmann, CC BY 3.0). Right, a homemade light box, with diffusing fabric and lamps on both sides and on top (photo by Alison Christine, CC BY 2.0).

In practice: light seed, dark seed

In a public set of faba bean photos, with a ruler and a blue background, we measured 160 seeds in SeedCounter and compared them with the authors' own analysis. In the photos of light seeds, the outline sits on the edge and the mean length agrees within 2%. In two lines with dark purple seeds, the shadow is almost the color of the seed's edge, and the outline spreads over it: length grows 6 to 7% and width 13 to 17%.

Four SeedCounter crops on a blue background. Top, a light faba bean seed before and after the click, with the cyan outline hugging the edge. Bottom, a dark purple seed before and after the click, with the outline spreading over the shadow along the top and left.
Faba bean, photos by Ortega Polo and Larkan (2026, CC BY 4.0). Top, the outline stays on the edge; bottom, it takes in the shadow along the top and left.

Even the scanner casts a shadow

A flatbed scanner looks free of this, because the light runs right against the glass. But the lamp comes from one side. In 10 soybean scans from a public dataset (Syahraza et al., 2025, CC BY 4.0), we measured the background brightness around 1,078 seeds, out to 1.9 mm from the edge, in each direction.

On the top side of the image, the background is already bright 0.1 mm from the seed. On the bottom side, the shadow starts out very dark and only fades out near 1.6 mm. Its half-width is 0.73 mm, about 23 pixels at 800 dpi. On the sides, the shadow is fainter and longer.

An outline that mistakes this band for the seed makes the measurement larger, and in the same direction for every seed. In the soybean post, on November 3, we show how large that effect is in a public dataset.

What the app does with the leftover shadow

Some shadow always remains. SeedCounter looks for the seed's edge by color, and with a well-contrasted background the shadow stays out. With a dark seed, like the purple faba above, part of it can get in; recognizing the shadow in the image itself is the app's next step. When a shadow joins two seeds, it proposes splitting them, and you choose whether to split or keep them. At the bench, it looks like this.

The same plate with raking light and with 45° light and a diffuserF04 · recording script
Real footage coming soon · F04The same plate with raking light and with 45° light and a diffuser

Light, background and ruler are set once, during bench setup. After shooting, check the outline in SeedCounter.

Sources

  • Eratosthenes and the measurement of the Earth's circumference. Wikipedia
  • Syahraza et al. (2025), soybean seeds of three Indonesian varieties, Mendeley Data, doi:10.17632/c733bjz4m3.3, CC BY 4.0. The shadow calculation is in _src/real/soja/sombra.py.
  • Ortega Polo and Larkan (2026), faba bean photos with a ruler, AAFC, CC BY 4.0.

For the full math: The threshold, with Otsu running on real images and where it fails.

lightshadowbenchsegmentation

Now with your image.

Count, classify and measure your seeds in SeedCounter, right in the browser.

Open SeedCounter