Sagitto uses machine vision to measure colour
Machine Vision

More Than Meets The Eye

January 13, 2025
  •  
3 minutes
George Hill
Sagitto Ltd

Sagitto has found that we can build significantly better models if we combine machine vision with spectroscopy. Since much of our work in this area is commercially confidential, here we give a simple example using bananas. We compare the results of three models that each predict the Total Dissolved Solids (Brix) of the same group of bananas. The first model uses only machine vision, the second model uses only NIR spectroscopy, and the third model uses a fusion of machine vision and NIR spectroscopy data.

Banana Sugars

Green bananas have a very high starch content and are not suitable for eating raw. However as bananas ripen, their starch converts to fruit sugars and the raw fruit becomes readily digestible. A common method for measuring the conversion of starch to sugars in fruit is to use refractometry, to measure the Total Dissolved Solids expressed as degrees Brix (°Bx). One degree Brix is equal to one gram of sucrose in 100 grams of solution.

The procedure that Sagitto used was to take a 30gm portion of flesh from the centre of the banana, and blend this for 30 seconds with 90ml of water. The resulting mixture was measured with a digital refractomer. The mean of triplicate readings was multiplied by three, to account for the dilution effect of the water3.

Brix for 113 bananas were measured in this way. Values ranged from 1.4 °Bx to 17.4 °Bx, with a mean value of 10.9 °Bx

Machine Vision and Bananas

The bananas were placed in simple lightbox, illuminated with LED light strips, and photographed using an iPad camera. Each banana had a unique 3-digit label. A machine vision application was created to automatically read these labels  and the banana image. The average colour of each banana image was measured, and the detailed colour information was stored in Sagitto's servers along with the image itself.

Example QR code linked to report of banana colour
B226 Report

For each banana, a report was produced and a unique QR code was generated. Clicking on the QR code opens up a more detailed report and gives access to the source image.

An example of using machine vision to measure the average colour of a banana
Analysis of average colour for banana B226

Hue Angles

The iPad camera recorded colours as triplets of red, green and blue values. We transformed these into the HSL (hue, saturation, luminance) colour space, and used the hue angle as the main characteristic to differentiate individual bananas. As the plot below shows, hue angles in the training set ranged from 31 degrees to 77 degrees.

Distribution of colours for bananas used to create fusion model
Hue values for bananas range from 31 to 77 degrees
Hue angles ranged from 31 degrees for very ripe bananas, to 77 degrees for very green bananas

Ripeness versus Sweetness

We can easily determine the ripeness of a banana by touch, and using our own eyes to assess colour changes in the fruit skin. However ripeness doesn't always equate to sweetness. One surprising result of our experiment was that sometimes two bananas with very different degrees of ripeness (as indicated by their colour and firmness) could have very similar Brix levels.

Brix of banana B208 measured using Sagitto NIR instrument
Banana B208 had an average hue angle of 63.46 degrees, and a (destructively) measured Brix of 14.4 degrees.
Sagitto report of Brix level in a banana, measured using NIR
Banana B226 had an average hue angle of 48.93 degrees, and a (destructively) measured Brix of 14.4 degrees.

While Brix is a useful and objective measure of fruit 'sweetness', it does have one big drawback : it is a highly destructive method of measurement! Perhaps one might be able to apply machine vision and NIR spectroscopy to predict Brix levels in bananas, leaving the bananas free to be eaten another day?

Predicting Brix Using Machine Vision

We used the colour data collected from our machine vision application to build a model that predicted Brix of bananas, using only the colour data. As the following plot shows, there was a reasonable relationship between colour and Brix levels - but as we have already shown with bananas B208 and B226, predicting the Brix of an individual banana just using its colour is not a very reliable approach.

Brix predicted using only the average colour of bananas
Brix predicted using only the average colour of bananas

Predicting Brix Using NIR Spectroscopy

We used Sagitto's miniature NIR spectrometer to scan each banana, and built a machine learning model using only this NIR data. The resulting model was considerably better than the one built just with colour data. However we suspected that if we could combine both colour and NIR data, we might be able to get an even more accurate model.

Brix predicted using only near infrared spectra from banana skins
Brix predicted using only near infrared spectra from bananas

Predicting Brix By Combining Machine Vision and NIR

As we suspected, when we built a model for Brix of bananas using both colour and NIR data, the result was even better.

Brix predicted using colour data from a machine vision application combined with near infrared spectra
Brix predicted using colour data from a machine vision application combined with near infrared spectra

Timing Issues With Sensor Fusion Models

What we have described above is a form of sensor fusion. One of the key challenges with sensor fusion applications is timing - data from different sensors is collected at different times, which means that models that rely on data from multiple sensors needs to be intelligent enough to know when all the data is available. Sagitto addresses this timing challenge by using AI Agents, that access the data through our API. But that is a story for another time.

Conclusion

Visual inspection by itself can be insufficient to identify the 'sweetness' of fruit, as measured by Total Dissolved Solids. However when image data is combined with NIR spectra then accurate models for measuring fruit sugars are much more achievable.

References

1. Liew, C.Y. & Lau, C.Y.. (2012). Determination of quality parameters in Cavendish banana during ripening by NIR spectroscopy. International Food Research Journal. 19. 751-758.

2. Ofosu, D.O., Appiah, F. and Banful, B. (2020) Interactive Effect of Variety and Irradiation Dose on Postharvest Behaviour of Fruits of Two Plantain (Musa sp AAB) Varieties from the Green Stage to the Onset of Ripening. American Journal of Plant Sciences, 11, 372-381.https://doi.org/10.4236/ajps.2020.113027

3. Mendoza, Fernando & Aguilera, J.M.. (2006). Application of Image Analysis for Classification of Ripening Bananas. Journal of Food Science. 69. E471 - E477. 10.1111/j.1365-2621.2004.tb09932.x.

4. Lien, Nguyen & Baranyai, Laszlo & Nagy, David & Mahajan, Pramod & Zsom-Muha, Viktória & Zsom, Tamás. (2021). Color analysis of horticultural produces using hue spectra fingerprinting. MethodsX. 8. 101594. 10.1016/j.mex.2021.101594.

Subscribe to Sagitto's Blog

Get industry insights that you won't delete, straight in your inbox.
We use contact information you provide to us to contact you about our relevant content, products, and services. You may unsubscribe from these communications at any time. For information, check out our Privacy Policy.
George Hill
Sagitto Ltd
Sagitto's founder, George Hill, first started working with artificial intelligence during the 1980s, while developing 'expert systems' within Bank of America in London. On returning to New Zealand, he undertook part-time study with the University of Waikato's Machine Learning Group while working for Hill Laboratories, a well-known New Zealand commercial testing laboratory. This led to the formation of Sagitto Limited, dedicated to combining the power of artificial intelligence and machine learning with spectroscopy.

More news

Data Science

Learning From Pasta

Good pasta is made from durum wheat flour rather than the softer wheat varieties used in bread. However being more expensive, durum flour ('semola rimacinata') is sometimes adulterated with other wheat flour. For a bit of fun, we've created a model that detects potential adulteration of durum wheat flour. And we use this to demonstrate how Sagitto evaluates calibration models.

Read Article
Data Science

A Journey Of Discovery

The process of building accurate predictive models for spectroscopy instruments is often a journey of discovery, with many twists and turns. Once we have an initial model, every step of the process deserves scrutiny. Are we using the best method of sample preparation? Is our reference data accurate and reliable?

Read Article
Authentication

Is This Pure Silk?

Silk has been a premium fibre for textiles for millennia. Sagitto provides a rapid and non-destructive way of determining whether a textile is genuine pure silk, a blend of silk with another fibre, or made entirely from another fibre. This is especially valuable for collectors of antique clothing or rugs, and buyers of premium label garments.

Read Article