IEEE Workshop on Nonlinear Circuit Networks
December 3-4, 2021

Classification of Shiitake Mushrooms
by Using Convolutional Neural Networks
with Edge Detection Images
Kazuki Satokawa, Yoko Uwate and Yoshifumi Nishio
Dept. of Electrical and Electronic Engineering, Tokushima University
2-1 Minami-Josanjima, Tokushima 770–8506, Japan
Email:{satokawa, uwate, nishio}@ee.tokushima-u.ac.jp

Abstract—In this study, we classify shiitake mushrooms basedon whether their caps are open or not by using Convolutional
Neural Networks (CNN). We aim at improving the classification
accuracy by using edge detection. The datasets consists of images
using morphological transformation and Canny method. The
morphological gradients are used in the morphological transformation. We investigate the test accuracy using these datasets.

(a)I. I NTRODUCTION
Vegetable growers face a heavy labor burden due to long
working hours during the harvest season and inadequate working environment. A shortage of agricultural labor has become
apparent, and vegetable production is also showing signs ofstagnation. One of the reasons why vegetable cultivation is
so difficult is not only because of the manual harvesting,but also because of the enormous amount of time required
for shipping.A typical example of this is sorting, as no twovegetables are alike. There are so many things to check, suchas shape, size, surface luster, bend, uniformity of thickness,etc. And since the wrong grade to be sorted can lead tocomplaints, it is not possible to hire part-time workers tohelp only during busy times. The most problematic thing isthat spending a lot of time on this work does not necessarily
increase the yield or quality of the vegetables.Vegetable sortingis a task that we want to spend as little time on as possible.
Therefore, methods using AI and deep learning have been
proposed[1] [4].
Mushrooms have a rank, just as fruits have luxury products.
There are various factors such as roundness, thickness, andsize, but when distinguishing the rank of shiitake mushrooms,
it is important to determine whether the cap is open or not.
Currently, people are deciding whether or not the cap is open.
It is necessary to classify automatically by using AI.
In this study, we improve classification accuracy by usingedge detection. We classify images with edge detection byusing convolutional neural networks(CNN)[5]. We aim atemphasizing the difference between characteristics of shiitakemushrooms.

(b)

Fig. 1: Edge detection by Canny method(a) A original image (b) A edge detection image.

II. BASIC TECHNIQUES FOR IMAGE RECOGNITION

A. Convolutional Neural Networks
In recent years, neural networks have been applied invarious fields. In particular, the CNN has produced many
results in the image field. In image recognition, results thatexceed human ability are also seen. In this study, we perform
edge detection on shiitake mushroom images to create training
data,and classify the images from feature extraction by CNN.
CNN has convolution layers, pooling layers, and denselayers. In a convolution layer, matrix calculation is performed
using some filters, and feature quantities of the same number
as the number of filters are extraction. Next, in a pooling layer,
the feature map obtained in the convolution layer is reduced
while leaving important information. Finally, in dense layers,
a label is connected to each feature amount, and a label withhigh probability can be selected.
Such network having some layers is called deep learning,and many layers enable accurate image classification. In thisstudy, we use the CNN which has four convolution layers, twopooling layers, and two dense layers in Fig. 2.

- 52 -Fig. 2: Structure of CNN.

B. Morphology transformation
A morphological transform is a simple process that works
mainly on binary images and on the shapes in the images.
The morphological transform takes two inputs: the input
image and structural elements that determine the nature of theprocess. The basic morphological operations are contractionand dilation. Other morphological processes include opening
and closing, which are a combination of these two processes.
In this study, we used a process called morphologicalgradient, which is the difference between an inflated image
and a deflated image.

mushroom cap and 108 images with closed mushroom cap.
The test data consists of 15 images with open mushroom
cap and 15 images with closed mushroom cap. The original
images and gray images are shown in Fig. 3. First, we createan edge detection image from the shiitake mushroom images
using OpenCV. Edge extraction makes the contour clearer
than the original image. In the morphology transformationof OpenCV, the edge detection image is created with thevalues of structural elements as 10, 20, 30, 40 and 50 (Fig.
4). Furthermore, Canny edge detection is used to create theedge extraction image. Furthermore, an edge extraction imageis created by using canny edge detection of OpenCV. The
threshold values are set as 10, 20, 30, 40, 50, and 60 (Fig.
5). The created images are classified by CNN with fourconvolutional layers and two pooling layers.

(a)

(b)

(c)

(d)

C. Canny method
The Canny method is an algorithm for edge detection
published by John F. Canny in 1986[6]. It performs edge
detection by multiple steps. The process of Canny edge
detection algorithm can be broken down to five different steps:
1. Apply Gaussian filter to smooth the image in orderto remove the noise.
2. Find the intensity gradients of the image.
3. Apply gradient magnitude thresholding or lower
bound cut-off suppression to get rid of spurious
response to edge detection.

Fig. 3: Original images and gray images.
(a) A original image of a open cap. (b) A original image of a close cap.
(c) A gray image of a open cap. (d) A gray image of a close cap.

4. Apply double threshold to determine potentialedges.
5. Track edge byhysteresis: Finalize the detection ofedges by suppressing all the other edges that are
weak and not connected to strong edges.
III. P ROPOSED M ETHOD
We propose to use CNN to classify the caps of shiitake
mushrooms. The training data are 108 images with open- 53 -(a)

(b)

(c)

(d)

(e)

(f)

Fig. 5: Edge detection images of canny method.
(a) A open cap (threshold=10). (b) A close cap (threshold=10).
(c) A open cap (threshold=30). (d) A close cap (threshold=30).
(e) A open cap (threshold=50). (f) A close cap (threshold=50).

IV. S IMULATION RESULTS
(e)

(f)

Fig. 4: Edge detection images of morphology transform.
(a) A open cap (kernel=10). (b) A close cap (kernel=10).
(c) A open cap (kernel=30). (d) A close cap (kernel=30).
(e) A open cap (kernel=50). (f) A close cap (kernel=50).

(a)

(b)

The number of epochs is 100, the optimizer is Adadelta,
and the Batch size is 32. The original images and the grayimages are classified by using CNN, and the average of fivetimes is taken. These results are shown in Table I. The test
accuracy is 0.800 when the CNN learns original images. In
other words, gray images are more effective than color images
for shiitake mushroom caps classification. The images createdusing morphological transformation are classified using CNN
and the average of five times is taken. These results are shownin Table II. The test accuracy is the best, 0.881 when the valueof kernel is 40. The accuracy tends to get better as the valueof kernel is increased. The test accuracy of images createdusing morphological transformation is not as good as the test
accuracy of Gray images.
The images created using Canny method are classified using
CNN and the average of five times is taken. These results areshown in Table III. The test accuracy is the best, 0.956 whenthe value of threshold is 30. The test accuracy of the image
created using the Canny method is better than the test accuracyof the Gray images.
TABLE I: Test accuracy of original images and gray images.
Data set
Original images
Gray images

Test accuracy
0.800
0.938

TABLE II: Test accuracy of images with edge detection of morphology
transform.

(c)

Data set
Edge detection (kernel is 10)
Edge detection (kernel is 20)
Edge detection (kernel is 30)
Edge detection (kernel is 40)
Edge detection (kernel is 50)(d)- 54 -

Test accuracy
0.788
0.813
0.819
0.881
0.863

TABLE III: Test accuracy of images with edge detection of Canny method.
Data set
Edge detection (threshold is 10)
Edge detection (threshold is 20)
Edge detection (threshold is 30)
Edge detection (threshold is 40)
Edge detection (threshold is 50)
Edge detection (threshold is 60)

Test accuracy
0.894
0.881
0.956
0.950
0.819
0.729

V. C ONCLUSIONSIn this study, we classify shiitake mushrooms based onwhether their caps are open or not by using CNN. We tried toimprove the classification accuracy by using Edge detection.
Edge detection images were created using morphologicaltransformation and Canny method. Original images, Grayimages, and the created edge detection images were classified
by using CNN. From the simulation results, it was found thatthe edge detection images were effective in classifying whether
shiitake mushrooms were open or not.
The test accuracy of the edge detection images using themorphological transform is higher than that of the originalimages, but lower than that of the Gray images. Increasing
the value of kernel tends to improve the test accuracy.
The test accuracy of the edge detection images using theCanny method is higher than the test accuracy of the originaland Gray images. The accuracy is best when the thresholdvalue is 30.
These results show that the classification accuracy is higher
when the contrast is clearer by using CNN to classify whether
shiitake mushroom caps are open or not.
In the future, we will investigate the classification accuracy
in networks other than CNN.
R EFERENCES[1] Pepito Menguito Bato, Masateru NAGATA, Qixin Cao, Kenji Hiyoshi,
Takao Kitahara, “Study on Sorting System for Strawberry Using Machine Vision (Part 2),” Journal of JSAM 62(2): 101-110, 2000
[2] Jeong, S., Lee, YM. Lee, S., “Development of an automatic sorting
system for fresh ginsengs by image processing techniques,” Hum. Cent.
Comput. Inf. Sci. 7, 41 (2017).
[3] S. Dhakshina Kumer, S. Esakkirajan S. Bama, B. Keerthiveena, “Anautomatic sorting system for fresh white button mushrooms based onimage processing,” Computers and Electronics in Agriculture, volume.
151, pp. 416-425, 2018.
[4] Fengyun Wang, Jiye Zheng, Xincheng Tian, Jianfei Wang, Luyan Niu,
Wenjie Feng, “A microcontroller based machine vision approach fortomato grading and sorting using SVM classifier,” Computers andElectronics in Agriculture, volume. 76, 2020.
[5] A. Krizhevsky, I. Sutskever and G. Hinton “ImageNet Classification with
Deep Convolutional Neural Networks,” Neural Information ProcessingSystems(NIPS), pp.1097-1105, Dec. 2012.
[6] J.Canny, “A computational approach to edge detection,” IEEE Trans.
Pattern Analysis and Machine Intelligence,8, pp. 679-714, 1986.

Acknowledgement
This work was partially supported by TOKUSHIN ELECTRIC INDUSTRIES CO.,LTD.

- 55 -