Fish fry counter based on digital image processing method

. Large quantities of ornamental fish fry can be time-consuming and error-prone to count manually. The tedious counting of ornamental fish fry can also be stressful and result in the death of the fish fry, which can result in lost sales for ornamental fish businesses. In order to solve these issues for the ornamental fish businesses, the goal of this research is to develop a system for automatically counting the number of fish fry using the thresholding and morphology methods based on digital image processing. The fish fry counter has been tested with four distinct types of fish fry, is capable of counting up to 130 fish fry in 1-3 seconds for a single operation. The final result generated by this tool are an image with a description of the total number of fish fry encountered, the date and time of data collection, and the number of fish fry detected. This information are stored in a database with .xlsx extension. The experiments result appears that this tool can count the number of fish fry corresponding to different colored fish species. However, when calculating the total amount of fish fry that can fit into the container to its full capacity, the tool has an accuracy of 95.86% and an average error of 4.14% that is caused by the side of the container which contains fish fry that are not visible to the detection camera (blind spot).


Introduction
Natural resource management is the management of natural resources such as land, water, soil, plants, and animals, with a particular focus on how management affects the quality of life for both present and future generations which deals with interaction between people and nature.Aquaculture and fisheries are one of natural management which can support sustainability of industries.Fish fry counter is one of the solutions for sustainable utilisation to improve quality of life.Ornamental fish fry are small and young fish that are used for aquarium supplies and other decorative aquatic purposes.This type of fish is often kept as a pet and valued for its bright colour, unique pattern, and interesting behaviour.Fish fry are generally small, usually ranging from 2.5 to 5 cm in length when first produced.The production of ornamental fish fry requires several techniques and special facilities.Fish hatchery and aquaculture facilities have an important influence on the production and maintenance of young fish until they are large enough to be sold to pet stores or individual buyers.These facilities must be able to provide proper nutrition, a clean and healthy environment, and regular care and monitoring for farmed fish fry [1][2][3][4].
The number of fish fry is not spared in the aspect of monitoring in fish fry farming.This is important to undertake with the aim of getting optimal results in cultivation.However, manually counting fish fry can be a time-consuming and labour-consuming process, especially if the number of fish counted is large.The manual counting process is also prone to errors because it is difficult to accurately count moving objects, especially in enclosed spaces of aquariums or fish tanks.In addition, manual counting can make existing fish fry become stressed and can even kill the fry.As a result, ornamental fish business actors in Indonesia can experience considerable losses.Therefore, this tool aims to answer the problem of counting the number of fish fry manually.
Several studies on automatic fish fry counting systems have been conducted.In another study [5][6][7], Research has been conducted on a system that applies a digital image processing process based on photos of fish eggs and performs calculations automatically using the improved counting Morphology calculation method which results in calculation accuracy of 88.2%.In research Zhang et al., [8], Lumaung et al., [9], Awalludin [10] et al., a study has been conducted that aims to create a system for calculating the number of gourami eggs automatically using the Blob Detection object identification method equipped with an Android-based GUI that produces an error percentage of 15.67% at an optimal lighting level of 106 lux.In research [11][12][13], a digital image processing system has been applied to classify fish objects and estimate their population numbers on sequential video images using the YOLO method.The YOLO method produces good performance in detecting fish objects.
This study combines fixed thresholding and Morphology image processing to identify and count fish fry objects in the image.The use of fixed thresholding is suitable because the system operates under consistent camera and lighting conditions [8,[14][15][16][17], allowing consistent detection, and counting of fish fry objects in the holding container.Morphology image processing is used to identify the shape of fish fry, making it easier to count in containers.The main challenge of overlapping fish fry is overcome by the method of Morphology, which allows adaptation of the system to changing conditions and accurate identification.The You Only Look Once (YOLO) method is not used because it is considered too advanced and takes a long processing time, not suitable for automatic counting of fish fry [18][19][20][21][22][23][24].

Research methodology
There are three stages in conducting this research, these stages are literature study, system design, and system testing.At the literature review stage, it is carried out with the aim of seeking information from books and previous studies as an effort to improve the quality of previous research.The second stage is to design the system, the working principle of the proposed system is designed to accurately count the number of fish fry with a maximum of 130 fish fry in a container using digital image processing.The system consists of a rectangular container with specific dimensions, measuring 330mm in length, 220mm in width, and 280mm in height.This container has been purposefully engineered for the containment and subsequent enumeration of fish fry.
The working process of the system commences with a camera capturing images of fish fry inside a container which will then be used as input for the system.Subsequently, a Personal Computer (PC) or laptop will process the image and identify each fish fry by using algorithms to accurately count the number of fish fry present in the image.
The system produces a numerical output that is shown on the computer monitor after analysing the image and computing the fish fry count.This number denotes the total amount of fish fry in the container, fulfilling the main purpose of providing the user with an accurate and effective means of keeping an eye on their fish fry population.The mechanical accuracy and functional effectiveness of the suggested system have been carefully considered throughout its design.This technique makes use of a 1080p camera that is placed in a strategic manner to produce high-quality pictures of the fish fries inside the containers.In addition to guaranteeing that the digital image processing software can precisely count the quantity of fish fries present, the camera can take comprehensive pictures.Together with the camera, the gadget also has LED lights.The purpose of the LED lights is to give the camera the best possible lighting, which guarantees high-quality photos.The camera will take crisp, detailed pictures in the proper illumination, giving the digital image processing software precise data to work with.
The suggested system uses a variety of digital image processing methods to compute fish fry precisely and in real time.In order to detect and measure fish fry, the system will process the photos in real-time using the OpenCV library, which is based on Python.First, the system must initialize the OpenCV library.This is a fundamental step that cannot be overstated, since it provides access to the fundamental tools and features needed for image processing.Following the library's initialization, the camera is turned on and begins to detect fish fry in the containment vessel in real time.The 'space' key on the keyboard is all it takes to snap pictures of the fish fry thanks to the system's well-thought-out design.This function minimizes the possibility of chaotic conditions affecting image quality, which is crucial for taking pictures of fish fries during moments of stability.The device continues to detect fish fry in real time even if the user chooses not to take a picture.The camera takes a colour picture of the fish fry inside the confinement vessel when the user hits the "space" key on the computer.This image is then fed into the system.The system then transforms the input image into a grayscale image.By reducing image complexity, this step seeks to expedite the system's overall processing time and make the image easier to process.
An image in shades of gray that captures the brightness value of each pixel in the image is called a grayscale image.By removing colour information from an image, grayscale conversion facilitates image processing operations like edge detection and thresholding.Grayscale images are commonly subjected to these operations due to their ability to simplify the image and facilitate the identification of features and structures.The total amount of data that needs to be processed is also decreased when an image is converted to grayscale.Three times as much data is present in a colour image as in a grayscale image, which can greatly increase processing requirements and slow down processing times.The image is converted to grayscale in order to the system operates more efficiently and rapidly.
The process of converting a grayscale image into a binary image is referred to as binary inverted thresholding, and it is the next step in the system.This is a key component because it helps set the subject of the picture in this case, the fish fry apart from the background.In order to obtain an accurate count of fish fries throughout the thresholding process, the threshold value selection is essential.An image with too much background noise will possess a threshold value that is too low, and an image with too little detail will have a threshold value that is too high.As a result, 90 is selected as the threshold value, which generates the most suitable binary image for processing by Binary thresholding is a process that converts a grayscale image to a black and white image in order to separate the image's foreground and background.The brightness value of each pixel in the image is compared to the threshold value in binary thresholding.Pixels with brightness values greater than or equal to the threshold are set to white, while pixels with brightness values less than or equal to the threshold are set to black.As a result, the image has only two levels of intensity: black and white.grayscale image into a binary thresholder image, the system can distinctly identify fish fry and determine their quantity.Subsequently, the system employs image morphology processing to detect the shapes of fish fry and address scenarios where fish fry overlap, potentially reducing the accuracy of fish fry counting.This stage involves applying morphological closing operations to the binary image.This allows the system to manipulate the shapes of overlapping fish fry in the binary image, ensuring their separation from one another.The final step in the system involves the Blob Detection process, which is employed to identify and classify clusters of fish fry within the image while distinguishing them from nonfish fry elements.Blob detection also serves the purpose of quantifying the number of fish fry clusters present in the detected image.This stage is executed by computing the number of key points, representing the central points of each detected fish fry Once the fish fry is counted, the system proceeds to annotate them with red-coloured circles for each detected fish fry during the labelling and marking process.Subsequently, the system displays the output in the form of the calculated fish fry count on the PC screen.

Results and discussion
The conducted testing of the device encompasses various aspects, including assessments involving fish samples of colours other than black, evaluations of fish fry counting amidst mixed fish fry populations, and examinations of the system's capacity to quantify the maximum fish fry load.The embodiment of the fish fry counting system, as per the designed blueprint, is depicted in Figure 5.

Testing with non-black-colored fish samples
The system operates on the principle of capturing frames from the camera, applying digital image processing techniques to detect fish fry within the images, displaying the detected fish fry count, and saving the images and calculation data into data processing software files.In this initial test, the term "non-black-colored fish samples" refers to fish fry of colours other than black.Specifically, red-colored carp fish fry was used for this initial test.
The results of the tests demonstrate that the system is capable of detecting and counting fish fry in colours other than black.This illustrates the system's effectiveness by applying image processing techniques to accurately detect such fish fry.

Testing with mixed-colored fish fry populations
The second experiment involved combining two types of fish fry, specifically black-colored serinding fish fry and red-colored carp fish fry.The purpose of this test was to evaluate the system's accuracy in counting fish fry of various colours and sizes at the identical time.
The results of the second test indicate the system is capable of accurately detecting and counting fish fry of different colours at the same time, with a 100% accuracy rate.The test outcomes emphasize the system's image processing capabilities in effectively handling the complexity of identifying fish fry of varying colours and shapes at the same time.

Testing maximum fish fry capacity counting
The subsequent phase of the testing process involves evaluating the system's ability to count the maximum capacity of fish fry, which is critical in evaluating system performance.This testing is carried out because the system's ability to count fish fry in large quantities is critical in its practical applications.Table 6 depicts the detailed results of testing on a large number of fish fry.The following testing procedure is implemented whenever testing a large number of fish fry: Initially, ten fish fry are placed in the containment vessel, and data is collected five times with 1-2 minute intervals between each data collection.The amount of error in data acquisition is calculated for each of these five data collection instances, and the results for each error are recorded in the 'Percentage Error (%)' column.Following that, the average error from the five data collection instances is calculated and entered into the 'Average Percentage Error (%)' column.After collecting data for 10 fish fry, a further 10 fish fry are included to the containment vessel, for a total of 20 fish fry.Data collection is then repeated five times, and the error in each data collection, in addition to the average error from the five data collection instances, is calculated.This process is repeated iteratively, each time adding 10 fish fry to the containment vessel, until the total number of fish fry in the containment vessel reaches 130.
Based on the results of the testing for counting a large number of fish fry, it is observed that the system exhibits varying levels of error when counting a large quantity of fish fry.The percentage error ranges from 0% to 5% for the counting of fish fry quantities below 60, which is deemed reasonably accurate.However, the percentage error increases as the number of fish fry being counted increases, with percentages ranging from 1% to 7.5% for the counting of fish fry quantities between 70 and 100, and percentages ranging from 6.36% to 10.77% for the counting of fish fry quantities between 110 and 130.

Conclusions
The conclusion drawn from the fish fry counting device utilizing image processing methods such as thresholding and morphology is that it demonstrates the capability to count fish fry within the range of 10 to 130 fish fry with an accuracy ranging from 100% to 90.47%.The corresponding percentage errors range from 1.17% to 8.64%.For future research, one potential improvement could involve transforming the device into an embedded system, making it more compact by integrating a Mini PC as the processing centre.This modification could help minimize the need for additional hardware components such as external cameras and laptops.

Fig. 4 .
Fig. 4. Blob Detection Simulation Process (a) Total number of fish is 14 (b) 12 fish detected by the system.

Table 1 .
Simulation process of converting to a grayscale image.

Table 3 .
Morphology operation simulation process.

Table 4 .
Colored fish fry counting process.

Table 6 .
Calculation results of maximum fish fry capacity.

Table 7 .
Image Processing Process Maximum Capacity of Fish Fry.