IBN AL- HAITHAM J. FOR PURE & APPL. SCI VOL.22 (2) 2009 Estimation Optimal Threshold Value for Image Edge Detection A.A. D. Al-Zuky and H. J. M. Al-Taa'y Department of Physics, College of Science, University of Al-Mustansiriya Abstract A new approach presented in this study to determine the optimal edge detection threshold value. This approach is base on extracting small homogenous blocks from unequal mean targets. Then, from these blocks we generate small image with known edges (edges represent the lines between the contacted blocks). So, these simulated edges can be assumed as true edges .The true simulated edges, compared with the detected edges in the small generated image is done by using different thresholding values. The comparison based on computing mean square errors between the simulated edge image and the produced edge image from edge detector methods. The mean square error computed for the total edge image (Er), for edge regions (Erl), and for non-edge regions (Er2). From these measures (Er, Erl, &Er2), we can estimate best threshold value, at low edge errors detection (i.e. best (th) at low Er, Erl,&Er2). Key-Words: (homogenous image region, edge detection, MSE, thresholding, edge filter) Introduction In many image interpretations analysis, boundaries of objects are of special concern. Where, the size or the shape of the outline of the object generally can be use to discern the object or detect abnormalities. For this purpose, large number of edge detection strategies, have been devise to locate the edges in the image by using local image properties. The most conventional methods that one is base on the image gradient. These methods work well whenever object boundaries have high contrast. The gradient of the two dimension function I(x,y) is a vector given by (l) where i, and j are the unit vectors along the x and y directions respectively. The orientation of the edge is useful for some applications but it is not always required. Clearly, an edge must match with places is a local maxima along the direction it points. The detected local maxima points are so many, that they hardly contain any useful information. The obvious cause of the problem is that when we do the edge detection, we must ignore the small and insignificant changes in the image intensity value. The proper terminology for this is thresholding. Effectively, algorithm can be built that would make the computer ignore any local maximum value that less than a certain threshold value. But, how can we find this threshold value. This is another topic of research. An algorithm we give to the computer can do it automatically. Alternatively, it can done manually, after we look at the values of the local maxima or IBN AL- HAITHAM J. FOR PURE & APPL. SCI VOL.22 (2) 2009 even more grossly, by trial and error, until we reach visually a good view. But, the determination of threshold, is not unique, and not optimal.(2-5) The aim of this study is to determine the optimal threshold based on quantitative testing. Where the quantitative test give a robust rule to reach optimal threshold value. Edge Image Simulation The edges between different image targets can be located precisely. The edges resulted from any edge detection method would not correctly match with the true image edges. Where the resulted edges are not always thin edges (i.e. edge thickness of more than one pixel) in some locations, and is connected edges in another location. In addition, some false edges may be introduced. But in order to determine the error between true edges and detected edges, we don't have the image of true edges. So, the error must be estimated visually. Visual measure without robustness is use in approximation the amount of error in resulted edges. Consequently, we cannot evaluate the best threshold value. In this paper, we suggest a new technique to simulate edges. This is done by extract square blocks from different homogeneous image regions of different means. Then these blocks are collected to produce small image that contains different blocks (of same sizes). So, the locations of the edges between the blocks are known. Hence, we can assume that these edges represent the true edges. An example of this simulated image and its true edges is shown in Fig.(2:a, and b), and the diagram of the suggested method is explain in Fig.(l). Then, in order to test the edge detection efficiency for the adopted edge detector, we would apply this detector to detect the edge in the simulated small image. After that, we determine the edges by using threshold value (th). The resulted edges don't always represent the true edges. Hence, we can use the following equations to evaluate the amount of error between true edges and the edges resulted from edge detector: where, TE (x,y), and RE (x,y) are the true edge image and resulted edge image respectively (NxM) represents the size of simulated image, EP is the total number of true edge points in the simulated image, and HP is the total number of homogenous points in the simulated image. Accordingly, the quantitative values (Er, Erl, and Er2) represent the mean square error, for total image plane, the error for only edge points, and for homogeneous (non-edge) points only. So, we can determiner an amount of edge error that would be produced from using the adopted edge detector. Also, it could be evaluated when the error is large in edge points or non-edge points. Hence we can be adjust IBN AL- HAITHAM J. FOR PURE & APPL. SCI VOL.22 (2) 2009 the (th) value to reduce the whole errors (Er, Erl, and Er2). See Fig.(3) which explain the relation between th-value and the errors (Er, Erl, and Er2). After finding the optimal threshold for the small-simulated image, we can apply the edge detection method in order to find the edge in the original (large) image. Results and Conclusions The adopted images (Laylal, and Lena) in this study are shown in Fig. (5). These images of size (256 x 256) pixels are presented by 8 bit/pixel. From each image we can extract different homogenous blocks from un-equal mean. The generated small image contains simulated edges. The small images and their simulated edge images are shown in Fig. (4). To obtain the optimal threshold value in order to determine image edge for each edge detector, we performed the edge detector methods ((Sobel, Prewit, Kirsch, and Robert Gradient)) (2,3,6), and used different threshold values (th). The resulted edge images compute the errors (Er, Erl, &Er2). The results of error values (Er, Erl, &Er2), differ with varying edge detectors at (tho) values. This tabulated in table (1) & (2). We plot the relation between th-values and Er-values, as in Fig. (3). From these figures we can shown that the low th-values would produce thick edges, and high Er2 in homogenous regions (i.e. produces false edges), and low Erl in edge regions (i.e. produces connected edges). The net error Er for homogenous and edge regions are high. When the th-value increases, the Er2 decreases, the Erl slowly increases, and Er decreases. These decreases in errors (Er) reach minimum value with the threshold optimal (tho). After, this the threshold values (tho), and the errors Er2 are highly decreased. Erl is increased and Er is increased. So, we can evaluate the best threshold (tho) to determine image edges, for both small-simulated image and large (original) image. Therefore we can use the estimated (tho) in order to determine the edges in the whole image. The optimal threshold (tho) is not fixed for all adopted detectors. The result of using estimated (tho) values for the images is shown in Fig. (3). Hence, we can noted that the best threshold (tho) with low (Er) introduces a very good edge image visually. This would give us a very good agreement between the suggested quantitative measure and subjective edge image quality. Also, we can show that the decrease in th-value would produce high errors in detecting homogenous regions and low errors in detecting edge regions. Then, high th-values would produce high errors in detecting edge regions (i.e. estimating true edges), and highly detected homogenous regions (i.e. low errors in homogenous regions). References 1. Petrou, M. (1994), Advances in Electronics and Electron physics, 88: 297-345. 2. Pratt, W.K. (1978) "Digital Image Processing", Wily; New York. 3. Gonzalez, R.C. and Wintz, P. (1987) "Digital Image Processing", Addison Wesley. 4. John A. Richards and Xinping Jia, (1999) "Remote Sensing Digital Image Analysis", Springer. 5. Sangwine, S.J. and Home, R.E.N. ( 1998) "The color image processing Handbook", First addition, Chapman and Hall London. IBN AL- HAITHAM J. FOR PURE & APPL. SCI VOL.22 (2) 2009 6. Asmaa, S. (2001) "Experimental Studies of Edge and Corner Detectors", M.Sc. Theses, National Computer Center, Institute of higher studies in computer and informatics. From applying the procedure steps which are shown in Fig. (1) for the image by using different threshold values (th). And in order to determine MSE for each case we can estimate optimal threshold value (tho) that would give least MSE value. Input Image Extract Homogeneouse Blocks Generate Small Image from Extracted Blocks Determine Real Input (th) Applied Edge Detector Determine (MSE) Minimum (MSE) means Optimal Threshold Fig. (1) block diagram of suggested algorithm to determine optimal threshold (tho) IBN AL- HAITHAM J. FOR PURE & APPL. SCI VOL.22 (2) 2009 2002( 2) 22مجلة ابن الهيثم للعلوم الصرفة والتطبيقية المجلد تخمين قيمة العتبة المثلى لكشف الحافات في الصورة علي عبد داود الزكي،حيدر جواد محمد الطائي قسم الفيزياء، كلية العلوم، الجامعة المستنصرية الخالصة اع اسلوب جديد تم استحداثه في هذه الدراسة لغرض تحديد أفضل قيمة عتبة لكشف الحافات. وذلك باالعتماد على استقط ت صغيرة متجانسة من مناطق ذات معدل شدة رمادية مختلفة, هذه البلوكات المستقطعة بعد ذلك تستخدم لتوليد صورة صغيرة ذات بلوكا حافات معروفة ) الحافات تمثل خطوط التماس بين البلوكات(, لذلك فان الحافات المولدة يمكن أن نعتبرها حافات حقيقية فعلية, ومن ثم الحافات الناتجة من تطبيق طرائق الكشف الحافية على الصورة المولدة الصغيرة, وباستخدام قيم تعتيب مختلفة. تقارن هذه الحافات مع والمقارنات تعتمد على حساب معدل مربع الخطأ بين الحافات الفعلية والحافات الناتجة من الطرائق المعتمدة. ومعدل مربع الخطأ لكل ( يمكن تخمين أفضل عتبة Er, Er1, Er2(. ومن هذه المعايير )Er2( وللمناطق غير الحافية )Er1( وللمناطق الحافية )Erالصورة ) (tho( عندما يكون الخطأ )Er.أصغر ما يمكن )