Real Time Implementation of Detection of Bacteria in Microscopic Images Using System Generator

This paper outlines efficient hardware architecture of detection of bacteria and alga in microscopic images, using Xilinx System Generator (XSG). XSG is a high-level design tool based on blocks. It gives bit and cycle accurate simulation. The approach of detection used is the Hough transform. The latter is a very efficient approach of location of parametric curves in an image, especially lines. System was implemented on Virtex-V FPGA. To demonstrate the quality of the system, some experiments on microscopic images are given.


Introduction
In the last few years, there has been an increasing tendency to implement Digital Signal Processor (DSP). DSP functions in Field Programmable Gate Arrays (FPGAs). FPGAs provide an attractive approach in comparison with conventional devices. They offer a very interesting solution that balance high flexibility, cost, time-to-market and performance [1,2]. Although Application-Specific Integrated Circuit (ASICs) and DSP chips have been the traditional solution for high performance applications, now the new technologies are imposing new rules. On one side, high development costs and timeto-market factors associated with ASICs may be prohibitive for certain applications, and on the other side, programmable DSP processors may be unable to achieve a desired performance because of their sequential execution architecture.
In this aim, the hardware level implementation is utilized because we need to process the image in real time. The hardware implementation offers also parallelism and it reduces the processing time. Our algorithm is encoded using XSG, which has been the tool of many researchers in several areas [3,4]. It is a graphical interface added to Matlab Simulink. Its library has a collection of many hardware blocks that can achieve complex functions.
In the digital image processing area, there are several methods of detection of objects in images [5,6]. Each method has different issues and different characteristics. Among them, the Hough transforms is very accurate in detecting parametric curves in an image. It is used in many researches, such as traffic and medical applications [7,8].
In the field of medical image processing, many studies have been carried such as the segmentation, classification and recognition of MRI and microscopic images [9,10]. In this case, our work focuses on the implementation of a real-time system of detection of linear alga and bacteria in microscopic images, using the Hough transform. The platform used is the Virtex-V FPGA. Our method is evaluated and improved by experimental results.
This paper is organized as follows. In Section 1, we present the XSG: its features, strengths. Section 2 addresses the overview of our system of detection. Section 3 gives the details of the hardware architecture. Experimental results are given in Section 4 and section 5 summarizes this paper.

Design flow
The proposed architecture is developed by the integrated design tool XSG dedicated FPGA. Unlike the standard HDL language, XSG provides an interface based upon a pattern using an extended library of construction blocks [11]. It takes the abstraction level slightly higher. It uses the Mathworks Simulink with a list of specific Xilinx building blocks, which can be used to create designs optimized for Xilinx FPGA's [4]. The Matlab workspace can be used during simulation.
Once the model is designed with XSG, the VHDL or Verilog code may be automatically generated. Each HDL file is related to an XSG building block. After that, the logic synthesis and routing steps should be performed [4,12]. Otherwise, simulation and testbench are not complicated by the generation of test vectors. The upload of this architecture on the FPGA will be possible using Xilinx Chip-Scope Pro tool [12]. The design flow of the XGS development tool is given in figure 1.

Loading digital data on XGS
Unlike software processing, XSG manipulates images as onedimensional vectors in place of 2-d matrix [13]. By this conversion, the (x, y) pixel in the (m,n)original image will have the ( ) y 1 * n x − + position in the output vector. After this, the image is stored in an input ROM to be ready to handle. The image conversion is shown in figure 2.
After applying the pre-processing steps, we applied the Hough transform to the binary image. This transformation is to locate the linear bacterium. Finally, we attain the features extraction step (slope and length of bacterium).

Architecture of Bacterium Detection Using XSG (Section 3)
The architecture of the linear bacterium detection is shown in figure  4. Data are acquired and transformed to 1-dimensionnal vectors. The blocks of preprocessing are given in the same order listed previously in section 3. The result of each pre-processing step (grayscale conversion, filtering, thresholding) is sent to the Workspace of Matlab. These results are reconverted to 2-d matrix in order to display it as an image. The length and the slope of the linear bacterium are displayed on XSG window.

Grayscale conversion
Images used are in the RGB space. They have three color components R, G and B. To facilitate their manipulation, searchers always try to have one component image that models the original image. Rahatabad et al. [14] used a ratio between the intensities of specific RGB components and the sum of their intensities. This report is used to detect bright colors in images.
In our research, microscopic images are converted to grayscale. We begin first by storing the color components of the input image. The grayscale conversion is the determination of the luminance Y of the YCrCb space. Y is the module that adds the components R, G and B. Each component is assigned by a coefficient using the following formula: The hardware architecture of grayscale conversion is shown in figure 5.

Filtering and thresholding
We started by a filtering step to reduce noise and small details. It is a smoothing step, in which we use the first derivative [15] of the image I, as shown in the following formula: x For the simple approximation of the discrete derivative, we convolved the image with the following mask: The hardware architecture of filtering is shown in figure 6.
The thresholding operation transforms the filtered image f to a binary one b. Pixels will be arranged according to their superiority at a chosen threshold T, as shown as followed: Figure 7 shows the hardware architecture of the thresholding implementation. The desired threshold is given by the input parameter 'Constant2'.

Hough transform
Principle: The principle of the Hough transform is to associate to each bright pixel in the Cartesian space (x, y)a sine wave in the Polar space ( ) r, θ . The advantage of using the polar space is in alignment  [7]. As shown in figure 8, sinusoids obtained from points belonging to the same line will intersect at the point with the coordinates . These coordinates are the parameters of the line.

Architecture of hough transform:
The whole architecture of Hough transform algorithm and of looking of linear bacterium parameters is given in figure 9. The principle is to use an accumulator with two dimensions in which each cell corresponds to a quantized value of ( ) r, θ . Before calculating the polar coordinates for each pixel and its neighborhoods, we search if there's enough evidence of an edge.
If so, we save its coordinates ( , ) x y . Then, we calculate its radius r for several angles using the polar equation (1). And we increment the corresponding cells in the accumulator. The peaks of the accumulator are the line parameters. Figure 10 show the architecture of test of neighbors and figure 11 shows the implementation of the polar equation.

Experimental Results (Section 4)
The hardware architecture of detection of linear bacterium in microscopic images consists on the association of the blocks presented above. Firstly, we start by the acquisition of images from the compact flash to the FPGA registers. Then, images are converted from the RGB space to the Grayscale. Afterwards, filtering and thresholding stages are done. We end with the Hough transform application. Figure 12 shows the complete RTL schematic of our architecture. The architecture has been implemented on Virtex 5 (ML507 target, XC5VSXT platform). The number of FLIP-FLOPs of FPGA used is the most important parameter that provides the amount of the used resources. The second parameter is the amount of memory used. Our architecture uses only 1% of the FPGA logic (flip flop) and 4% of the amount of memory, i.e. it uses 691 CLBs slices and 90 KB of memory.
In figure 13 and 14 below, we give some experimental results on 512 x 512 microscopic images. After Grayscale conversion and filtering, the linear bacteria appear clearly in the thresholded images given in figure  13 (d) and 14 (d).
To validate operatively our design, we use the ISIM simulator. Firstly, it is necessary to define the stimuli (the test vectors and the      Figure 15 below shows the waveform result made on the image of figure 13. This waveform shows the frames of the image, the slope of the detected bacterium and its length.

Conclusion (Section 5)
For summary, Xilinx System Generator is a really valuable tool for developing computer vision algorithms. It could be described as an advantageous option for development in a way more comfortable than that permitted by VHDL or Verilog Hardware Description Language. The aim of this paper is to prove the use of System Generator in designing a hardware system for image recognition. This concept is successfully implemented in the device Virtex 5 ML507 (XC5VSXT platform).