# Appling a Novel Cost Function to Hopfield Neural Network for Defects Boundaries Detection of Wood Image

- Dawei Qi
^{1}Email author, - Peng Zhang
^{1}, - Xuefei Zhang
^{1}, - Xuejing Jin
^{1}and - Haijun Wu
^{1}

**2010**:427878

https://doi.org/10.1155/2010/427878

© Dawei Qi et al. 2010

**Received: **31 December 2009

**Accepted: **13 May 2010

**Published: **10 June 2010

## Abstract

A modified Hopfield neural network with a novel cost function was presented for detecting wood defects boundary in the image. Different from traditional methods, the boundary detection problem in this paper was formulated as an optimization process that sought the boundary points to minimize a cost function. An initial boundary was estimated by Canny algorithm first. The pixel gray value was described as a neuron state of Hopfield neural network. The state updated till the cost function touches the minimum value. The designed cost function ensured that few neurons were activated except the neurons corresponding to actual boundary points and ensured that the activated neurons are positioned in the points which had greatest change in gray value. The tools of Matlab were used to implement the experiment. The results show that the noises of the image are effectively removed, and our method obtains more noiseless and vivid boundary than those of the traditional methods.

## Keywords

## 1. Introduction

X-ray wood nondestructive testing is an effective method for accessing to internal information of wood. Comparing with other conventional wood nondestructive testing, such as appearance judgment, acoustic emission testing, ultrasonic testing, microwave testing, and stress wave testing, this method can acquire distinct wood internal structure images by an X-ray imaging system. Through the wood images, the positions of wood defects can be easily identified; the scales of the defects can be roughly estimated. Furthermore, we can make use of computer technology to automatically extract wood defects information from the images for automatically identifying defects characteristics such as areas, types, and severity, which can help making the optimal sawing solution. However, extracting accurate defects information depends on the accurate boundary detection. There are many edge detection algorithms. Most previous edge detection algorithms used first-order derivative operators such as the Sobel edge operator [1, 2], the Roberts edge operator, and the Prewitt edge operator [3]. If a pixel point is on the boundary, its neighborhood will be a zone of transition. The Laplacian operator [4] is a second-order derivative operator and is used to detect boundary at locations of the zero crossing. The Canny operator [5, 6], another gradient operator, is used to determine a class of optimal filter for different types of boundaries. All these operators detect boundary points by gray gradient change of the image pixels in the neighborhood; the disadvantage of these methods are sensitive to noise.

Comparing with traditional edge detection methods, Hopfield neural network, which regarded an edge detection process as an optimization process, has been applied in the field of the low-level image processing of boundary detection in the recent years. Chao and Dhawan [7] used a Hopfield neural network to perform edge detection on a gray-level image. The results were found to be comparable to a Sobel operator on gray-level noisy images. Chang [8] applied Contextual-based Hopfield neural network to medical image edge detection and designed the specific energy function for the medical images. The results showed that the method can obtain better edge points than the conventional methods. Active contour model (Snake) [9] was used in image processing these years [10–13]. Zhu and Yan [10] attempted to combine Hopfield neural network with active contour model for brain image boundary detection. That method showed the results comparable to those of standard "snakes-" based algorithms, but it requires less computing time.

In this paper, we presented a novel approach to automatically detect wood defects boundaries using a modified Hopfield neural network with a specific cost function designed for wood defects image. The boundary detection problem in this paper was regarded as an optimization process that sought the boundary points to minimize a cost function. Hopfield neural network was used as computational networks for solving optimization problems. Because of its highly interconnected structure of neurons, the network was not only very effective in computational complexity, but also very fault tolerant. In consideration of the accuracy of the detection, an initial boundary must be estimated before using the Hopfield neural network. Every pixel in the image with an initial boundary was represented by a neuron which was connected to all other neurons but not to itself. The image was considered as a dynamic system which was completely depicted by a cost function. The states of the neurons updated according to the cost function till the convergence. Then, the result image was given by the states of the neurons. The tools of Matlab were applied to implement the experiment in this paper. The results showed that our method can obtain more continued and more accurate boundary points than the traditional methods of boundary detection.

The remainder of this paper is organized as follows. In Section 2, a basic imaging principle of X-ray and a wood nondestructive detection imaging system are described. A Hopfield neural network theory and its application in solving optimization problems are illustrated in Section 3. Section 4 discusses how to implement the boundary detection algorithm using a Hopfield network. This section is divided into four phases. We first discuss how to initiate defects boundaries, then how to map the boundary detection problem into a Hopfield neural network, and then a novel cost function for wood defects boundaries detection is described. Finally, we illustrate the summary of the algorithm. In Section 5, experimental results and a discussion are given. We illustrate a conclusion and a perspective in Section 6.

## 2. X-Ray Wood Nondestructive Detection Theory

X-ray detection method has been widely applied in the field of wood nondestructive detection in recent decades. As the major application way using X-ray, wood defects image was acquired first by an X-ray image system. Then, wood defects and other internal structure features were detected by subsequent evaluation methods.

### 2.1. Basic Imaging Principle of X-Ray

### 2.2. X-Ray Wood Nondestructive Detection Imaging System

## 3. Hopfield Neural Networks

### 3.1. Basic Theory of Hopfield Neural Networks

In a discrete model, is a discrete variable with a value of zero or one.

In a Hopfield neural network, a neuron can not only be used for an input neuron, but also an output neuron. Every Hopfield neural network has a so-called cost function (or an energy function), which is used for measuring stability of a Hopfield neural network. Signals were circularly transmitted in the whole network. The operation course can be regarded as a recovered and strengthened processing for an input signal. In the course, the network approach gradually to a stable state when the cost function is minimized. If a problem can be mapped to the task of minimizing a cost function, the Hopfield neural network will be implemented to obtain an optimal (or near optimal) solution.

### 3.2. Hopfield Neural Networks for Solving Optimization Problem

The general steps for solving optimization problems are described as follows.

After obtaining the dynamic equation, the original inputs can drive the network till it achieves a stable state. Then, the optimization result is worked out.

## 4. Hopfield Neural Networks for Wood Defects Boundary Detection

The boundary detection problem in this paper was regarded as an optimization process that sought the boundary points to minimize a cost function. Hopfield neural network was used as computational networks for solving optimization problems.

### 4.1. Initiate Boundary

### 4.2. Boundary Detection with a Novel Cost Function

Once we have found the initial boundary of a defect in a wood image, we determine an approximate region where the actual boundary is most likely to be located. A slight adjustment can be made to seek the actual boundary which will be implemented by a Hopfield neural network.

To design such a neural network with an energy function for an entire image is impossible and impractical. However, we noticed that the influence is small between two distant elements. Thus, a small window is applied to the image. The neurons inside the window are fully connected to each other. The correlation between the central element and the element outside the window can be ignored without affecting the final result [22].

where is the output of the neuron in row and column , is the initial value of the neuron in row and column . is the gray value of the original wood defects image. and are constant coefficients.

The first term of the energy function ensures that fewer neurons are activated except the neurons corresponding to the actual boundary points in each row. The second term ensures that the activated neurons are positioned in the points which have greatest change in gray value.

where if and zero otherwise. Once the parameters and are obtained using (14), each neuron can evaluate and adjust its state according to (10) and (12).

Once the initial state of the neurons has been set, the Hopfield neural network begins to work continuously until the energy function of the network stops decreasing. Through the network evolutions, the optimal (or near optimal) boundary points are detected. The position of these activated neurons indicates the detected boundary locations.

### 4.3. Summary of the Algorithm

The algorithm of wood defects boundary detection using the Hopfield neural network can be summarized as follows.

Step ( ) Set the initial state of the neurons based on the initial boundary points which is detected by the Canny edge detection algorithm.

Step ( ) Calculate the input of each neuron, , using (10).

Step ( ) Calculate the output of each neuron, , using (11).

Step ( ) Check the state of neurons; if the state does not change comparing with the last state, stop; otherwise, go back to step ( ).

Step ( ) The final states of neurons are the output result of the network, which represent the final boundary points.

## 5. Experimental Results and Discussion

The purpose of our boundary detection approach is to detect boundaries of wood defects in an image and separate it from normal wood structure. Once isolated, the detected defect can be further processed for recognition of defect type and other defect characteristic. To show that the proposed method have good capability of boundary detection, the proposed method is compared with the conventional methods such as Sobel edge operator, Roberts edge operator, Prewitt edge operator, Laplacian operator, and Canny operator.

Matlab is a high-level technical computing language. We can solve technical computing problems faster than with traditional programming languages such as C and C++. It has a toolbox of image processing which have some traditional image processing functions such as Sobel, Roberts, Prewitt, Laplacian, and Canny. We can conveniently implement the traditional image processing methods by some simple commands. M-files are macros of Matlab commands that are stored as ordinary text files. An M-file can be either a function with input and output variables or a list of commands. All macros of image processing commands in Matlab are stored in M-files. We can program the proposed commands using M-files to implement some works of image processing including the Hopfield neural network method.

Comparing with conventional boundary detection methods, this approach converted a boundary problem to an optimization process that seeks the boundary points to minimize a cost function. The gray value of image pixel was described as the neuron state of Hopfield neural network. The state updated till the cost function touches the minimum value. The final states of neurons were the result image of boundary detection. Taking advantage of the collective computational ability and energy convergence capability of the Hopfield network, the noises will be effectively removed. The experimental results showed that our method can obtain more noiseless and more vivid boundary points than the traditional methods of boundary detection.

## 6. Conclusion

An X-ray imaging technique was applied in wood nondestructive detection. Through wood images acquired by this technique, the wood defects information such as locations, scales, and types was visual. The detected defects can be further processed for recognition of defects types and other defects characteristics.

Hopfield neural network was applied in the boundary detection of wood images. We designed a novel cost function for a Hopfield neural network to detect a defect boundary as solving an optimization problem. After the boundary initiation using Canny edge algorithm, a slight adjustment can be made to seek the actual boundary which will be implemented by a Hopfield neural network with the cost function. Those points that decreased the network energy were detected as boundary points. Taking advantage of the collective computational ability and energy convergence capability of the Hopfield neural network, the experiment received a good result. As shown in the Figures 6–14, the method based on Hopfield neural network in detecting boundary of wood defects was effective; the noises were effectively removed. We can get a more noiseless and vivid wood defect boundary. Thus, a promising method of wood boundary detection based on Hopfield neural network with a novel cost function is provided. All the courses of image processing and building a Hopfield neural network in this paper were implemented using the tools of Matlab. The tools of Matlab are well done in the study of images.

## Authors’ Affiliations

## References

- Davis LS: A survey of edge detection techniques.
*Computer Graphics Image Processing*1975, 4: 248-270. 10.1016/0146-664X(75)90012-XView ArticleGoogle Scholar - Lu D-S, Chen C-C: Edge detection improvement by ant colony optimization.
*Pattern Recognition Letters*2008, 29(4):416-425. 10.1016/j.patrec.2007.10.021View ArticleGoogle Scholar - Gonzalez RC, Woods RE, Eddins SL:
*Digital Image Processing Using MATLAB*. Publishing House of Electronics Industry, Beijing, China; 2004.Google Scholar - Gonzalez RC, Woods RE:
*Digital Image Processing*. 2nd edition. Publishing House of Electronics Industry, Beijing, China; 2002.Google Scholar - Canny J: Computational approach to edge detection.
*IEEE Transactions on Pattern Analysis and Machine Intelligence*1986, 8(6):679-698.View ArticleGoogle Scholar - Xu X, Yang Z, Wang Y: A method based on rank-ordered filter to detect edges in cellular image.
*Pattern Recognition Letters*2009, 30(6):634-640. 10.1016/j.patrec.2008.12.009View ArticleGoogle Scholar - Chao CH, Dhawan AP: Edge detection using Hopfield neural network.
*Proceedings of Conference on Applications of Artificial Neural Networks, 1994*2243: 242-251.View ArticleGoogle Scholar - Chang C-Y: A contextual-based Hopfield neural network for medical image edge detection.
*Proceedings of the IEEE International Conference on Multimedia and Expo (ICME '04), June 2004*1011-1014.Google Scholar - Kass M, Witkin A, Terzopoulos D: Snakes: active contour models.
*International Journal of Computer Vision*1988, 1(4):321-331. 10.1007/BF00133570View ArticleMATHGoogle Scholar - Zhu Y, Yan H: Computerized tumor boundary detection using a hopfield neural network.
*IEEE Transactions on Medical Imaging*1997, 16(1):55-67. 10.1109/42.552055View ArticleGoogle Scholar - Hamou AK, El-Sakka MR: Optical flow active contours with primitive shape priors for echocardiography.
*EURASIP Journal on Advances in Signal Processing*2010, 2010:-10.Google Scholar - Zheng Y, Li G, Sun X, Zhou X: A geometric active contour model without re-initialization for color images.
*Image and Vision Computing*2009, 27(9):1411-1417. 10.1016/j.imavis.2009.01.001View ArticleGoogle Scholar - Yang Y, Gao X: Remote sensing image registration via active contour model.
*AEU—International Journal of Electronics and Communications*2009, 63(4):227-234. 10.1016/j.aeue.2008.01.003Google Scholar - Liu Z:
*Modern Ray Detection Technology*. China Standard Press, Beijing, China; 1999.Google Scholar - Rößler JF, Gerstacker WH: On the convergence of iterative receiver algorithms utilizing hard decisions.
*EURASIP Journal on Advances in Signal Processing*2009, 2009:-8.Google Scholar - Wen U-P, Lan K-M, Shih H-S: A review of Hopfield neural networks for solving mathematical programming problems.
*European Journal of Operational Research*2009, 198(3):675-687. 10.1016/j.ejor.2008.11.002MathSciNetView ArticleMATHGoogle Scholar - Hopfield JJ, Tank DW: 'Neural' computation of decisions in optimization problems.
*Biological Cybernetics*1985, 52(3):141-152.MathSciNetMATHGoogle Scholar - Pajares G, Guijarro M, Ribeiro A: A Hopfield Neural Network for combining classifiers applied to textured images.
*Neural Networks*2010, 23(1):144-153. 10.1016/j.neunet.2009.07.019View ArticleGoogle Scholar - Cierniak R: A 2D approach to tomographic image reconstruction using a Hopfield-type neural network.
*Artificial Intelligence in Medicine*2008, 43(2):113-125. 10.1016/j.artmed.2008.03.003MathSciNetView ArticleGoogle Scholar - Sammouda R, Sammouda M: Improving the performance of Hopfield neural network to segment pathological liver color images.
*International Congress Series*2003, 1256: 232-239.View ArticleGoogle Scholar - Hopfield JJ: Neurons with graded response have collective computational properties like those of two-state neurons.
*Proceedings of the National Academy of Sciences of the United States of America*1984, 81: 3088-3092. 10.1073/pnas.81.10.3088View ArticleGoogle Scholar - Lu S, Wang Z, Shen J: Neuro-fuzzy synergism to the intelligent system for edge detection and enhancement.
*Pattern Recognition*2003, 36(10):2395-2409. 10.1016/S0031-3203(03)00083-9View ArticleMATHGoogle Scholar

## Copyright

This article is published under license to BioMed Central Ltd. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.