The GIMP Retinex Filter Applied to the Fabric Fault Detection

In this paper we are proposing the use of a Retinex filter, the GIMP Retinex, for improving the methods for fabric fault detection based on image processing. Since the Retinex filtering is simulating the human vision, it can act in the processing of the images as the trained staff of textile industry is acting in the visual inspection of fabrics on off-line stations. Here some examples are proposed. These examples show that an image preprocessing based on a Retinex filter can help any further analysis aimed to detect the presence of defects.


Introduction
The visual inspection of woven fabrics is fundamental for textile producers to guarantee the quality of their products as being free from defects.Traditionally, trained staff is performing a visual inspection on offline stations for finding any fault present in the fabric.Sometimes the human inspection is supported by automatic inspection methods for detecting defects.Some of these inspection tools can also work during the production processes, that is, directly on the looms.
As discussed in [1], the automation of the visual inspection process [2] "is a multifaceted problem" which is requiring "complex interaction among various system components".Therefore, a relevant investment is necessary for the development of a final inspection system which could be commercialized.About twenty years ago, such an investment was considered as economically attractive [3], so that some industrial inspection systems had been developed (I-TEX from Elbit Vision Systems, Barco Vision's Cyclops, Zellweger Uster's Fabriscan) [4].In spite of the presence of commercial systems, the research for further improvements of the textile fault detection continues as evidenced by the recent publications on this subject, such as [5][6][7][8][9][10].
Actually, the studies for the development of automatic systems based on artificial vision for the textile fault detection started several years ago.The researches immediately evidenced the difficulties of such a task, difficulties that are intrinsic to the fact that fabric faults are often very small and hardly detectable, having a visibility strongly dependent on illumination (front or back lighting) and reduced by the vibrations of the mounting devices [11][12][13][14][15].
For the analysis of fabric textures, several statistical approaches had been used and developed [16][17], such as some methods based on the Fourier analysis of the grey levels of images [18], on the Gabor filtering [19,20] and wavelets with adaptive bases [21].In addition, an approach based on an image processing, developed for the study of liquid crystals [22], had been proposed by one of the authors of this article in [23][24][25].
To authors' best knowledge, there is a possibility not yet experimented, and this possibility is here proposed-It is the use of a Retinex filtering of the images of fabrics, to enhance the visibility of defects.Of the Retinex filtering, we have discussed in some recent papers, applying it to microscopy, radiography and detection of vehicles in foggy images [26][27][28][29][30].

Retinex filters
Of the Retinex filtering, let us shortly remember the following.Retinex filtering methods had been developed to solve some experimental observations.These experiments concerned the fact that it is easy to find discrepancies between an image we have recorded by a camera and the real scene we have observed.The reason is that humans are able to see details both in the shadows and in the nearby illuminated areas, whereas a photograph of the same scene is showing either the shadows as too dark or the bright areas as overexposed [31].
Modelled on the peculiar features of the human vision, which are quite different from those of the recording devices [32,33], several algorithms of image processing had been developed to simulate the human ability of adapting to adverse conditions.These algorithms are known as Retinex algorithms.The first of them was conceived by Edwin H. Land, an American scientist and inventor, best known as cofounder of Polaroid Corporation [34][35].As explained in Ref.31, through the years, Land evolved several models, until his last one proposed in 1986.The term "Retinex" was coined by Land himself, combining the words "retina" and "cortex", to indicate the results of his researches.These researches tell that the human colour perception is involving all levels of vision processes, from the retina to the cerebral cortex.
Several Retinex approaches exist [33,39]: the singlescale Retinex (SSR), the multiscale Retinex (MSR), and, for colour images, the MultiScale Retinex with Colour Restoration (MSRCR).Among MSRCR we find the GIMP Retinex, a freely available tool developed by Fabien Pelisson [40] (GIMP is the GNU image processing software).The resulting image of this filter can be adjusted selecting different levels, scales and dynamics.There are three "levels".The "uniform" level tends to treat both low and high intensity areas fairly; the "low" level "flares up" the lower intensity areas on the image; and the "high" level tends to "bury" the lower intensity areas in favor of a better rendering of the clearer areas of the image.
The "scale" determines the depth of the Retinex scale.Minimum value is 16, a value providing gross, unrefined filtering.Maximum value is 250.Optimal and default value is 240.A "scale division" determines the number of iterations in the multiscale Retinex filter.The minimum required and recommended value is three.The "dynamic" slider allows adjusting colour saturation contamination around the new average colour (default value is 1,2).

Faults in fabrics
Let us start the discussion of some examples, with a processing of some images of faults in fabrics by means of the GIMP Retinex.As we will see, this filter can improve the score of successful detections, by increasing the visibility of the defects.
Faults in the structure of woven fabrics are deviations from the recurrence of a fundamental unit, and usually appear as subtle lines, dark or bright, in the image frame.The more frequently encountered defects are broken or missing picks.Dust, extraneous staples or oil spots can also be observed.Let us start from the defect in the Figure 1.The image is showing a mispick, a rather common defect, produced when a yarn is lacking or broken on the loom.It is a defect expanding on the surface fabric and involving several neighbor yarns.Mispicks are easy to find by eye inspection, such as dust and little oil spots.These defects are eye-inspected with back lighting.The same illumination system was used to record image in the Figure 1.
We use the GIMP Retinex filter with the following parameters: Scale = 150, Scale division = 4 and Dynamic slider = 0.The result for the image in the Figure 1 is given in the Figure 2 for the three levels: uniform (U), low (L) and high (H).It is evident the selective action of the filtering, so the three outputs, that is the images U, L and H, are enhancing different features of the fabric.In particular, the low level (L) filtering seems suppressing the fault, whereas the high level (H) filtering enhances its visibility.
In fact, we have two images that we can compare, and they are the L and H filtered images.L could represent the fabric as it would be "without defect", and H the "defect".Using these images, we can try a further analysis by comparing them.The procedure can be that proposed in the following.Let us consider the image L in the Figure 2 and invert its colour tones with GIMP, having the panel L-I in the Figure 3a.We can add this image to image H.The result is an almost homogenous grey image, having the position of the defect evidenced by the bright region (Figure 3b).
To enhance the result, we can reduce the number of the grey tones to three or five.We have the results in the Figure 4.It is easy to imagine a segmentation of the image obtained by the proposed approach.In the Figure 4c for instance, we have used a thresholding which is able to evidence the position of the defect for an automatic inspection.In the following, using the same approach we have here proposed, some other examples of fabric fault detection are given.

Other defects
Let us consider the same fabric of the Figure 1, but here we see some dust on it, which is altering the light transmitted by the fabric.Again, we can do the same as in the Figure 2. The result is given in the Figure 5. Adding the High level filtered image to the inverse of the Low level filtered image we obtain the image in the left panel of Figure 6.In the right panel we can see the result given with a reduced number of grey tones.Of course, we can use a thresholding to have the image in the Figure 7, on which it is easy to make a segmentation for detecting the defects.
In the Figure 8, we can see on the left, the image of a missing pick, another quite common defect in fabrics.In the same image, we can see the result of the Retinex filtering.Again, using the same addition of images as previously proposed in the Figures 3 and 6, we can obtain the results given in the Figure 9.In these examples, we have considered an image of a certain fabric and from it, using the Retinex filter, we have obtained two images.One (L), which is obtained after selecting the low level filtering, is that where the lower intensity areas are evidenced.The other image, obtained using the high level (H), has the clearer areas which are favored.Let us note that, in the given examples, we have used a back lighting illumination system for inspecting the fabric.In them, we have seen a fault as a region which is transmitting more light.Therefore, L is close to the "good" fabric, H is close to the "bad" fabric.Therefore, from a single image of the fabric, we had two filtered images that we can compare to determine the presence of a defect.
In the Figure 10a, we can see another example of a defect observed using a back lighting.It is a weaving mismatch.This defect has an extension on 8-10 yarns and, sometimes, it is difficult to identify.In the Figure 10b we can see the image we obtain after mixing L and H image as made in the previously proposed cases.In the right panel of the Figure 10b we are giving the result after enhancing the contrast.In this example, the defect is stopping the light, but also in this case, the proposed approach based on L and H filtered images seems giving some interesting results.Another possible defect is that shown in the Figure 11a, where we see a fabric observed in front lighting.In the Figure 11b, we have the images we obtain after mixing L and H images.In the right panel, the result after thresholding.In fact, being the defect composed by bright yarns, for the Retinex filter it is the same as a region seen in back lighting which is transmitting more light.

Conclusion
As a conclusion, after the examples we have proposed in the previous images, we can tell that, from an image of a certain fabric, using the Retinex filter we can obtain at least two useful images.One can be that obtained after selecting the low level filtering (L), where we find the lower intensity areas of the image enhanced.The other image can be that obtained using the high level filter (H), where the clearer areas of the images are favored.If we suppose to work with a back lighting illumination system and that a fault is a part of the fabric which is transmitting more light, the proposed approach seems quite good.This happens because L is close to the "good" fabric and H is close to the "bad" fabric.In this manner, we have from an image of the fabric, two filtered images that we can compare to determine the presence of a defect.Some other studies are necessary to improve this approach based on Retinex filtering for the cases where defects are difficult to identify, such as when there are tiny flaws or doublepicks in the fabric.Unlike mispicks the doublepicks, which are defects that appear when two yarns are very close, produce very narrow lines in the fabric.However, some preliminary analyses of Retinex filtering seem quite promising.Let us end the article with a further example of a simple use of GIMP Retinex.In the previous examples we have proposed this filter for preprocessing the images to be used in an automatic vision system.However, GIMP Retinex can be used to help the direct human vision, for instance in detecting tiny flaws of the fabric.
A simulation is given in the Figure 12.In the upper panel we have the fabric as it could be seen in a direct inspection: the defects are hardly visible.However a simple filtering with GIMP Retinex gives us the presence of defects.Then, a device which is giving a filtered image could be used to improve the visual inspection on the off-line stations.

Figure 1 :
Figure 1: A mispick in a textile woven fabric.Image size is 40 mm.

Figure 2 :
Figure 2: The image in the Figure 1 is processed by means of GIMP Retinex, for Uniform (U), Low (L) and High (H) levels.

Figure 3a :
Figure 3a: Let us use image L in the Figure 2; we can invert the colour tones with GIMP, having the panel L-I.Adding L-I to H of Figure 2, we have the result shown in the following Figure 3b.

Figure 3b :
Figure 3b: In the image of the right panel, the grey areas are those where the two images are coincident.

Figure 4 :
Figure 4: The result obtained in the Figure 3b can be shown by a reduced number of grey tones.The grey tones are three in the panel A and five in the panel B. In the panel C, we can see the effect of the use of a suitable threshold.

Figure 5 :
Figure 5: The original image is processed using the GIMP tool.The images U, L and H show the results obtained using the GIMP Retinex, for Uniform, Low and High levels respectively.

Figure 6 :
Figure 6: Adding the High level filtered image to the inverse of the Low level filtered image from the Figure 5 we obtain the image in the left panel.In the right panel we can see the result given with a reduced number of grey tones.

Figure 7 :
Figure 7: Effect of a thresholding on the image in Figure 6.

Figure 8 :
Figure 8:The grey-tone image is showing a missing pick (image size is of 20mm).The other images (U, L and H) are those obtained using GIMP Retinex, for Uniform, Low and High levels.Note that the low level filtering is reducing the effect of the double pick, whereas the high level filtering is enhancing it.

Figure 9 :
Figure 9: Adding the High level filtered image to the inverse of the Low level filtered image from Figure 8 we obtain the image in the ( A ) panel.In the ( B ) panel, we can see the result given with a reduced number of grey tones.In panel ( C ) we can see the result after a suitable thresholding of the grey tones.

Figure 10a :
Figure 10a: A weaving mismatch in a fabric.This defect has an extension on 8-10 yarns and, sometimes, it is difficult to identify.The size of the figure is 20 mm.

Figure 10b :
Figure 10b: Here the results of filtering the image 10a.On the left, we can see the image we obtain after mixing a Low and High filtered images as made in the previously proposed examples.In the right panel we can see the result after enhancing the contrast.Again, a segmentation of this image is easy to perform to identify the defect.

Figure 11a :
Figure 11a: Defect in a complex fabrics with yarns of different colors (image size is 20 mm).

Figure 11b :
Figure 11b: Here the results of filtering the image 11a.On the left, we can see the image we obtain after mixing a Low and High filtered images as made for the example given in the Figure 3.In the right panel we see the result after enhancing the contrast.

Figure 12 :
Figure 12: In the upper panels, the simulation of a good fabric (left) and the same with defects (middle, right).A simple Retinex filtering is evidencing their visibility.