Mga Pahina

Martes, Setyembre 15, 2015

Pattern Recognition via Texture

When you google the word texture, it returns the following definition:

noun: 1. the feel, appearance, or consistency of a surface or a substance
"skin texture and tone"
synonyms: feel, touch; appearance, finish, surface, grain; quality, consistency

In reality, one could easily identify a texture of a surface by merely evaluating it through our senses such as touch and sight. In machine learning however, we are only limited by the appearance of the image -- that is, the gradient of graylevel values across an area. In this activity, we use texture as a feature in recognizing patterns in an image. There are already several techniques in analyzing textures of images. In particular, we will be using the local binary pattern technique,  which is essentially non-reversible, meaning one cannot use the final output (that is, the histogram) to get back to the original image. 

Now how do we obtain the LBP feature vector? We follow the following algorithm:
  1.  Compare the graylevel value of a pixel to its eight nearest neighbors. If the neighbor is greater than the pixel itself, we make it equal to 1. For each pixel, there should be 8 binary numbers.
  2. Convert these 8 binary numbers to decimal by multiplying each binary number to their corresponding power of 2 - [1,2,4,8,16,32,64,128]. Sum them all.
  3. Do this for all pixels in the image. The end product should be another image set with pixel values ranging from 0 to 255.
This algorithm can be easier understood by following the following diagram:
Figure 1. LBP algorithm to be implemented

Upon writing the code, I tried it first to a random image I found in google. This is an image of a broken glass, which I find fascinating.
Figure 2. Image of the (left) shattered glass and its (right) corresponding LBP.

As one can see, you could still easily detect the location of the fractures, and the relatively smooth part of the mirror. In order to extract the features, one should obtain the histogram of the LBP values. In textures of the same class (fur, canvass, seeds and so on), the histogram should be relatively the same.
Shown below are just some of the texture classes I processed with their corresponding LBP histogram.
Figure 3. Class: Barley Rice


From the images shown above, one can easily see that the images are of similar textures, but different in colors. As expected, the histograms are relatively the same.

(a) Different canvas used
(b) Corresponding LBP images of canvas
(c) Histogram of the LBP for the canvas class
Figure 3. Sample images of the (a) original canvas used and the corresponding (b) lbp images. The histograms are shown in (c)

It is interesting to see that in Fig. 3, the histogram of the LBP for all canvas images are still relatively similar, regardless of the fact that the spatial patterns in the canvas have different directions/orientations.

I have also applied the algorithm to several other classes such as chips and seeds, among many others.

Refereces:

[1] Local Binary Patterns, Retrieved from  http://www.scholarpedia.org/article/Local_Binary_Patterns, dated September 15, 2015
[2] Images obtained from Outex - University of Oulu  from http://www.outex.oulu.fi/index.php?page=browse and retrieved September 15 2015






Walang komento:

Mag-post ng isang Komento