The content of this section is the method design part. First, the overall system framework is determined. On this basis, the video capture, image processing, communication, feedback control, database management and other modules of the system hardware are designed. Image processing algorithms are designed in the system software, including a priori fog removal algorithm for dark channels, double histogram equalization based on precise brightness control, and dark channel dehazing algorithms based on regional contrast constraints.
2.1 System framework design
The process of realizing auto focus manually is as follows. First, through the lens system, the individual presents its image on the sensor (CCD, CMOS) and uses the intelligent chip embedded in the autofocus manager or the computer that processes the technology, and acts on the stepper motor with reference to the discrimination result, which is reflected to the lens system. In the following article, we take the automatic focusing system of the microscope as an example, regard it as a lens system, transform the microscope with CCD, and the PC uses DSP microcontroller to help control and prevent the change of the direction of the sample and the transformation of the objective lens to achieve automatic focus. The system is one of the complete systems of the automatic urine sediment analyzer, which is composed of the upper and lower computer, the former is the module of sorting out all the data, collecting the material and processing it, and the latter is the management and control module of the evaluation result. in addition, the communication part provides communication for the two. The specific structure is shown in figure 1.
2.2 System module design
2.2.1 Video capture module
To sum up, the first step of the system will use the automatic sample injection dyeing device to collect objects, the second step will send the data to the counting pool where the microscope is placed, the third step uses its CCD lens to obtain analog video signals, and the fourth step converts the collected materials into digital signals and sends them to the PC, where an image acquisition card is used. Mainly based on the accuracy premise established before, and the real situation of the chip, through the Tianmin SDK2500 acquisition card, the use of embedded SDK secondary development, the specific process is shown in figure 2 below.
When the collection is completed, the analog video stream is collected at a speed of 25 frames per second, and the image is collected by PC and its location is identified and stored in the corresponding database.
2.2.2 Image processing module
This part is the most important part of the whole microscopic automatic adjustment system. After the PC calculates the collected information software, it uses the communication function to convey the identification results to the feedback management part, prompting this part to do the necessary actions according to the PC. The detailed work has three parts: identifying the clarity of the picture, selecting the window of the selected object and processing in advance. Then make the corresponding focusing curve. The detailed steps are shown in figure 3 below.
2.2.3 Communication module
The function of this part is to complete the information transmission from PC to DSP micro-control, including the selection of information transmission method and the design of its protocol.
There are two ways to convey information between the two, serial and parallel. Different methods are different in the method of transmitting data words, the latter is one at a time, and the former is carried out at different times according to the location. The advantage of parallelism lies in its speed, but it requires high hardware performance. Compared with serial, serial is more suitable for long-distance and common data operations. Based on the actual situation, the serial method is established below. When dividing in detail, there are two transmission methods: asynchronous and synchronous. The reason why this paper chooses the former is that in this article, PC and DSP micro-control do not have fixed data transmission and do not have consistency. The serial interfaces include RS-232, RS-422 and RS-485. The advantage of RS-485 is the most significant, mainly for its low signal level, little impact on the interface circuit chip, and can be compatible with the TTL level, which provides conditions for the associated TTL circuit, and it is basically free from noise or other factors, long-distance transmission, and has the advantage of multi-station, so the following interface is chosen. Basically, there is a primary serial port in the engineering computer. the change of the PC 232 signal to the 485 signal is mainly realized by the 485 interface card. at the same time, the Optocoupler isolation is used to minimize the damage to the PC brought by the instrument's own circuit. The signal achieves half-duplex by avoiding twisted pair transmission. In order to ensure the safety and stability of the above transformation process, the hardware method is used here.
The communication protocol represents the agreement of the two parties on the content, in which multi-party standards are established, including transmission steps, data format, speed, synchronization methods and unified characters. The system is divided into two main ways, using the upper computer and the lower computer mentioned earlier. The former sends packets to the latter, or the latter gives feedback to the former. Among them, the serial port data has a total of 9 bytes, the packet header of the first transmission mode is EB 91, and the packet header of the second transmission mode is 55A6. For example, in the communication process, if the DSP micro-control receives the data packet, it will first identify the location where the data packet should be sent according to its packet header, and start reading if it is determined to be sent to itself. Otherwise it will not pay attention to it and receive other data packets at the same time. The process that relies on the implementation of the CSerialPort class is shown in figure 4 below.
2.2.4 Feedback control module
The principle of this part is to use the focusing curve to manage the work of the stepper motor, control the movement of the objective lens in all directions, and help the objective lens to focus, including the design of the microscope control board and the extreme value search of the image processing part. Among them, the role of the control board is to use the microscope to select the scene to be observed and optimize the image to be clear:
- Take the motion controller TMS32UF2812 for TI as its main component.
- The stepper motor is connected with four circuits, that is, the motor that places the axis of the sample and the conversion objective lens.
- Five circuits are connected to the sensor to help the motor to carry out the relevant operation, three channels are placed on the sensor to determine the azimuth for the return of the three-axis motor, and the remaining two are Hall and the temperature sensor, the former assists the objective lens to return to the transformation motor, and the latter provides temperature supply for the focal length.
- Based on the consideration of dual-channel and its maintenance, four-way solenoid valve is realized, which is used for dual-channel selection and protection.
- 485 bus interface, which processes the information sent by the host computer and reflects the current situation to it at the same time.
2.2.5 Database management module
The composition of this part includes the database system and its application program, which plays the role of inputting and controlling the coordinates of the sample, evaluating whether the image is clear, focusing process and stepper motor step size or other. One of the functions of database is to sort out a large amount of information to help staff to complete this part of the task of its management system, that is, DBMS, the main function of its user program is to provide practical windows, interact with DBMS, and complete the needs of information in the homework. Among them, the application of MySQL and VC+ ten to complete, the details for the user, object, information management and recovery standby.
- User management. There are two parts: manager and tester. Under normal circumstances, the former can use the new automatic focus proofreading, the right coverage is wider, and the host parameters of the automatic urinary sediment analyzer can be adjusted based on the final data. When multiple conditions are obtained, the total rotation distance of the motor connected to the focus completes focus proofreading.
- Object management. While completing the data of the test object itself and the test premise and other management, keeping the function of realizing the clear image of the matching of the different experimental objects, finding the objects that have passed the test in detail, filling in the data storage of new objects, eliminating incorrect object data and reasonably determining the degree of clarity.
- Information management. Complete the recording of the situation and collation of the results in the focusing process. There are the following items: image acquisition point, recording point, relevant clear state, the best value point to achieve clarity in focusing, all the required time and other related data.
- Standby recovery. Its function is to record all its states in the database and to generate templates and restore them as needed.
2.3 System Related Algorithm and Analysis
2.3.1 Classical a priori fog removal algorithm for dark channels
When haze is produced in the natural environment, the medium existing in the air will affect the reflected light, so it will change the definition of the acquired image, and the distance between the monitoring and the target affects the scattering state in the air, so the definition of the image will change with the change of its distance. The de-fog algorithm of the only image is basically based on the atmospheric optical model established by HE and others, and based on the a priori de-fog method of guided filtering dark channel, namely:
In formula (1), I is the basic fog image obtained. Coordinates are represented by and x and y. J is a clear picture in a perfect environment, which is the image of the object to be processed. The degree of transmission is expressed by t . A is the global lighting situation. β is the atmospheric scattering coefficient. d (xPowery) is the depth data of the actual situation.
Based on the statistics of the prior law of dark channel, when the sample image is clear and free of fog, all sub-parts have the possibility of shadow. So, the possibility that all sub-parts contain at least a single pixel in one of the color components is basically equal to 0.
So, J's dark channel image Jdark：
In formula (2), is the color component category. R, G, B are three primary colors, and J is any color component of the former. Ω(x,y) is a single subpart. If the transmittance and natural light state are taken as prerequisites, the algorithm to complete the fog-free state is:
The natural light state can be set as the overall data. Based on the reference , the average pixel number of 0.1% of the part with the highest intensity in the dark channel is selected, which is the average of the brightness of the maximum part of the cover fog-the natural light state. The map of transmission degree can be obtained by guided filtering. Through the above two parameters and (3) algorithm, we can achieve the existing preparation to solve the restoration of the image with fog.
Among them, the function of the guided filtering formula is to speed up the details of the smooth image and stabilize the edge data of the image, so that the transmittance map can be optimized to optimize the clarity of the fog removal image. In fact, the principle of the above formula is to build a local linear model in the acquisition and transportation diagram, mainly taking the two-dimensional window as a reference. If the dark channel of a haze image is ultimately, then the transport map is:
In formula (4), i is a pixel in the wk domain. Di echoes the existence value of the dark channel in the final D . wk is the core part of the matrix D that takes the pixel k as the core. (ak,bk) is a partial internal constant.
In the guided filtering method, the difference between the stable transport graph ti and the acquisition graph t0 is minimized to obtain the best coefficient (ak,bk),:
In formula (5), E is the cost function of minimizing the difference between the transportation graph and the acquisition graph.ε is a control parameter to prevent ak from being too large.
Using the minimization of formula (5), the above two can maintain their similarity on a global scale. With the application of guided filter improvement, the transmission degree map of transmission is the specific data. In order to further optimize the dark channel defog operation in reality, we can see the oriented filter, and its transmission map has been carried out with efficient median filtering in reference , which strengthens the later operation solution.
At present, it has been tried to apply this operation method directly to the foggy weather, although there is a significant improvement in the detailed parts and colors of the image, but because the atmospheric light intensity is not equal to the reflected light intensity in reality, the latter is relatively low. so the results after processing are light with the original image, which as a whole can not be compared with the original image. Through figure 5 below, it can be made clear that the above disadvantages do not improve significantly in practice, and the global brightness of the transmitted image is dim, and it is found that no matter which part is different from the original image. In the (d) display of figure 5 below, the basic factors of individual HSI (Hue-Saturation-Intensity) color space expression are saturation, lightness, and so on. In this process, if you want to use double histograms to improve the foggy picture, the high brightness part of the initial image will be distorted.
2.3.2 Double histogram equalization based on accurate brightness control
Relevant research shows that when using the previous double histogram method to improve the presentation results, there will be a bias in the process of conveying the brightness of the picture. The content of reference  not only provides a detailed algorithm for managing lightness, but also directly ensures that the image can reach the required lightness. First, based on the relationship between the lightness and the gray threshold from the construction of the picture lightness histogram, many threshold conditions are obtained to achieve the required lightness of the picture; through one of the similar characteristics of the histogram, to judge the gray threshold, so as to improve the effect of the picture. The advantage of this operation method is obvious, which can not only efficiently and accurately manage the brightness of the picture needed to maintain stability, but also take into account the need to improve the picture color saturation and achieve the difference condition.
2.3.3 Dark Channel de-fogging algorithm based on region contrast constraint
Detailed process of dark channel de-fog algorithm based on region contrast constraint:
- Using the dark channel a priori, the normalized thorough map of I with fog is obtained.T , defines the two parts of the image by the method of maximum inter-class variance: bright RL and dark RA , at the same time, and obtains the ratio of the average pixel value of these two parts, that is,k'.
- Based on the a priori de-fog algorithm of dark channel with median-oriented filtering, the I pixel values of clear and bright parts of Jl, with fog can be obtained by RL, recording of clear part of fog.
- As far as possible, make sure that the k' value is used to calculate the brightness parameters RA that needs to meet after fog removal, sort out the luminance histogram arrangement of other RA, improve the picture quality by controlling the bright double histogram equalization, and obtain the constrained RA.
- Collect all the RL optimized images to get the defog map J.