Sharpening filter for false color imaging of dual-energy X-ray scans

Dual-energy X-ray imaging has a vast range of application in security. Luggage inspection is an essential process for an airplane or court house security as well as securing mass events. An image of a content of some package may help to figure out if there is any dangerous object inside and avoid possibly threatening situation. As the raw X-ray images are not always easy to analyze and interpret, some image processing methods like an object detection, a frequency resolution increase or a pseudocoloring are being used. Since color can be a powerful tool to improve the usefulness of an information display, we propose pseudocoloring improvement by modifying material-based approach with edge detection to fill and sharpen color layers over the image making it easier to read and analyze. We demonstrate the effectiveness of the methods using real data, acquired from a professional dual-energy X-ray scanner.


Introduction
X-Ray scanners provide images based on different level of absorption of radiation of different materials. Scanners are used, for example, in medical tomography and security on which we focus. Dual-energy X-ray imaging is a well-known technique. It requires two measurements at different energies and allows displaying material properties (the effective atomic number and mass density). In most cases, the resulting images are displayed in gray scale where the most absorbing parts are colored white, and areas transparent to the X-rays are colored with black (see Fig. 1a). An inversion of this colorspace is also popular and frequently used. This kind of presentation, in some applications, is good enough for well-trained technicians, but the necessity of providing more details to images causes that some marking is required. A common approach is to use a linear color map (LCM) (see Fig. 1b). More advanced methods allow to classify scanned objects or their parts to certain materials on the basis of mass attenuation coefficient [1][2][3]. This coefficient depends on the material's atomic number. In theory, it should allow us to classify the object on the basis of their atomic number, but tests showed that objects' thickness has a major impact on the classification.
The proposed method-edge enhanced image pseudocoloring (EEIPC)-is based on material qualification, but also takes objects' shapes into account. An image features such a structure and geometric description are used to correct object assignment. Our aim is to provide images that allow to easily distinguish one object from another by significantly enhancing object edges during the colorizing procedure. The presented method is capable of colorizing objects in a way that it matches its material. It is also important to remove the most of artifacts and unexpected transitions of material color ranges, but preserving sharp borders between objects. The EEIPC method is an enhancement of the material classification presented in our previous work [4]. Similar image filter is also discussed in [5]. In this paper we also are concerned about assessment of image sharpness. We examine image sharpness and color using two measures: standard deviation of image histogram and LPC-Sharpness Index introduced in  [6,7]. It is also important to know that the most important quality estimation of our method comes from the scanners operators using this method in their daily work.

Methodology
X-ray inspection system is composed of X-ray source, X-ray detector and conveyor belt [8]. Security scanners use a very short (0.0110 nm) electromagnetic radiation waves. X-rays are emitted with photon energy ranging from 30 to 200 KeV [9]. Photons successfully passed through a scanned object are measured by detectors ordered in a L-shaped bar [10]. As the baggage goes through the scanner tunnel, the attenuated X-rays are collected by the row of detectors. Detectors' driver assembles data from multiple detectors into one discrete grayscale image.

Hardware
Our scanner works with a single X-ray monoblock generator and a dual-energy range detector which provides simultaneously two energy images. This means that during one-time X-ray shot, we obtain two sets of data for two images gen-eration (low and high energies, I LE and I HE , respectively). A detector for dual-energy digital radiography has a complicated construction. There are two scintillators, for low energy: GOS (153 mg/cm 2 ) and for high energy: CsI(TI). The first one is 3.0 mm thick, and the second one is 4.1 mm thick. There is also a filter element (0.6 mm copper) between LE and HE scintillators. In order to produce our test images, a tube generates X-rays using 160 keV voltage with 5300 A current, which are measured by the detectors after passing through scanned objects. We are using Spellman XRB160P model/type tube with X-Scan 1,5L-1253 DE-ENET detectors.
Tested objects were moved by conveyor at 40 cm/s speed rate. Scanned objects could have maximum width of 1000 mm and unlimited length due to the possibility of moving them horizontally.

Dual energy
For our scans, we use dual-energy data collection. Dualenergy X-ray imaging brings us benefits in the form of depth resolution enhancement, because of slightly different attenuation characteristics which are depending on photons energy. In this section data acquisition from detectors and creation of raw images is discussed, see [11]. The X-ray tube emits N 0 photons, but only N passes through the scanned object and reaches the detector. The numbers of photons that will pass through the object depends on its attenuation coefficient (μ) and object thickness (T ): The coefficient μ depends on the density of the material (ρ), and mass attenuation of the material (τ ). τ is experimentally obtained and tabularized function depending on the material effective atomic number (Z ) and energy of the photons (E): Attenuation graphs for some substances are displayed in Fig. 2. From Eq. (1) we have: and finally we get the following equation: where Ω is number of different materials. N 0 is a variable which depends on photon energy and it will be denoted as N 0 (E) from now. The X-ray spectrum is polychromatic in energy range [E1, E2]: where N 0 (E) is number of photons emitted with energy E in range [E1, E2]: where D(E) represents detector efficiency. The detector efficiency and X-ray tube spectrum are known. From the Eq. (6) it could be possible to determine Z value of each material in a scanned object but in real scan we do not know how much objects and what materials we have to designate proper ρ and τ values for this equation. To retrieve approximate information of an object material, we use combination of data from two measurements of different energies.
We receive number of registered photons that crossed a scanned object (N ) from the detector. Knowing the number of photons emitted (N 0 ), the ratio is: As it was stated in 2.1, we gather data in two energy ranges, LE and HE, see [13]. Finally, we can use following formulas, to calculate so-called Q values [14]: where (I LE ) and (I HE ) stand for low-energy image and highenergy image, respectively, and Q determines the expected material of an object registered on a pixel and will be used in the proposed algorithm.

Algorithm
A current section describes a coloring algorithm that uses two raw images received from the scanner to produce sharp and colorized image.

Material determination
X-ray images obtained for high energy (I HE ) and low energy (I LE ) are shown in Fig. 3. All image examples in this work are cropped to the region of interest from received scans. In order to determine the Q(x, y) value for every pixel we use quotient of the logarithms of object's material values (see Eq. 9) of HE and LE scan.
The number of materials (Ω) as well as their Q ranges can be chosen arbitrary. Typically to the standards used in the professional security scanners, only three types of materials are distinguished: After pixel classification we create Ω + 2 (number of materials, plus background and foreground) binary images for all material types based on pixel value: where i ∈ (0, Ω + 1), Q(x, y) is a quotient of the logarithms of I LE and I HE images (Eq. 9), Q i L and Q i H are low and high limits of the Q values for ith material, respectively (see Fig. 4).

Edge sharpening
Images generated in such a way are very sharp, and they have a lot of isolated pixels and unwanted artifacts. Such problem can be fixed by using a morphological filling or blurring. We use a simple Gaussian blurring technique to prepare those images for the next processing step. Optimal sizes of the Gaussian filter masks are ((S, T ) = 5, 5) and ((S, T ) = 7, 7), i.e., the kernel of a Gaussian filter with a standard deviation of σ ∈ (2/3, 1). A filter with smaller standard deviation is unable to cover all in-object holes, while bigger masks give no improvement in the final image while increasing computational complexity. As a result we obtain blurred (i = Ω + 2) material images: where Γ σ is a Gaussian blur operator. Because of the blurring procedure, the material images are overlapping each other nearby edges. We use the edge detection algorithm [15,16] to restore sharp edges.
= CED(I HE ) where CED is the Canny edge operator, I HE is the high energy image, and is an edge image. We chose the Canny edge detector due to its ability to describe edges in a vector form. It provides the information about an angle of a contrast gradient in every point classified as the edge.
where (x , y ) are pixels that belong to the edge determined by the Canny edge detector. A Sobel filter is used to calculate these gradient angles (θ ) from horizontal (g x ) and vertical (g y ) direction: These angles are often called contrast gradient degree. In the Canny algorithm, angles are discretized to one of the following four values (discretized directions θ D ) which are equal to 0 • , 45 • , 90 • and 135 • covering 45 • around each one. For every pixel which belongs to Canny's edge vector, the appropriate contrast gradient degree is assigned. We used voting algorithm to determine an affiliation of a point to a certain mask. The size of the region of interest created around current pixel is equal to the size of previously used Gaussian filter mask. An example is shown in Fig. 5. As shown in Fig. 5, a border found by the Canny algorithm is marked with black pixels (Fig. 5b). The central pixel r(x 0 , y 0 ) is a border point being processed in the current step. In this example the central pixel has the contrast gradient g(x, y) with angle θ D in the range of 45 • ± 22.5 • , so it  requires comparison of two neighboring pixels from SW and NE (pixels with bold border in Fig. 5b). Values of these two pixels are read from blurred material image π (i) σ (see Fig. 6), and a greater one is chosen.
A line perpendicular to the proper discretized gradient κ(g ⊥ (x, y)) splits the neighbor into two triangles (or two rectangles depending on the θ D ). This line is marked as diagonal line in our example image in Fig. 5b. The triangle (or rectangle) that contains the pixel with a higher value of a pixel r f (x, y) is being set as the foreground (dark background pixels in Fig. 5b), and the second part of the square is marked as the background (light background pixels in Fig. 5). These values are used to create so-called affiliation matrices which contains information whether the pixel is included in the material layer or not. Every affiliation matrix has the same size as the acquired image and is initially filled with zeros. Only the pixels that were effectively blurred are being processed this way (see Fig. 6c). Next, the algorithm fills the affiliation matrices with the proper values. Every pixel with a value equal to one (1) on the blurred image π (i) σ (pure black in Fig. 6b) will be mapped into maximum value on the affiliation matrix. Every pixel with a zero value on the same image will be mapped into minimal negative value on the affiliation matrix. The values of the other pixels are set to 0 (shown in a gray in Fig. 6b).
At this step, for each pixel in Canny edge image , the region of interest of the affiliation mask must be determined. This region is centered on the position of the current Canny edge vector pixel r(x 0 , y 0 ). The sizes of this region and Gaussian mask used in previous step are the same. In the region of interest for each foreground pixel, a positive value is added. This value is proportional to the distance between the point and the borderline κ(g ⊥ ) separating the foreground and the background parts. For each background pixel a negative value is added in the same manner.
where ||a, κ|| b is a signed distance between the vector a and the line κ depending on the direction of the unit vector b.
After the inspection of each edge pixel, all negative pixels are removed from the affiliation mask: It is the final step of the construction of the affiliation matrix for the single layer. Now the affiliation matrix must be determined for each material layers taking all the affiliation matrices into account. At this point of analysis there are some pixels that belong to several material layers. We have to determine to which single layer the analyzed pixel should be assigned. We use the voting algorithm which compares affiliation masks pixels from the same coordinates on different material layers. If pixel has a maximum value on some mask, its value is set to 1, while on the other masks the pixels on the same coordinates are set to zero.

Image colorizing
On the basis of the affiliation matrices α (i) and the corresponding low-energy image I LE and high-energy image I HE , we construct final color image. We have decided to use CIE L*a*b* color space because it separates achromatic channel from chromatic channels and due to its ability to compare colors as a simple Euclidean distance of its coordinates. With S-CIELAB extension it allows for measuring color reproduction errors of digital images [17].
To properly colorize scans a specific color maps are predefined for all material types, i.e., for all Q (i) material ranges a specific lightness L * (i) value as well as a * (i) and b * (i) chromatic color values are predefined. In this step we map high-energy image I HE into an L * channel and chromatic a * , b * channels are calculated using the following formulas where i ∈ (0, Ω + 1), and Ψ are mapping operations defined as: After coloring procedure, the final image is converted into sRGB color space and displayed to the scanner operator. Examples of original images and pseudocolored images as well as some edge details are shown in Figs. 7, 8, and 9. images we calculate contrast and sharpness indices for original grayscale images, images with linear color map (LCM) without sharpening filter and images colorized with the presented method (EEIPC). As a contrast measure we chose a standard deviation of an image histogram where i k is a kth image value, L is a maximum image value, h(i k ) is i k th value of a normalized histogram of the image, and h is an average value of the histogram. As an image sharpness measure we chose Local Phase Coherence Sharpness Index (LPC-SI) proposed by Hassen [7] which describes the alignment of local phase patterns in the scalespace in the vicinity of distinctive sharp image features and as a result gives a single To compare tri-chromatic images, σ and LPC-SI were calculated for each color channel separately in an sRGB color space and then the arithmetic average value from three channels was taken as a result. The quantitative evaluation results are given in Table 1 for original grayscale images, for images with linear color map (LCM) and for our colorizing method with sharpness filter (EEIPC). For every image we highlight the better evaluation measure value. The quantitative results show clearly that our EEIPC method gives more sharp edges and cleaner boundaries between objects at about 30 % compared to LCM method and almost 60 % compared to original grayscale images. It also does not change low-frequency parts of an image and preserves overall mean and contrast σ of the original image. Figure 7 shows a few examples of scans for original grayscale images, LCM colorized images and images colorized with our EEIPC method. There are also some closeups to edge details and material boundaries shown in Fig. 8 for both colorizing methods. Figure 9 shows a close to a part of a scan in chromatic channels of CIELAB color model. There are sharp metal edges clearly visible in Fig. 9b, d enhanced by our EEIPC method, whereas these edges are not visible at all when only a LCM method was used.
The most important benefit of presented algorithm is an ability to distinguish between material layers regardless of whether the edges of scanned object are smooth or sharp. The described algorithm can analyze unrestricted number of different layers. We have to remember that in practical scanning baggage procedure, inspectors can be confused seeing more than four different color ranges. Algorithm's time computational complexity depends linearly on the number of layers' edge pixels. For each layer the complexity is similar to two-dimensional convolution filter and is thus in the order of O(P M f ) where P is the number of pixels, M is number of material masks, and f is the area of the Gaussian mask. Presented algorithm runs almost real time on our testing machine with Intel i5-3470 3.2 GHz. Processing time for the testing images with resolution 900 × 540 pixels varies between 1 and 3 s for typical scanned object and three material layers. Such processing time is shorter than time needed for the scanner user to complete the operating task.

Conclusions and future
The discussed false coloring algorithm EEIPC has already been introduced into professional usage as a part of a software driver for scanners produced under the name of Arida. It is being used among others image adjusting and object detection algorithms. A colored X-ray image is a basic tool for baggage inspectors. This algorithm is also used for potential risk detection filter where areas of attenuation coefficient are close to known drugs and explosives. Currently our team works on an algorithm for risk detection based on both material properties and on geometric information like, for example, the shape of a weapon, see [18][19][20]. There is also important to evaluate the quality of the colorized images by a subjective quality tests in which a number of human subjects are asked to judge the quality of the sequence images. The subjective tests will be based on the recommendations given by the International Telecommunication Union (ITU) [21] that define how to carry out subjective quality tests.