Automatic focus algorithms for TDI X-Ray image reconstruction 147

In food industry, most products are checked by X-rays for contaminations. These X-ray machines continuously scan the product passing through. To minimize the required X-ray power, a Time, Delay and Integration (TDI) CCD-sensor is used to capture the image. While the product moves across the sensor area, the X-ray angle changes during the pass. As a countermeasure, adjusting the sensor shift speed on a single focal plane of the product can be selected. However, the changing angle result in a blurred image in dependance to the thickness of the product. This so-called “laminographic effect” can be compensated individually for one plane by inverse filtering. As the plane of contamination is unknown, the blurred image will be inversely filtered for different planes, but only one of these images shows the correctly focussed object. If the correct image can be found, the plane containing the contamination is identified. In this contribution we demonstrate how the correctly focussed images can be found by analyzing the images of all planes. Different characteristics for correctly and incorrectly focussed planes like sharpness, number of objects and edges are investigated by using image processing algorithms.


Introduction
For quality assurance in food industry more and more X-rayscanners are used instead of simple metal detectors, because they are also able to detect non-metallic contaminations, to check filling levels or to check that a product is sealed properly.For such scanning applications continuous processing is desirable, because it fits in most production processes without the need of further adaptations.To minimize the required X-ray power, a Time, Delay and Integration (TDI) (Wong et al., 1992) CCD sensor can be used to capture images while the objects are moving across the sensor area.One way to obtain depth information is the use of laminographic techniques (Gondrom and Schröpfer, 1999;Rooks and Sack, 1995) in Manuscript prepared for Adv.Radio Sci. with version 4.2 of the L A T E X class copernicus.cls.Date: 27 July 2012

Introduction
For quality assurance in food industry more and more X-rayscanners are used instead of simple metal detectors, because they are also able to detect non-metallic contaminations, to check filling levels or to check that a product is sealed properly.For such scanning applications continuous processing is desirable, because it fits in most production processes without the need of further adaptations.To minimize the required X-ray power, a Time, Delay and Integration (TDI) (Wong et al. (1992)) CCD sensor can be used to capture images while Correspondence to: Mark Rosenbaum (rosenbaum@eit.uni-kl.de) the objects are moving across the sensor area.One way to obtain depth information is the use of laminographic techniques (Gondrom, Schröpfer (1999), Rooks, Sack (1995)) in con-

35
junction with the Radon Transform (Popularikas (1996)).This requires a complex mechanical setup not suitable for continuous scanning or requires two or more X-ray sources and detectors.This approach is not only expensive in terms of investment, in addition the second X-ray tube also needs 40 power, cooling and better shielding against X-rays leaving the machine.An alternative way is the use of a single sensor followed by inverse filtering.However, this technique causes the problem that the angle of the X-rays changes during the transport, as 45 shown in figure 1.
This effect can be modeled as a convolution of the real image a(x,y) with the point spread function (PSF) of the imaging system h(x,y), yielding an image s(x,y).s(x,y) = a(x,y) * h(x,y) (1) In general, this PSF is two-dimensional, but in our case only the contribution in direction of the belt movement is significant, which can be modeled as a one-dimensional impulse response.This impulse response is height variant, which means it is only valid for a given height of the object   (Popularikas, 1996).This requires a complex mechanical setup not suitable for continuous scanning or requires two or more X-ray sources and detectors.This approach is not only expensive in terms of investment, in addition the second X-ray tube also needs power, cooling and better shielding against X-rays leaving the machine.
An alternative way is the use of a single sensor followed by inverse filtering.However, this technique causes the problem that the angle of the X-rays changes during the transport, as shown in Fig. 1.
This effect can be modeled as a convolution of the real image a(x,y) with the point spread function (PSF) of the imaging system h(x,y), yielding an image s(x,y).s(x,y) = a(x,y) * h(x,y) (1) In general, this PSF is two-dimensional, but in our case only the contribution in direction of the belt movement is significant, which can be modeled as a one-dimensional impulse response.This impulse response is height variant, which means it is only valid for a given height of the object above the sensor plane.Further information can be found in (Rosenbaum et al., 2011).Images of thin objects can be deblurred by inverse filtering during post processing using a Wiener filter approach.This deblurring process performs well for thin objects, if the PSF is known.The PSF can be estimated for one specific plane or layer.By resizing this PSF one can obtain PSFs of other layers.However, it is unknown which layer contains the contamination.So the idea is to deblur the image with respect to the PSFs of different layers and to search for a correctly focussed image a posteriori.If no correctly focussed image can be identified, the object is not flat.If a correct image is found, the object is flat and the height of the object over the transport belt is known.
Humans are well able to decide for correctly focussed images.However, for practical industrial usage the decision has to be made by computer algorithms.Unfortunately, standard autofocus algorithms (Subbarao et al., 1993) can not be applied because of potential artifacts from inverse filtering.In this article a solution for these problems is proposed and demonstrated by simulation results.
The remainder of this paper is organized as follows: After an overview on inverse filtering which is visualized by resulting images from our simulation setup, three different autofocus algorithms are discussed.A combination of these algorithms is proposed and demonstrated by simulation results.Finally, conclusions are drawn.

Simulation setup
To demonstrate and test the proposed algorithms, the ray tracing software POV-Ray (see www.povray.org) was used to build test images, where a visual light source models the X-ray tube. Figure 2 shows the model.Different washers and cylinders with different thicknesses in different layers were simulated.To model the conveyor belt, the light source is moved and the changing shadows are captured.Finally, the images of different light positions are merged to one image by calculating the mean value.This simulates the laminographic effect resulting from the use of an TDI X-ray system.
The results of the mean value calculations are inversely filtered for a specific number of layers (here 160).Finally we use these 160 inversely filtered layer-images for every washer to test the algorithms.

Inverse filtering
Blurring caused by the laminographic effect can be effectively addressed by inverse filtering since it can be regarded as a convolution of the real image with the point-spreadfunction of the imaging system additionally corrupted with noise n. s(x,y) = a(x,y) * h(x,y) + n (2) The inverse filtering takes advantage of the frequency domain.A pure inversion of the transfer function H (f x ,f y ) requires to take the reciprocal of it yielding H w (f x ,f y ) = 2 J. Dörr et al.: Automatic Focus Algorithms for TDI X-Ray Image Reconstruction above the sensor plane.Further information can be found in (Rosenbaum et al. (2011)).
Images of thin objects can be deblurred by inverse filtering during post processing using a Wiener filter approach.This deblurring process performs well for thin objects, if the PSF is known.The PSF can be estimated for one specific plane or layer.By resizing this PSF one can obtain PSFs of other layers.However, it is unknown which layer contains the contamination.So the idea is to deblur the image with respect to the PSFs of different layers and to search for a correctly focussed image a posteriori.If no correctly focussed image can be identified, the object is not flat.If a correct image is found, the object is flat and the height of the object over the transport belt is known.
Humans are well able to decide for correctly focussed images.However, for practical industrial usage the decision has to be made by computer algorithms.Unfortunately, standard autofocus algorithms (Subbarao et al. (1993)) can not be applied because of potential artifacts from inverse filtering.
In this article a solution for these problems is proposed and demonstrated by simulation results.The remainder of this paper is organized as follows: After an overview on inverse filtering which is visualized by resulting images from our simulation setup, three different autofocus algorithms are discussed.A combination of these algorithms is proposed and demonstrated by simulation results.Finally, conclusions are drawn.

Simulation Setup
To demonstrate and test the proposed algorithms, the ray tracing software POV-Ray (see www.povray.org) was used to build test images, where a visual light source models the X-ray tube. Figure 2 shows the model.Different washers and cylinders with different thicknesses in different layers were simulated.To model the conveyor belt, the light source is moved and the changing shadows are captured.Finally, the images of different light positions are merged to one image by calculating the mean value.This simulates the laminographic effect resulting from the use of an TDI X-ray system.
The results of the mean value calculations are inversely filtered for a specific number of layers (here 160).Finally we use these 160 inversely filtered layer-images for every washer to test the algorithms.

Inverse Filtering
Blurring caused by the laminographic effect can be effectively addressed by inverse filtering since it can be regarded as a convolution of the real image with the point-spreadfunction of the imaging system additionally corrupted with noise n. s(x,y) = a(x,y) * h(x,y) + n (2) The inverse filtering takes advantage of the frequency do-105 main.A pure inversion of the transfer function H(f x ,f y ) requires to take the reciprocal of it yielding H w (f x ,f y ) = H −1 (f x ,f y ), which poses problems because of spectral zeros and ampluification of noise contained in the X-ray image.A well-known solution to this problem is Wiener filter-110 ing (Madissettti and Williams (1998)).Equation 3shows the parametric form of the Wiener filter.K accounts for noise influence, which is ideally chosen as the reciprocal of the input signal-to-noise-ratio.above the sensor plane.Further information can be found in (Rosenbaum et al. (2011)).
Images of thin objects can be deblurred by inverse filtering during post processing using a Wiener filter approach.This deblurring process performs well for thin objects, if the PSF 60 is known.The PSF can be estimated for one specific plane or layer.By resizing this PSF one can obtain PSFs of other layers.However, it is unknown which layer contains the contamination.So the idea is to deblur the image with respect to the PSFs of different layers and to search for a correctly 65 focussed image a posteriori.If no correctly focussed image can be identified, the object is not flat.If a correct image is found, the object is flat and the height of the object over the transport belt is known.
Humans are well able to decide for correctly focussed images.However, for practical industrial usage the decision has to be made by computer algorithms.Unfortunately, standard autofocus algorithms (Subbarao et al. (1993)) can not be applied because of potential artifacts from inverse filtering.
In this article a solution for these problems is proposed and 75 demonstrated by simulation results.The remainder of this paper is organized as follows: After an overview on inverse filtering which is visualized by resulting images from our simulation setup, three different autofocus algorithms are discussed.A combination of these algorithms is proposed and demonstrated by simulation results.Finally, conclusions are drawn.

Simulation Setup
To demonstrate and test the proposed algorithms, the ray tracing software POV-Ray (see www.povray.org) was used to build test images, where a visual light source models the X-ray tube. Figure 2 shows the model.Different washers and cylinders with different thicknesses in different layers were simulated.To model the conveyor belt, the light source is moved and the changing shadows are captured.Finally, the images of different light positions are merged to one image by calculating the mean value.This simulates the laminographic effect resulting from the use of an TDI X-ray system.
The results of the mean value calculations are inversely filtered for a specific number of layers (here 160).Finally we use these 160 inversely filtered layer-images for every washer to test the algorithms.

Inverse Filtering
Blurring caused by the laminographic effect can be effectively addressed by inverse filtering since it can be regarded 100 as a convolution of the real image with the point-spreadfunction of the imaging system additionally corrupted with noise n. s(x,y) = a(x,y) * h(x,y) + n (2) The inverse filtering takes advantage of the frequency do-105 main.A pure inversion of the transfer function H(f x ,f y ) requires to take the reciprocal of it yielding H w (f x ,f y ) = H −1 (f x ,f y ), which poses problems because of spectral zeros and ampluification of noise contained in the X-ray image.A well-known solution to this problem is Wiener filter-110 ing (Madissettti and Williams (1998)).Equation 3shows the parametric form of the Wiener filter.K accounts for noise influence, which is ideally chosen as the reciprocal of the input signal-to-noise-ratio.H −1 (f x ,f y ), which poses problems because of spectral zeros and amplification of noise contained in the X-ray image.A well-known solution to this problem is Wiener filtering (Madissettti and Williams, 1998).Equation (3) shows the parametric form of the Wiener filter.K accounts for noise influence, which is ideally chosen as the reciprocal of the input signal-to-noise-ratio.
Figure 3 summarizes the imaging and reconstruction process, which produces an estimate Â of the unknown original image A.
In the reconstruction process, an impulse response is only valid for a single focal plane.The characteristics of the imaging process allow to calculate an impulse response for every focal plane out of one known impulse response by using algorithms also known in image processing as bilinear or bicubic scaling (details can be found in Keys, 1981).focal plane out of one known impulse response by using algorithms also known in image processing as bilinear or bicubic scaling (details can be found in (Keys (1981))).
To estimate the height of an object above the belt, images 125 have to be reconstructed with scaled PSFs.In our case, 160 images corresponding to 160 focal planes with a distance of 0,5mm were calculated, yielding a range of 8 cm.As described in section 2, we used simulated X-ray scenarios of a thin metallic washer, diameter 2cm.Some examples of 130 these images are shown in figures 4 -7.The characteristics of these images and especially the differences between the correctly and incorrectly focussed images will be useful for understanding suitable algorithms.
If the inverse filtering PSF is too compressed, it nearly cor-135 responds to a dirac-impulse and therefore the result of the convolution with this PSF resembles the original blurred image after the scanning process (figure 4).The result is a very blurry image, but it shows only one object and not separated parts of the washer.Figure 5 depicts the result of an inverse 140 convolution with a wider spread PSF.If the PSF is spread farther, artifacts with sharp edges and many separated areas are the result as shown in figure 6.

Algorithms
In general, the contaminants cannot be specified and the product may also vary.This means, the general proper-150 ties which are different between correctly and incorrectly focussed images need to be used to detect the focal plane.
In this contribution we propose to use the set of following features: (1) peaks of image autocorrelation function, (2) number of objects and (3) pixels outside objects.

Autocorrelation
Incorrectly focussed images with a too wide PSF suffer from periodic artifacts, which need to be detected.The idea is to measure these changes by autocorrelation.The more peri-  focal plane out of one known impulse response by using algorithms also known in image processing as bilinear or bicubic scaling (details can be found in (Keys (1981))).
To estimate the height of an object above the belt, images have to be reconstructed with scaled PSFs.In our case, 160 images corresponding to 160 focal planes with a distance of 0,5mm were calculated, yielding a range of 8 cm.As described in section 2, we used simulated X-ray scenarios of a thin metallic washer, diameter 2cm.Some examples of these images are shown in figures 4 -7.The characteristics of these images and especially the differences between the correctly and incorrectly focussed images will be useful for understanding suitable algorithms.
If the inverse filtering PSF is too compressed, it nearly corresponds to a dirac-impulse and therefore the result of the convolution with this PSF resembles the original blurred image after the scanning process (figure 4).The result is a very blurry image, but it shows only one object and not separated parts of the washer.Figure 5 depicts the result of an inverse convolution with a wider spread PSF.If the PSF is spread farther, artifacts with sharp edges and many separated areas are the result as shown in figure 6.

Algorithms
In general, the contaminants cannot be specified and the product may also vary.This means, the general proper-150 ties which are different between correctly and incorrectly focussed images need to be used to detect the focal plane.
In this contribution we propose to use the set of following features: (1) peaks of image autocorrelation function, (2) number of objects and (3) pixels outside objects.

Autocorrelation
Incorrectly focussed images with a too wide PSF suffer from periodic artifacts, which need to be detected.The idea is to measure these changes by autocorrelation.The more peri- To estimate the height of an object above the belt, images have to be reconstructed with scaled PSFs.In our case, 160 images corresponding to 160 focal planes with a distance of 0.5 mm were calculated, yielding a range of 8 cm.As described in Sect.2, we used simulated X-ray scenarios of a thin metallic washer, diameter 2 cm.Some examples of these images are shown in Figs.4-7.The characteristics of these images and especially the differences between the correctly and incorrectly focussed images will be useful for understanding suitable algorithms.
If the inverse filtering PSF is too compressed, it nearly corresponds to a dirac-impulse and therefore the result of the convolution with this PSF resembles the original blurred image after the scanning process (Fig. 4).
The result is a very blurry image, but it shows only one object and not separated parts of the washer.Figure 5 depicts the result of an inverse convolution with a wider spread PSF.
If the PSF is spread farther, artifacts with sharp edges and many separated areas are the result as shown in Fig. 6. Figure 7 depicts an example for images filtered with the correctly scaled PSF and which should be chosen as correctly focussed.They are characterized by sharp edges, only one object and not many changes of intensity values.focal plane out of one known impulse response by using algorithms also known in image processing as bilinear or bicubic scaling (details can be found in (Keys (1981))).
To estimate the height of an object above the belt, images 125 have to be reconstructed with scaled PSFs.In our case, 160 images corresponding to 160 focal planes with a distance of 0,5mm were calculated, yielding a range of 8 cm.As described in section 2, we used simulated X-ray scenarios of a thin metallic washer, diameter 2cm.Some examples of 130 these images are shown in figures 4 -7.The characteristics of these images and especially the differences between the correctly and incorrectly focussed images will be useful for understanding suitable algorithms.
If the inverse filtering PSF is too compressed, it nearly cor-135 responds to a dirac-impulse and therefore the result of the convolution with this PSF resembles the original blurred image after the scanning process (figure 4).The result is a very blurry image, but it shows only one object and not separated parts of the washer.Figure 5 depicts the result of an inverse 140 convolution with a wider spread PSF.If the PSF is spread farther, artifacts with sharp edges and many separated areas are the result as shown in figure 6.

Algorithms
In general, the contaminants cannot be specified and the product may also vary.This means, the general proper-150 ties which are different between correctly and incorrectly focussed images need to be used to detect the focal plane.
In this contribution we propose to use the set of following features: (1) peaks of image autocorrelation function, (2) number of objects and (3) pixels outside objects.

Autocorrelation
Incorrectly focussed images with a too wide PSF suffer from periodic artifacts, which need to be detected.The idea is to measure these changes by autocorrelation.The more peri-  focal plane out of one known impulse response by using algorithms also known in image processing as bilinear or bicubic scaling (details can be found in (Keys (1981))).
To estimate the height of an object above the belt, images 125 have to be reconstructed with scaled PSFs.In our case, 160 images corresponding to 160 focal planes with a distance of 0,5mm were calculated, yielding a range of 8 cm.As described in section 2, we used simulated X-ray scenarios of a thin metallic washer, diameter 2cm.Some examples of 130 these images are shown in figures 4 -7.The characteristics of these images and especially the differences between the correctly and incorrectly focussed images will be useful for understanding suitable algorithms.
If the inverse filtering PSF is too compressed, it nearly cor-135 responds to a dirac-impulse and therefore the result of the convolution with this PSF resembles the original blurred image after the scanning process (figure 4).The result is a very blurry image, but it shows only one object and not separated parts of the washer.Figure 5 depicts the result of an inverse 140 convolution with a wider spread PSF.If the PSF is spread farther, artifacts with sharp edges and many separated areas are the result as shown in figure 6.

Algorithms
In general, the contaminants cannot be specified and the product may also vary.This means, the general proper-150 ties which are different between correctly and incorrectly focussed images need to be used to detect the focal plane.
In this contribution we propose to use the set of following features: (1) peaks of image autocorrelation function, (2) number of objects and (3) pixels outside objects.

Autocorrelation
Incorrectly focussed images with a too wide PSF suffer from periodic artifacts, which need to be detected.The idea is to measure these changes by autocorrelation.The more peri- ties which are different between correctly and incorrectly focussed images need to be used to detect the focal plane.
In this contribution we propose to use the set of following features: (1) peaks of image autocorrelation function, (2) number of objects and (3) pixels outside objects.

Autocorrelation
Incorrectly focussed images with a too wide PSF suffer from periodic artifacts, which need to be detected.The idea is to measure these changes by autocorrelation.The more periodic artifacts appear in an image, the more peaks occur in the result of the image autocorrelation function.
The autocorrelation function is calculated for every image line.Figure 8 shows the resulting matrix after normalization.
After the summation of all lines the result is a ,,correlation line".To deal with varying image intensities, the maximum of the autocorrelation function is normalized to 1. Figure 9 shows an example for an autocorrelation function of a correctly focussed image and Fig. 10 for an incorrectly focussed image.
Obviously, the incorrectly focussed image produces more autocorrelation peaks than the correctly focussed.We propose to sum up the number of peaks of the correlation line.The autocorrelation function is calculated for every image line.Figure 8 shows the resulting matrix after normalization.After the summation of all lines the result is a ,,correlation line".To deal with varying image intensities, the maximum of the autocorrelation function is normalized to 1. Figure 9 shows an example for an autocorrelation function of a correctly focussed image and figure 10 for an incorrectly focussed image.
Obviously, the incorrectly focussed image produces more autocorrelation peaks than the correctly focussed.We propose to sum up the number of peaks of the correlation line.
These sums for all images over the image height index are shown in figure 11.The value near the best image is very low in comparison to incorrectly focussed images.As can be seen, this criterion is suitable expect for low-index (compressed PSF) images.So, for these images another algorithm has to be employed.

Object Count
Another difference between a correctly and most of the incor-180 rectly focussed images is the number of separated objects.To count the objects, an area has to be defined and divided into seperate objects.This is done by a binarisation and a following object segmentation.The binarisation threshold has to be determined adaptively depending on the background bright-185 ness.All connected white pixels are counted as one object.To find out which pixel groups belong together, well known segmentation algorithms (Ho (2011)) can be used.
Figure 12 shows two binarized images.Obviously, the 190 incorrectly focussed image contains more objects (white areas) than the correctly focussed image.Figure 13 shows the counted number of objects over the image height index.Obviously many images have only one object, especially the low index images and the images around the correctly This algorithm is more likely usable for an image preselection because it cannot determine the correctly focussed image, but it can detect images which are clearly incorrectly focussed.

Remaining Pixel Analysis
The two previous algorithms work well if the PSF is widely spread.They fail for blurred images, which result from inverse filtering with a narrow PSF.A possible solution for this problem is to count the pixels which remain outside the ob-205 jects after binarisation.This can be implemented very efficiently: The filtered image with white background is binarized after applying a noise suppressing Gaussian filter.This binarized image is multiplied with the inverted image.Since the color black corresponds to the value zero all pixels in ob-210 ject areas are suppressed.The number of remaining pixels will be summed up.
Figure 14 demonstrates the process, and figure 15 shows the sums of remaining pixels over the image hight index.As  The autocorrelation function is calculated for every image line.Figure 8 shows the resulting matrix after normalization.After the summation of all lines the result is a ,,correlation line".To deal with varying image intensities, the maximum of the autocorrelation function is normalized to 1. Figure 9 shows an example for an autocorrelation function of a correctly focussed image and figure 10 for an incorrectly focussed image.
Obviously, the incorrectly focussed image produces more autocorrelation peaks than the correctly focussed.We propose to sum up the number of peaks of the correlation line.
These sums for all images over the image height index are shown in figure 11.The value near the best image is very low in comparison to incorrectly focussed images.As can be seen, this criterion is suitable expect for low-index (compressed PSF) images.So, for these images another algorithm has to be employed.

Object Count
Another difference between a correctly and most of the incorrectly focussed images is the number of separated objects.To count the objects, an area has to be defined and divided into seperate objects.This is done by a binarisation and a following object segmentation.The binarisation threshold has to be determined adaptively depending on the background brightness.All connected white pixels are counted as one object.To find out which pixel groups belong together, well known segmentation algorithms (Ho (2011)) can be used.
Figure 12 shows two binarized images.Obviously, the 190 incorrectly focussed image contains more objects (white areas) than the correctly focussed image.Figure 13 shows the counted number of objects over the image height index.Obviously many images have only one object, especially the low index images and the images around the correctly This algorithm is more likely usable for an image preselection because it cannot determine the correctly focussed image, but it can detect images which are clearly incorrectly focussed.

Remaining Pixel Analysis
The two previous algorithms work well if the PSF is widely spread.They fail for blurred images, which result from inverse filtering with a narrow PSF.A possible solution for this problem is to count the pixels which remain outside the ob-205 jects after binarisation.This can be implemented very efficiently: The filtered image with white background is binarized after applying a noise suppressing Gaussian filter.This binarized image is multiplied with the inverted image.Since the color black corresponds to the value zero all pixels in ob-210 ject areas are suppressed.The number of remaining pixels will be summed up.
Figure 14 demonstrates the process, and figure 15 shows the sums of remaining pixels over the image hight index.As PSF) images.So, for these images another algorithm has to be employed.

Object count
Another difference between a correctly and most of the incorrectly focussed images is the number of separated objects.To count the objects, an area has to be defined and divided into seperate objects.This is done by a binarisation and a following object segmentation.The binarisation threshold has to be determined adaptively depending on the background brightness.
All connected white pixels are counted as one object.To find out which pixel groups belong together, well known segmentation algorithms (Ho, 2011) can be used.
Figure 12 shows two binarized images.Obviously, the incorrectly focussed image contains more objects (white areas) than the correctly focussed image.
Figure 13 shows the counted number of objects over the image height index.
Obviously many images have only one object, especially the low index images and the images around the correctly focussed image.
This algorithm is more likely usable for an image preselection because it cannot determine the correctly focussed image, but it can detect images which are clearly incorrectly focussed.

Remaining pixel analysis
The two previous algorithms work well if the PSF is widely spread.They fail for blurred images, which result from in- The autocorrelation function is calculated for every image line.Figure 8 shows the resulting matrix after normalization.After the summation of all lines the result is a ,,correlation line".To deal with varying image intensities, the maximum of the autocorrelation function is normalized to 1. Figure 9 shows an example for an autocorrelation function of a correctly focussed image and figure 10 for an incorrectly focussed image.
Obviously, the incorrectly focussed image produces more autocorrelation peaks than the correctly focussed.We propose to sum up the number of peaks of the correlation line.
These sums for all images over the image height index are shown in figure 11.The value near the best image is very low in comparison to incorrectly focussed images.As can be seen, this criterion is suitable expect for low-index (compressed PSF) images.So, for these images another algorithm has to be employed.

Object Count
Another difference between a correctly and most of the incorrectly focussed images is the number of separated objects.To count the objects, an area has to be defined and divided into seperate objects.This is done by a binarisation and a following object segmentation.The binarisation threshold has to be determined adaptively depending on the background brightness.All connected white pixels are counted as one object.To find out which pixel groups belong together, well known segmentation algorithms (Ho (2011)) can be used.
Figure 12 shows two binarized images.Obviously, the 190 incorrectly focussed image contains more objects (white areas) than the correctly focussed image.Figure 13 shows the counted number of objects over the image height index.Obviously many images have only one object, especially the low index images and the images around the correctly This algorithm is more likely usable for an image preselection because it cannot determine the correctly focussed image, but it can detect images which are clearly incorrectly focussed.

Remaining Pixel Analysis
The two previous algorithms work well if the PSF is widely spread.They fail for blurred images, which result from inverse filtering with a narrow PSF.A possible solution for this problem is to count the pixels which remain outside the ob-205 jects after binarisation.This can be implemented very efficiently: The filtered image with white background is binarized after applying a noise suppressing Gaussian filter.This binarized image is multiplied with the inverted image.Since the color black corresponds to the value zero all pixels in ob-210 ject areas are suppressed.The number of remaining pixels will be summed up.
Figure 14 demonstrates the process, and figure 15 shows the sums of remaining pixels over the image hight index.As  The autocorrelation function is calculated for every image line.Figure 8 shows the resulting matrix after normalization.After the summation of all lines the result is a ,,correlation line".To deal with varying image intensities, the maximum of the autocorrelation function is normalized to 1. Figure 9 shows an example for an autocorrelation function of a correctly focussed image and figure 10 for an incorrectly focussed image.
Obviously, the incorrectly focussed image produces more autocorrelation peaks than the correctly focussed.We propose to sum up the number of peaks of the correlation line.
These sums for all images over the image height index are shown in figure 11.The value near the best image is very low in comparison to incorrectly focussed images.As can be seen, this criterion is suitable expect for low-index (compressed PSF) images.So, for these images another algorithm has to be employed.

Object Count
Another difference between a correctly and most of the incorrectly focussed images is the number of separated objects.To count the objects, an area has to be defined and divided into seperate objects.This is done by a binarisation and a following object segmentation.The binarisation threshold has to be determined adaptively depending on the background brightness.All connected white pixels are counted as one object.To find out which pixel groups belong together, well known segmentation algorithms (Ho (2011)) can be used.
Figure 12 shows two binarized images.Obviously, the 190 incorrectly focussed image contains more objects (white areas) than the correctly focussed image.Figure 13 shows the counted number of objects over the image height index.Obviously many images have only one object, especially the low index images and the images around the correctly This algorithm is more likely usable for an image preselection because it cannot determine the correctly focussed image, but it can detect images which are clearly incorrectly focussed.

Remaining Pixel Analysis
The two previous algorithms work well if the PSF is widely spread.They fail for blurred images, which result from inverse filtering with a narrow PSF.A possible solution for this problem is to count the pixels which remain outside the ob-205 jects after binarisation.This can be implemented very efficiently: The filtered image with white background is binarized after applying a noise suppressing Gaussian filter.This binarized image is multiplied with the inverted image.Since the color black corresponds to the value zero all pixels in ob-210 ject areas are suppressed.The number of remaining pixels will be summed up.
Figure 14 demonstrates the process, and figure 15 shows the sums of remaining pixels over the image hight index.As verse filtering with a narrow PSF.A possible solution for this problem is to count the pixels which remain outside the objects after binarisation.This can be implemented very efficiently: The filtered image with white background is binarized after applying a noise suppressing Gaussian filter.This binarized image is multiplied with the inverted image.Since the color black corresponds to the value zero all pixels in object areas are suppressed.The number of remaining pixels will be summed up.
Figure 14 demonstrates the process, and Fig. 15 shows the sums of remaining pixels over the image hight index.As can be seen the process works well, therefore the correctly focussed image can be found easily by a minimum-search.

Combination of algorithms
Other test images showed that summing up the pixels out of objects could lead to a few wrong decisions.Therefore, a combination of the presented methods is proposed.The flowchart in Fig. 16 illustrates the concept of a full image detection process.
First, the remaining pixels and the number of objects are calculated.In addition, the number of edges are counted.This acts like counting the objects, but with a preceding edgefinding algorithm.
To identify that an image indicates a plane with a flat object, the following conditions are proposed: A correctly focussed image has to exhibit only one object, not more than a specific number of edges and a sum of remaining pixels lower than a specific threshold, which depends on the edge length.The thresholds have to be adapted to the specific

Combination of Algorithms
Other test images showed that summing up the pixels out of objects could lead to a few wrong decisions.Therefore, a combination of the presented methods is proposed.The 220 flowchart in figure 16 illustrates the concept of a full image detection process.
First, the remaining pixels and the number of objects are calculated.In addition, the number of edges are counted.This acts like counting the objects, but with a preceding edge-225 finding algorithm.
To identify that an image indicates a plane with a flat object, the following conditions are proposed: A correctly focussed image has to exhibit only one object, not more than a specific number of edges and a sum of remaining pixels 230 lower than a specific threshold, which depends on the edge length.The thresholds have to be adapted to the specific system.If no image satisfying the conditions can be identified, it is assumed that there is no distinguishable flat object.
To save computing time, the number of edges and the au-235 tocorrelations are calculated for images with one object only.The results of remaining pixels and of autocorrelations are combined to deliver a final result.In our example, the algorithm detects three images, which satisfy the conditions and the correct image (index 35 in this example) has been found.

Combination of Algorithms
Other test images showed that summing up the pixels out of objects could lead to a few wrong decisions.Therefore, a combination of the presented methods is proposed.The 220 flowchart in figure 16 illustrates the concept of a full image detection process.
First, the remaining pixels and the number of objects are calculated.In addition, the number of edges are counted.This acts like counting the objects, but with a preceding edge-225 finding algorithm.
To identify that an image indicates a plane with a flat object, the following conditions are proposed: A correctly focussed image has to exhibit only one object, not more than a specific number of edges and a sum of remaining pixels 230 lower than a specific threshold, which depends on the edge length.The thresholds have to be adapted to the specific system.If no image satisfying the conditions can be identified, it is assumed that there is no distinguishable flat object.
To save computing time, the number of edges and the au-235 tocorrelations are calculated for images with one object only.The results of remaining pixels and of autocorrelations are combined to deliver a final result.In our example, the algorithm detects three images, which satisfy the conditions and the correct image (index 35 in this example) has been found.system.If no image satisfying the conditions can be identified, it is assumed that there is no distinguishable flat object.
To save computing time, the number of edges and the autocorrelations are calculated for images with one object only.The results of remaining pixels and of autocorrelations are combined to deliver a final result.In our example, the algorithm detects three images, which satisfy the conditions and the correct image (index 35 in this example) has been found.

Results
Figure 17 shows the results of the steps of the combined algorithm for one of the washers.The parameters of the algorithms, like threshold values or Gaussian filter values were set up in such a way that they operate successfully for all test images.Objects with a height below 2 centimeters are considered flat, yielding a distinguished sharp plane.For objects higher than that, which are considered non-flat, no erroneous images satisfying the conditions have been found.

Conclusions
It has been demonstrated that the proposed technique is able to identify distinguishable flat objects in a set of images resulting from inverse filtering of a laminographic image for different focal planes.The algorithm is based on combining methods from autocorrelation techniques, object counts and pixels-outside-objects analysis.
Together with the idea of height variant inverse filtering this paves the way to extracting 3-D-Information out of 2-D scanned objects by using the laminographic effect of TDI-X-

Combination of Algorithms
Other test images showed that summing up the pixels out of objects could lead to a few wrong decisions.Therefore, a combination of the presented methods is proposed.The 220 flowchart in figure 16 illustrates the concept of a full image detection process.
First, the remaining pixels and the number of objects are calculated.In addition, the number of edges are counted.This acts like counting the objects, but with a preceding edge-225 finding algorithm.
To identify that an image indicates a plane with a flat object, the following conditions are proposed: A correctly focussed image has to exhibit only one object, not more than a specific number of edges and a sum of remaining pixels 230 lower than a specific threshold, which depends on the edge length.The thresholds have to be adapted to the specific system.If no image satisfying the conditions can be identified, it is assumed that there is no distinguishable flat object.
To save computing time, the number of edges and the au-235 tocorrelations are calculated for images with one object only.The results of remaining pixels and of autocorrelations are combined to deliver a final result.In our example, the algorithm detects three images, which satisfy the conditions and the correct image (index 35 in this example) has been found.

Combination of Algorithms
Other test images showed that summing up the pixels out of objects could lead to a few wrong decisions.Therefore, a combination of the presented methods is proposed.The flowchart in figure 16 illustrates the concept of a full image detection process.
First, the remaining pixels and the number of objects are calculated.In addition, the number of edges are counted.This acts like counting the objects, but with a preceding edgefinding algorithm.
To identify that an image indicates a plane with a flat object, the following conditions are proposed: A correctly focussed image has to exhibit only one object, not more than a specific number of edges and a sum of remaining pixels lower than a specific threshold, which depends on the edge length.The thresholds have to be adapted to the specific system.If no image satisfying the conditions can be identified, it is assumed that there is no distinguishable flat object.
To save computing time, the number of edges and the autocorrelations are calculated for images with one object only.The results of remaining pixels and of autocorrelations are combined to deliver a final result.In our example, the algorithm detects three images, which satisfy the conditions and the correct image (index 35 in this example) has been found.ray systems.The concept works well in our simulation setup, the next step will be to verify these results for a real system.

Fig. 1 .
Fig. 1.The laminographic effect: result of changing angle on (a) high objects (b) no impact on flat objects 55

Fig. 1 .
Fig. 1.The laminographic effect: result of changing angle on (a) high objects (b) no impact on flat objects

Figure 3
Figure 3 summarizes the imaging and reconstruction process, which produces an estimate Â of the unknown original image A In the reconstruction process, an impulse response is only valid for a single focal plane.The characteristics of the imag-120
et al.: Automatic Focus Algorithms for TDI X-Ray Image Reconstruction

Figure 3
Figure 3 summarizes the imaging and reconstruction process, which produces an estimate Â of the unknown original image A In the reconstruction process, an impulse response is only valid for a single focal plane.The characteristics of the imag-120

Fig. 3 .
Fig. 3. Block diagram of the whole imaging process.

Fig. 6 .Fig. 7 .
Fig. 6.Many separated objects and edges are the result of inverse filtering with widely spread PSF 155

Fig. 6 .Fig. 7 .
Fig. 6.Many separated objects and edges are the result of inverse filtering with widely spread PSF 155

Fig. 6 .Fig. 7 .
Fig. 6.Many separated objects and edges are the result of inverse filtering with widely spread PSF 155

Fig. 6 .
Fig. 6.Many separated objects and edges are the result of inverse filtering with widely spread PSF.

Fig. 6 .Fig. 7 .
Fig. 6.Many separated objects and edges are the result of inverse filtering with widely spread PSF 155

Fig. 7 .
Fig. 7. Results of inversion with correctly scaled PSF (a) washer on a low layer, (b) washer on a high layer.

Fig. 11 .
Fig. 11.Sum of maxima over image index, correctly focussed image leads to low values, but there are also images with lower values.

Fig. 12 .
Fig. 12.After binarisation only one object in correctly focussed image (a) many objects in incorrectly focussed image

Fig. 14 .Fig. 15 .
Fig. 14.After binarisation (a2, b2) and multiplication with original (a1,b1) there are many pixels remaining in the result of the blurred image (a1) and only a few pixels in the result of the sharp image (b3)

Fig. 12 .Fig. 12 .
Fig. 12.After binarisation only one object in correctly focussed image (a) many objects in incorrectly focussed image.

Fig. 14 .Fig. 15 .
Fig. 14.After binarisation (a2, b2) and multiplication with original (a1,b1) there are many pixels remaining in the result of the blurred image (a1) and only a few pixels in the result of the sharp image (b3)

Fig. 13 .
Fig. 13.Number of objects over image index for a washer on a low layer.

Fig. 12 .
Fig. 12.After binarisation only one object in correctly focussed image (a) many objects in incorrectly focussed image

Fig. 14 .Fig. 15 .
Fig. 14.After binarisation (a2, b2) and multiplication with original (a1,b1) there are many pixels remaining in the result of the blurred image (a1) and only a few pixels in the result of the sharp image (b3)

Fig. 14 .Fig. 12 .
Fig. 14.After binarisation (a2, b2) and multiplication with original (a1,b1) there are many pixels remaining in the result of the blurred image (a1) and only a few pixels in the result of the sharp image (b3).

Fig. 14 .Fig. 15 .
Fig. 14.After binarisation (a2, b2) and multiplication with original (a1,b1) there are many pixels remaining in the result of the blurred image (a1) and only a few pixels in the result of the sharp image (b3)

Fig. 15 .
Fig. 15.Sum of non-black pixels out-of objects (a) washer on a low layer, (b) washer on a higher layer.