Instruments & Data Tools: solutions for sensing, imaging, analytics

Instruments & Data Tools is specialising in custom algorithms and instrumentation for spectroscopy and imaging.
We develop solutions for science and industry.

Automated kernel shrivel detection of walnuts in shell

Walnut kernel shrivel can be caused by water stress (either too dry or too wet), sunburn or walnut tree diseases. Shrivel may occur in conjunction with a change of colour of the pellicle surrounding the kernel without any of these being evident on the outside of the shell.

Nothing beats x-rays to find out what’s hidden inside opaque and dense object. So, once we heard about the kernel shrivel problem we set out to try x-rays at once. Here’s a simplified report of our preliminary work, which we decided to put out there to look for potential interest in the industry.

X-ray imaging of walnuts in shell

We imaged 166 walnut samples, kindly provided by Quality Walnut Producers Pty Ltd. The imaging work has been done in the x-ray lab of Dr Marcus Kitchen at Monash University. We used a medical (mammography) x-ray unit and a flat panel digital detector. The x-ray unit was set to 35 kVp and 50 mAs. Walnut samples were placed in close proximity of the flat panel detector to acquire images. All walnuts samples were placed in approximately the same orientation with respect to the detector.

Some result

Here’s the image overview of some of the samples we measured. We made sure to have a wide range of size and shell colour. Moreover we used walnuts from different growing regions around Victoria and New South Wales.

Automated kernel shrivel detection of walnuts in shell

As a starting point of our analysis, we classified the walnuts by visual inspection of the x-ray images as having 1) normal kernel, 2) kernel with mild shrivel and 3) kernel with significant shrivel. An example of the three types is below. Left: normal kernel. Middle: mild shrivel. Right: Substantial shrivel.

Automated kernel shrivel detection of walnuts in shell

Automated kernel shrivel detection

We developed an automated sorting algorithm which, starting from the x-ray images, returns a binary classification, either normal or shrivel kernels. After that we quantified the performance of the automated algorithm, by comparing the results with the visual classification.

To run a binary sorting of the kernels, we run a Principal Components Analysis, PCA (see these posts for an introduction to PCA and PCA classification of macadamia kernels), and build a score plot of the results as a function of the first two components. The scatter plot is shown below using two types of labeling. The top graph contains the score plot labelled with the result of the automated algorithm (shrivel kernels in yellow). The plot at the bottom is instead labelled using the visual inspection, where yellow is the substantial shrivel, blue is the mild shrivel and purple is the normal kernels.

The numbers next to each dot represent the walnut ID, from 1 to 166.

Automated kernel shrivel detection of walnuts in shell
Clustering results

By visually inspecting the scatter plots, we note that all but one of the walnuts with severe shrivel are recognised by the automated algorithm. The mild shriveled cases are only partially recognised in this modality, owing to most of them being clustered together with the normal kernels in the PCA process.

To produce a quantitative evaluation of the performance of the automated sorting on the substantial shrivel case, we measured sensitivity and specificity of the algorithm. Results are:

  • Sensitivity (percentage of the kernels with severe shrivel that are rejected by the sorting algorithm): 86.7%
  • Specificity (percentage of normal kernels that are accepted by the sorting algorithm): 88.7%

The results of this preliminary analysis, show that our automated sorting algorithm is able to detect and reject shriveled kernels with very good accuracy. There is definitely room for improvement, ideally bringing both specificity and sensitivity around 95%.

For that, we anticipate that a more comprehensive sorting algorithm, able to handle the intermediate cases of mild shrivel, can be implemented with a supervised learning algorithm, starting from the preliminary clustering shown here. More samples are likely to be required for a supervised learning algorithm to be successfully tested.

That’s it for today. Hope you found this interesting, and thanks for stopping by!