Image Texture and Color Analysis Guide
Image Texture and Color Analysis Guide
Images
Avinash Kak
Purdue University
2
CONTENTS (contd.)
Section Title Page
3
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
5
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
color) changes. However, as you will see in Section 5, this periodicity analysis is localized to the immediate
neighborhoods of the individual pixels. To the extent these within-neighborhood periodicity properties can be
used to recognize texture differences between the different regions in an image, I think the word “structural”
applies. ]
The first-order properties are typically based on the means, the variances, etc., of the pixel values. The
second-order properties involve comparing two pixel values at the same time. The second-order properties,
6
Texture and Color An RVL Tutorial by Avi Kak
therefore, investigate how one pixel at some reference location relates statistically to another pixel at a
location displaced from the reference location. Some researchers have also looked at characterizing textures
with third and higher order properties. These would involve investigating the grayscale and color
distributions at three or more pixels whose coordinates occupy specific positions vis-a-vis one another. Third
and higher order texture characterizations have been found to be too complex for a practical characterization
]
of textures.
• The same goes for the second invariance: It’s highly likely that
the orientation of the texture you used for training a machine
learning algorithm would not be identical to the orientations of
the same texture in the test images.
8
Texture and Color An RVL Tutorial by Avi Kak
9
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
10
Texture and Color An RVL Tutorial by Avi Kak
texture characterization.
2 0 1 1
0 1 2 0
1 1 1 2
0 0 1 1
11
Texture and Color An RVL Tutorial by Avi Kak
d = (1, 1) (1)
As we scan the “image” row by row by visiting each pixel from
top-left to bottom-right, if m is the grayscale value at the
current pixel and n the grayscale value at the pixel one position
to the right and one row below, we increment glcm[m][n] by 1.
Scanning the 4 × 4 array shown above, we get the following
3 × 3 GLCM matrix:
Image GLCM
• Looking at the first row, what this matrix tells us is that if the
reference pixel has grayscale value 0, it is never the case that
the displaced pixel also has grayscale value 0. And that there is
only one occurrence of the reference pixel having grayscale value
12
Texture and Color An RVL Tutorial by Avi Kak
13
Texture and Color An RVL Tutorial by Avi Kak
glcm(m, n). For the above example, this yields the result:
0 3 1
3 6 1
1 1 2
level differences. ]
14
Texture and Color An RVL Tutorial by Avi Kak
GLCM:
[0, 0, 0, 0, 0, 49]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[49, 0, 0, 0, 0, 0]
Texture attributes:
entropy: 1.0
contrast: 25.0
homogeneity: 0.166
• On the other hand, if in the script of Section 3.3, you set the
texture type to horizontal, you get the output shown below:
15
Texture and Color An RVL Tutorial by Avi Kak
GLCM:
[0, 0, 0, 0, 0, 49]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[49, 0, 0, 0, 0, 0]
Texture attributes:
entropy: 1.0
contrast: 25.0
homogeneity: 0.166
which is the same as what you saw for the vertical case. This
is a consequence of how the GLCM matrix is made symmetric.
In any case, we have no problem accepting this result since the
two textures are visually the same — even though they are
oriented differently.
16
Texture and Color An RVL Tutorial by Avi Kak
[0, 5, 0, 5, 0, 5, 0, 5]
[5, 0, 5, 0, 5, 0, 5, 0]
[0, 5, 0, 5, 0, 5, 0, 5]
[5, 0, 5, 0, 5, 0, 5, 0]
[0, 5, 0, 5, 0, 5, 0, 5]
[5, 0, 5, 0, 5, 0, 5, 0]
GLCM:
[50, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 48]
Texture attributes:
entropy: 0.999
contrast: 0.0
homogeneity: 0.489
• Here is the output of the script if you choose random for the
texture type:
17
Texture and Color An RVL Tutorial by Avi Kak
[2, 1, 4, 3, 2, 2, 5, 3]
GLCM:
[2, 3, 2, 2, 0, 1]
[3, 6, 4, 4, 3, 6]
[2, 4, 0, 1, 1, 8]
[2, 4, 1, 0, 2, 4]
[0, 3, 1, 2, 0, 2]
[1, 6, 8, 4, 2, 4]
Texture attributes:
entropy: 4.70094581328
contrast: 5.9693877551
homogeneity: 0.371428571429
GLCM:
[30, 0, 0, 0, 0, 0]
[0, 12, 0, 0, 0, 0]
[0, 0, 6, 0, 0, 0]
18
Texture and Color An RVL Tutorial by Avi Kak
[0, 0, 0, 6, 0, 0]
[0, 0, 0, 0, 12, 0]
[0, 0, 0, 0, 0, 32]
Texture attributes:
entropy: 2.28547139622
contrast: 0.0
homogeneity: 0.69387755102
• By the way, if you set the texture type to “None”, you get
default choices in lines (B19) through (B21) of the script. It is
these choices that created a 3 × 3 GLCM matrix for the 4 × 4
array that was used at the beginning of this section (see page 8)
to explain the basic idea of how one constructs a GLCM matrix.
19
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
• Typically, one does NOT construct a GLCM matrix for the full
range of grayscale values in an image. For 8-bit grayscale
images with its 256 shades of gray (that is, the value of the
brightness at each pixel is an integer between 0 and 255, both
ends inclusive), you are likely to create a GLCM matrix of size
of just 16 × 16 that corresponds to a re-quantization of the gray
levels to just 4 bits (for the purpose of texture characterization).
20
Texture and Color An RVL Tutorial by Avi Kak
Cityblock distance, also known as the Manhattan or the Taxicab distance. The Cityblock Distance between
any two points is the sum of the absolute differences of the cooordinates of the two points. More formally, the
Cityblock distance is referred to as the L1 norm. The 8 immediate neighbors of a pixel as shown at left below
are at a Chessboard Distance of 1 from the pixel. However, as shown at right below, only the two column-wise
closest neighbors and the two row-wise closest neighbors of a pixel are at a Cityblock distance of 1:
X X X X
X P X X P X
X X X X
In and of itself, the GLCM characterization does not care what distance metric you use for the displacement
vector d. ]
21
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
deterministic when all of the grayscale values in the image are identical — that is, when there
15 X15
X 1
Entropy = − log2 2−8
i=0 j=0
256
15 X15
X 1
= − (−8)
i=0 j=0
256
15 X15
X 1
= 8.
i=0 j=0
256
= 8 bits (3)
23
Texture and Color An RVL Tutorial by Avi Kak
• Now consider the opposite case, that is, when an image has the
same grayscale value at all the pixels. In this case, only one cell
of the GLCM matrix would be populated — the cell at the
[k, k] element of the matrix, assuming that the grayscale value
assigned to all the pixels is k. When you normalize the GLCM,
the solitary populated cell would get a value of 1 while all the
other cells would still be 0. Since log 1 is zero, it is easy to show
that the Entropy becomes zero for this case.
• The main rule to remember here is that the smaller the value
of the entropy the more nonuniform a GLCM matrix.
• Here are some other textures attributes that are derived from a
GLCM Matrix:
24
Texture and Color An RVL Tutorial by Avi Kak
M −1 M −1
P [i, j]2
X X
Energy =
i=0 j=0
M
X −1 M
X −1
Contrast = (i − j)2.P [i, j]
i=0 j=0
M −1 M −1
X X P [i, j]
Homogeneity =
i=0 j=0
1 + |i − j|
(4)
(4). This attribute takes on a low value when the values in the
GLCM matrix are large along and in the vicinity of the
diagonal. In the extreme case, if only the diagonal entries in the
GLCM matrix are populated, Contrast is 0. As you would
expect, when the displacement vector is (1, 1), the value of
Contrast for an image that consists of diagonal stripes of
constant grayscale values — with each stripe possibly of a
different grayscale value — is zero. This should explain the logic
used for creating the low contrast texture pattern in lines
(B12) through (B17) of the Python script that is shown in the
next section.
26
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
Shown below is the code that was used to generate the GLCM
results you saw previously on pages 11 through 15 of this tutorial.
#!/usr/bin/env python
## [Link]
## Author: Avi Kak (kak@[Link])
## Date: September 26, 2016
## This script was written as a teaching aid for the lecture on "Textures
## and Color" as a part of my class on Computer Vision at Purdue. This
## Python script demonstrates how the Gray Level Co-occurrence Matrix can
## be used for characterizing image textures.
27
Texture and Color An RVL Tutorial by Avi Kak
##
## Note that if uncomment line (A6), that sets the image size to 4
## and the number of gray levels of 3 regardless of the choices you
## make in lines (A7) and (A8)
##
## 2. Set the image size in line (A7)
##
## 3. Set the number of gray levels in line (A8)
##
## 4. Set the displacement vector by uncommenting one of the lines (A9),
# (A10), or (A11). However, note that the "low_contrast" choice for
## the contrast type in line (A5) is low contrast only when the displacement
## vector is set as in line (A9).
import random
import math
import functools
IMAGE_SIZE = 8 #(A7)
GRAY_LEVELS = 6 #(A8)
displacement = [1,1] #(A9)
#displacement = [1,0] #(A10)
#displacement = [0,1] #(A11)
28
Texture and Color An RVL Tutorial by Avi Kak
29
Texture and Color An RVL Tutorial by Avi Kak
30
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
aspects of LBP:
32
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
Fig. A
33
Texture and Color An RVL Tutorial by Avi Kak
------------------------------------------------
| | | | | |
| | | | | |
| | | | | |
------------------------------------------------
| | | p=4 | | |
| | p=5 | x | p=3 | |
| | x | | x | |
------------------------------------------------
| | | | | |
| | x | X | x | |
| | p=6 | | p=2 | |
------------------------------------------------
| | x | | x | |
| | p=7 | x | p=1 | |
| | | p=0 | | |
------------------------------------------------
| | | | | |
| | | | | |
| | | | | |
------------------------------------------------
Fig. B
34
Texture and Color An RVL Tutorial by Avi Kak
\Del l
--------->
.
A . B
--------------
| | . |
\Del k | | . |
| | . |
V | . |
.........|....... x |
| |
--------------
C D
35
Texture and Color An RVL Tutorial by Avi Kak
Fig. C
36
Texture and Color An RVL Tutorial by Avi Kak
Fig. D
0 0 0 1 1 0 1 1
38
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
39
Texture and Color An RVL Tutorial by Avi Kak
• I’ll next show the minIntVal versions of the binary patterns for
the image represented by the randomly generated 8x8 array of
numbers shown below. The binary patterns will be for the
parameter values R = 1 and P = 8. Here is the image array:
The image:
[5, 4, 2, 4, 2, 2, 4, 0]
[4, 2, 1, 2, 1, 0, 0, 2]
[2, 4, 4, 0, 4, 0, 2, 4]
[4, 1, 5, 0, 4, 0, 5, 5]
[0, 4, 4, 5, 0, 0, 3, 2]
[2, 0, 4, 3, 0, 3, 1, 2]
[5, 1, 0, 0, 5, 4, 2, 3]
[1, 0, 0, 4, 5, 5, 0, 1]
40
Texture and Color An RVL Tutorial by Avi Kak
pixel at (1,1):
pattern: [1, 1, 0, 1, 1, 1, 1, 1]
minbv: 01111111
pixel at (1,2):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
pixel at (1,3):
pattern: [0, 1, 0, 1, 1, 1, 0, 1]
minbv: 01010111
pixel at (1,4):
pattern: [1, 0, 0, 1, 1, 1, 1, 1]
minbv: 00111111
pixel at (1,5):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
pixel at (1,6):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
...
...
41
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
43
Texture and Color An RVL Tutorial by Avi Kak
44
Texture and Color An RVL Tutorial by Avi Kak
else: #(C28)
[Link](0) #(C29)
print("pattern: %s" % pattern) #(C30)
bv = [Link]( bitlist = pattern ) #(C31)
intvals_for_circular_shifts = [int(bv << 1) for _ in range(P)] #(C32)
minbv = [Link]( intVal = \
min(intvals_for_circular_shifts), size = P ) #(C33)
print("minbv: %s" % minbv) #(C34)
bvruns = [Link]() #(C35)
encoding = None
if len(bvruns) > 2: #(C36)
lbp_hist[P+1] += 1 #(C37)
encoding = P+1 #(C38)
elif len(bvruns) == 1 and bvruns[0][0] == ’1’: #(C39)
lbp_hist[P] += 1 #(C40)
encoding = P #(C41)
elif len(bvruns) == 1 and bvruns[0][0] == ’0’: #(C42)
lbp_hist[0] += 1 #(C43)
encoding = 0 #(C44)
else: #(C45)
lbp_hist[len(bvruns[1])] += 1 #(C46)
encoding = len(bvruns[1]) #(C47)
print("encoding: %s" % encoding) #(C48)
print("\nLBP Histogram: %s" % lbp_hist) #(C49)
• Shown below are the encodings for the local binary patterns for
each of the inner 6x6 section of the 8x8 image array presented
towards the end of the previous subsection:
pixel at (1,1):
pattern: [1, 1, 0, 1, 1, 1, 1, 1]
minbv: 01111111
encoding: 7
pixel at (1,2):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
pixel at (1,3):
pattern: [0, 1, 0, 1, 1, 1, 0, 1]
minbv: 01010111
encoding: 9
pixel at (1,4):
pattern: [1, 0, 0, 1, 1, 1, 1, 1]
minbv: 00111111
encoding: 6
45
Texture and Color An RVL Tutorial by Avi Kak
pixel at (1,5):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
pixel at (1,6):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
pixel at (2,1):
pattern: [0, 0, 1, 0, 0, 0, 0, 0]
minbv: 00000001
encoding: 1
pixel at (2,2):
pattern: [1, 0, 0, 0, 0, 0, 1, 0]
minbv: 00000101
encoding: 9
pixel at (2,3):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
pixel at (2,4):
pattern: [1, 0, 0, 0, 0, 0, 0, 0]
minbv: 00000001
encoding: 1
pixel at (2,5):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
pixel at (2,6):
pattern: [1, 1, 1, 1, 0, 0, 0, 0]
minbv: 00001111
encoding: 4
pixel at (3,1):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
pixel at (3,2):
pattern: [0, 0, 0, 0, 0, 0, 0, 0]
minbv: 00000000
encoding: 0
pixel at (3,3):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
46
Texture and Color An RVL Tutorial by Avi Kak
pixel at (3,4):
pattern: [0, 0, 0, 0, 1, 0, 0, 0]
minbv: 00000001
encoding: 1
pixel at (3,5):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
pixel at (3,6):
pattern: [0, 0, 1, 0, 0, 0, 0, 0]
minbv: 00000001
encoding: 1
pixel at (4,1):
pattern: [0, 0, 1, 0, 0, 0, 0, 0]
minbv: 00000001
encoding: 1
pixel at (4,2):
pattern: [1, 0, 1, 0, 1, 0, 1, 0]
minbv: 01010101
encoding: 9
pixel at (4,3):
pattern: [0, 0, 0, 0, 0, 0, 0, 0]
minbv: 00000000
encoding: 0
pixel at (4,4):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
pixel at (4,5):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
pixel at (4,6):
pattern: [0, 0, 0, 1, 1, 0, 0, 0]
minbv: 00000011
encoding: 2
pixel at (5,1):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
pixel at (5,2):
pattern: [0, 0, 0, 1, 1, 0, 0, 0]
minbv: 00000011
encoding: 2
47
Texture and Color An RVL Tutorial by Avi Kak
pixel at (5,3):
pattern: [0, 0, 0, 0, 1, 1, 1, 0]
minbv: 00000111
encoding: 3
pixel at (5,4):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
pixel at (5,5):
pattern: [1, 0, 0, 0, 0, 0, 0, 1]
minbv: 00000011
encoding: 2
pixel at (5,6):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
pixel at (6,1):
pattern: [0, 0, 0, 1, 0, 1, 1, 1]
minbv: 00010111
encoding: 9
pixel at (6,2):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
pixel at (6,3):
pattern: [1, 1, 1, 1, 1, 1, 1, 1]
minbv: 11111111
encoding: 8
pixel at (6,4):
pattern: [1, 0, 0, 0, 0, 0, 0, 0]
minbv: 00000001
encoding: 1
pixel at (6,5):
pattern: [1, 0, 0, 0, 0, 0, 1, 1]
minbv: 00000111
encoding: 3
pixel at (6,6):
pattern: [0, 0, 1, 1, 0, 1, 1, 1]
minbv: 00110111
encoding: 9
48
Texture and Color An RVL Tutorial by Avi Kak
• Shown below are the LBP histograms for the other cases of
textures you can produce with the [Link] script that is
presented in the next subsection.
Texture type: vertical
[5, 0, 5, 0, 5, 0, 5, 0]
[5, 0, 5, 0, 5, 0, 5, 0]
[5, 0, 5, 0, 5, 0, 5, 0]
[5, 0, 5, 0, 5, 0, 5, 0]
[5, 0, 5, 0, 5, 0, 5, 0]
[5, 0, 5, 0, 5, 0, 5, 0]
[5, 0, 5, 0, 5, 0, 5, 0]
[5, 0, 5, 0, 5, 0, 5, 0]
[5, 5, 5, 5, 5, 5, 5, 5]
[0, 0, 0, 0, 0, 0, 0, 0]
[5, 5, 5, 5, 5, 5, 5, 5]
[0, 0, 0, 0, 0, 0, 0, 0]
[5, 5, 5, 5, 5, 5, 5, 5]
[0, 0, 0, 0, 0, 0, 0, 0]
[5, 5, 5, 5, 5, 5, 5, 5]
[0, 0, 0, 0, 0, 0, 0, 0]
49
Texture and Color An RVL Tutorial by Avi Kak
[0, 5, 0, 5, 0, 5, 0, 5]
[5, 0, 5, 0, 5, 0, 5, 0]
[0, 5, 0, 5, 0, 5, 0, 5]
[5, 0, 5, 0, 5, 0, 5, 0]
[0, 5, 0, 5, 0, 5, 0, 5]
[5, 0, 5, 0, 5, 0, 5, 0]
[0, 5, 0, 5, 0, 5, 0, 5]
[5, 0, 5, 0, 5, 0, 5, 0]
50
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
All of the LBP based results shown earlier were produced by the
Python script shown below.
The script generates elementary textures for you and applies the
LBP algorithm to the textures. You can specify the texture you
want by uncommenting one of lines in (A1) through (A5).
The script allows you to set any arbitrary size for the image array
and the number of gray levels you want in the image.
The script also allows you to give whatever values you wish to the
P and R parameters needed by the LBP algorithm.
#!/usr/bin/env python
## [Link]
## Author: Avi Kak (kak@[Link])
## Date: November 1, 2016
## This script was written as a teaching aid for the lecture on "Textures and Color"
## as a part of my class on Computer Vision at Purdue.
##
## This Python script demonstrates how Local Binary Patterns can be used for
## characterizing image textures.
## For educational purposes, this script generates five different types of textures
## -- you make the choice by uncommenting one of the statements in lines (A1)
## through (A5). You can also set the size of the image array and number of gray
## levels to use.
51
Texture and Color An RVL Tutorial by Avi Kak
##
## 1. Specify the texture type you want by uncommenting one of the lines (A1)
## through (A5)
##
## 2. Set the image size in line (A6)
##
## 3. Set the number of gray levels in line (A7)
##
## 4. Choose a value for the circle radius R in line (A8)
#3
## 5. Choose a value for the number of sampling points on the circle in line (A9).
import random
import math
import BitVector
IMAGE_SIZE = 8 #(A6)
#IMAGE_SIZE = 4 #(A6)
GRAY_LEVELS = 6 #(A7)
R = 1 # the parameter R is radius of the circular pattern #(A8)
P = 8 # the number of points to sample on the circle #(A9)
52
Texture and Color An RVL Tutorial by Avi Kak
53
Texture and Color An RVL Tutorial by Avi Kak
encoding = 0 #(C44)
else: #(C45)
lbp_hist[len(bvruns[1])] += 1 #(C46)
encoding = len(bvruns[1]) #(C47)
print("encoding: %s" % encoding) #(C48)
print("\nLBP Histogram: %s" % lbp_hist) #(C49)
54
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
55
Texture and Color An RVL Tutorial by Avi Kak
primarily with the image resolution to be made available in a video service. MPEG-1, which is
the oldest such standard, specifies an image resolution of 352 × 240 at 30 fps (frames per
second). On the other hand, MPEG-2 specifies two image resolutions, 720 × 480 and 1280 × 720,
both at 60 fps. The acronym MPEG stands for “Moving Picture Experts Group”. MPEG is a
f0
fs = s = 0, 1, 2, 3, 4 (8)
2s
where s = 0 obviously corresponds to the outer boundary of the
outermost band. Note that, except for the lowest band, each
56
Texture and Color An RVL Tutorial by Avi Kak
Figure 1: Defining the Gabor texture channels for the MPEG-7 stan-
dard by dividing the spatial frequencies in polar coordinates. The Ga-
bor filter bank in this case consists of Gabor convolutional operators
at 6 orientations and 5 spatial frequencies.
57
Texture and Color An RVL Tutorial by Avi Kak
!
f0
band1 = , f0
2
!
f0 f0
band2 = ,
4 2
!
f0 f0
band3 = ,
8 4
!
f0 f0
band4 = ,
16 8
!
f0
band5 = 0,
16
58
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
59
Texture and Color An RVL Tutorial by Avi Kak
The real part (and also the imaginary part) of the expression on
the right above is a two-dimensional sinusoidal wave (think of an
ocean wave) in the (x, y) plane that cuts the x-axis at u-cycles
per unit length and the y-axis at v cycles per unit length.
θ = arctan(v/u) (14)
u = f ∗ cos(θ)
v = f ∗ sin(θ) (15)
60
Texture and Color An RVL Tutorial by Avi Kak
Z ∞ Z 2π −j2πf x cos(θ)+y sin(θ)
G(f, θ) = g(x, y)e dxdy (16)
r=0 θ=0
61
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
62
Texture and Color An RVL Tutorial by Avi Kak
• What that implies is that the best way to interpret the Gabor
operator is to think of it as a localized Fourier transform of an
image where, for the calculation at each locale in the image, you
weight the pixels away from the locale according to the
exponential decay factor. Obviously, the decay rate with respect
to the pixel coordinates is controlled by the ”standard
deviation” σ
64
Texture and Color An RVL Tutorial by Avi Kak
!
1 − 12 i2 +j22
hre (i, j; f, θ) = √ e 2σ cos 2πf (i cos(θ) + j sin(θ))
πσ
!
1 2
1 i +j 2
him (i, j; f, θ) = √ e− 2 2σ2 sin 2πf (i cos(θ) + j sin(θ))
πσ
(23)
where i represents the row index and the j the column index.
Note that we commonly think of the x-axis as being along the
horizontal, going from left to right, and the y-axis as being
along the vertical, going from bottom to top. However, in the
discrete version, we think of the i index as representing the rows
(that is, i is along the vertical, going from top to bottom, and j
is along the horizontal, going from left to right. The origin in
the continuous case is usually at the center of the (x, y) plane.
The origin in the discrete case is at the upper left corner.
• An important issue for the discrete case is how far one should
go from the origin for a given value of σ. Obviously, the smaller
the value of σ, the faster the drop-off in terms of the weighting
given to the pixels in the image, and, therefore, the smaller the
effective footprint of the operator on the (x, y) plane. A
commonly used rule of thumb for the discrete case is to let i and
j cover a bounding box that goes from −int(3σ) to int(3σ)
along the x and the y axes.
65
Texture and Color An RVL Tutorial by Avi Kak
1
√ (24)
πσ
its purpose is to ensure that the “energy” of the operator is
unity. For the continuous case, the energy constraint is defined
as
Z ∞ Z ∞
|h(x, y)|2 = 1 (25)
x=−∞ y=−∞
int(3σ) int(3σ)
X X
|h(i, j)|2 ≈ 1 (26)
i=−int(3σ) j=−int(3σ)
66
Texture and Color An RVL Tutorial by Avi Kak
67
Texture and Color An RVL Tutorial by Avi Kak
• The Gabor filter bank shown in the figure was used to measure
the texture in the following 32 × 32 image array:
[5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5, 0, 5, 0, 5, 0, 5, 0, 5, 0]
68
Texture and Color An RVL Tutorial by Avi Kak
69
Texture and Color An RVL Tutorial by Avi Kak
• The fact that the third column has the highest values is
consistent with the orientation of the texture in the image.
[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
• In the output shown above, recall again that the first column for
the orientation of 0 radians with respect to the vertical, the
second for 45 degrees, the third for 90 degrees, and the last for
135 degrees, all with respect to the vertical and going
counter-clockwise. We see that the highest spectral energy is
now at 0 degrees which is consistent with the new orientation of
the texture.
• With regard to the rows shown above, the first row is for 2
cycles per window width, the second for 4 cycles per window
width, and the third for 6 cycles per window width. Since the
pattern of the alternations in the texture is the same as before
(albeit its new rotation), we again expect the maximum spectral
energy to be roughly around 6 cycles per window width. This is
borne out by the output shown above.
[2, 3, 3, 0, 3, 0, 5, 5, 2, 0, 1, 4, 2, 2, 4, 2, 1, 4, 1, 1, 0, 4, 3, 3, 4, 1, 1, 2, 3, 2, 1, 1]
[2, 5, 5, 5, 5, 2, 2, 2, 2, 2, 1, 0, 5, 3, 0, 4, 4, 2, 0, 3, 1, 5, 0, 4, 5, 5, 4, 1, 1, 5, 0, 1]
[5, 0, 0, 3, 3, 5, 1, 0, 3, 5, 1, 1, 5, 3, 2, 4, 1, 1, 5, 3, 4, 1, 3, 1, 0, 4, 4, 5, 2, 3, 5, 3]
[0, 4, 1, 5, 5, 4, 5, 2, 0, 1, 0, 2, 0, 3, 2, 5, 1, 4, 1, 0, 3, 5, 1, 3, 2, 0, 4, 3, 5, 5, 3, 5]
[3, 1, 1, 0, 5, 5, 5, 2, 5, 1, 0, 0, 5, 1, 2, 1, 0, 3, 2, 4, 0, 1, 0, 3, 0, 1, 5, 1, 0, 2, 4, 0]
[0, 0, 4, 5, 1, 5, 4, 3, 4, 1, 3, 1, 0, 3, 4, 5, 0, 5, 4, 0, 1, 5, 2, 2, 5, 4, 3, 1, 5, 4, 5, 1]
[1, 3, 3, 2, 1,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, 1, 2, 4, 5, 3, 4, 0, 4, 2, 2, 3, 3, 0, 1, 5, 3, 1, 2, 0, 5, 0, 3, 5]
[4, 3, 1, 5, 2, 1, 4, 5, 4, 3, 0, 5, 3, 2, 0, 0, 4, 0, 5, 2, 0, 1, 0, 1, 0, 0, 0, 3, 0, 2, 4, 1]
[3, 4, 3, 0, 3, 1, 3, 2, 5, 4, 1, 1, 2, 1, 3, 4, 3, 1, 1, 1, 5, 3, 0, 2, 4, 0, 1, 0, 4, 3, 2, 5]
[4, 3, 1, 1, 0, 5, 0, 1, 0, 4, 0, 0, 4, 5, 5, 5, 2, 1, 0, 0, 3, 0, 4, 4, 0, 4, 2, 0, 1, 3, 0, 1]
[2, 1, 1, 4, 3, 4, 0, 0, 5, 1, 3, 4, 2, 3, 2, 1, 1, 5, 5, 0, 1, 4, 5, 4, 0, 0, 0, 1, 1, 0, 5, 4]
74
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
All of the Gabor based results shown earlier were produced by the
Python script shown below.
The script generates elementary textures for you and applies Gabor
filter bank to the image array. You can specify the texture you
want by uncommenting one of lines in (A4) through (A8).
The script allows you to set any arbitrary size for the image array
and the number of grayscale values you want in the image.
Note that you must also set the size of the Gabor σ and the size of
the convolutional operator in lines (A29) and (A30).
#!/usr/bin/env python
## [Link]
## Author: Avi Kak (kak@[Link])
## Date: October 15, 2016
## This script was written as a teaching aid for the lecture on "Textures and Color" as
## a part of my class on Computer Vision at Purdue.
##
## This Python script demonstrates how Gabor Filtering can be used for characterizing
## image textures.
## Just for the sake of playing with the code, this script generates five different types
75
Texture and Color An RVL Tutorial by Avi Kak
## of "textures". You make the choice by uncommenting one of the statements in lines
## (A4) through (A8). You can also set the size of the image array and number of grayscale
## values to use in lines in lines (A9) and (A10)
import random
import math
import sys, glob, os
if sys.version_info[0] == 3:
import tkinter as Tkinter
from [Link] import *
else:
import Tkinter
from Tkconstants import *
from PIL import Image
from PIL import ImageDraw
from PIL import ImageTk
import functools
76
Texture and Color An RVL Tutorial by Avi Kak
77
Texture and Color An RVL Tutorial by Avi Kak
op_imag[-(gabor_size//2)+k][-(gabor_size//2)+l] #(A61)
filter_outputs[freq][direc] += \
[Link]( real_part**2 + imag_part**2 ) #(A62)
filter_outputs = list(map(lambda x: x / (1.0*(rowmax-rowmin)*(colmax-colmin)),
filter_outputs[freq]) for freq in range(1,how_many_frequencies)) #(A63)
print("\nGabor filter output:\n") #(A64)
for freq in range(len(filter_outputs)): print(list(filter_outputs[freq])) #(A65)
78
Texture and Color An RVL Tutorial by Avi Kak
main() #(G1)
79
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
80
Texture and Color An RVL Tutorial by Avi Kak
81
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
[Link]
85
Texture and Color An RVL Tutorial by Avi Kak
feature map.
[By the way, each layer in a neural network is “delimited” by what’s known as the activation
function. Without such activation functions, the entire neural network would reduce to
subjecting the input data to a large vector-matrix product.]
Figure 4: This figure depicts the output from each layer of a typical neural network meant
for processing images. The output consists of a certain number of channels. As shown here,
for the layer indexed l, the output data consists of Nl channels. Since the input to each layer
is the output from the previous layer, the layer inputs possess the same shape as shown in
the figure, except that the image dimensions and the number of channels will be different for
the input and the output. When the input consists of color images, the number of channels
in the input at the first layer, meaning the layer indexed l = 0, equals 3.
86
Texture and Color An RVL Tutorial by Avi Kak
87
Texture and Color An RVL Tutorial by Avi Kak
T
Gl = Fl · Fl
M
X l −1
Glij = l
Fi,k l
· Fj,k (27)
k=0
88
Texture and Color An RVL Tutorial by Avi Kak
89
Texture and Color An RVL Tutorial by Avi Kak
90
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
mean and the standard deviation in the data, you subtract the
mean, and divide by the standard deviation. However, it is
critical to honor the said constraint.
B H W
1 XXX
µc = xnchw (28)
BHW n=1
h=1 w=1
v
u
u 1 X B XH X W
σc = t (xnchw − µc )2 + ǫ (29)
BHW n=1 w=1 h=1
xnchw − µc
BN (xnchw ) = γc · + βc (30)
σc
• The parameters γc and βc are referred to as the scale and the
shift parameters for the channel in question. More generally,
92
Texture and Color An RVL Tutorial by Avi Kak
they are together called the the affine parameters that must
be learned on a per channel basis in each layer that uses BN.
H W
1 XX
µcn = xnchw (31)
HW
v h=1 w=1
u
u 1 XH X W
σcn = t (xnchw − µcn )2 + ǫ (32)
HW w=1
h=1
xnchw − µcn
IN (xnchw ) = γcn · + βcn (33)
σcn
Note that the affine parameters γcn and βcn for data
normalization are now learned on a per-instance basis in each
channel.
xnchw − µcn
AdaIN (xnchw , yc) = σy · + µyc (34)
σcn
94
Texture and Color An RVL Tutorial by Avi Kak
Figure 8: The naming convention for the different components of the VGG19 network. From
[Link]
96
Texture and Color An RVL Tutorial by Avi Kak
98
Texture and Color An RVL Tutorial by Avi Kak
• Shown below are the result for one of the several pairs of
content and style images in the AdaIN paper.
Figure 9: Comparative results from the AdaIN paper. “Ours” means the authors of the AdaIN paper.
100
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
algorithm to each color channel separately? If you do, how would you combine the three
characterizations? Yes, one could possibly “concatenate” the three characterizations. But might there
be other ways to represent color images so that such a concatenation would become unnecessary? ]
saturation (S), and brightness (I/V/L), where I stands for intensity, V for value, and L for
lightness. ]
“Opponent Color Spaces” in Section 7.3.5 of this tutorial for what is meant by “red-green” and
“yellow-blue” values. The L*a*b* space has become very important for the purpose of data
visualization. It is now well known that the changes in data are best visualized if they
correspond to proportional changes in the L* value in the color graphic used for visualization. ]
102
Texture and Color An RVL Tutorial by Avi Kak
Figure 10: The goal here is to segment out the fruitlets from the
image on the left. The segmentation shown at right is based on just
hue filtering. We accept all pixels whose hue values are between 0◦
and 30◦. The image at left was supplied by Dr. Peter Hirst, Professor
of Horticulture, Purdue University. The segmentation result shown
was obtained by invoking the function apply color filter hsv()
of my Python based Watershed module.
103
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
104
Texture and Color An RVL Tutorial by Avi Kak
blue laser, a human observer would perceive this combined light as magenta. On the other
hand, if we could produce a spectrally pure light at a wavelength halfway between blue and
red, that light would not be perceived as magenta. In other words, both the average
wavelength and the shape of the spectral distribution are important for characterizing hue. ]
two degrees of freedom, everything conveyed by the chromaticity plane can also be conveyed
by its projection on either the XY, or the YZ, or the XZ plane. Such a projection is referred
106
Texture and Color An RVL Tutorial by Avi Kak
• Last but not the least is the great difficulty of making reliable
measurements of color if the goal is for these measurements to
reflect the “true” colors of the object surfaces in a scene.
107
Texture and Color An RVL Tutorial by Avi Kak
– Hardware engineers: These are folks charged with pushing the state
of the art in the fabrication of RGB based sensors that go into
cameras and other devices. For a lot of them, their principal focus is
on improving the spatial resolution of the sensors. They are proud
of the fact that their devices can give you as many as
256 ∗ 256 ∗ 256 = 1, 677, 256 colors, and they are truly perplexed by
humans wanting more. [This number is based on using 8-bits for each of the
so-called primary colors, R, G, and B]
tutorial. What that implies is that many of the fundamental limitations of the RGB
representation also apply to HSI/V/L representations.]
• It’s almost like the parable of the six blind men and the
elephant.
108
Texture and Color An RVL Tutorial by Avi Kak
the catalog frequently because my wife is on their mailing list — for reasons that should be
1. Margaretha Schwarz, Lynne Grewe, and Avi Kak, “Representation of Color and
Segmentation of Color Images,” Purdue University Technical Report, 1-1-1994.
Paper 171, January 1994.
[Link]
109
Texture and Color An RVL Tutorial by Avi Kak
3. Jae Byung Park and Avinash C. Kak, “A New Color Representation for
Non-White Illumination Conditions,” Purdue University Technical Report,
6-1-2005, Paper 8, June 2005.
[Link]
110
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
111
Texture and Color An RVL Tutorial by Avi Kak
photo receptors are sensitive mostly to monochromatic blue. In the past, L, M, and S
photo receptors have been loosely associated with R (for red), G (for green), and B
(for blue).]
The three spectral responses shown in the figure have
commonly been denoted hR (λ), hG(λ), and hB (λ) in the
literature.
Figure 11: The retina of the human eye contains three different types
of photo receptors for color vision. The spectral responses of the three
types are shown here. This figure is from the Wikipedia page on “Color
Vision”.
112
Texture and Color An RVL Tutorial by Avi Kak
Z
R = fill (λ)fref (λ)hR (λ)dλ
Z
G = fill (λ)fref (λ)hG (λ)dλ
Z
B = fill (λ)fref (λ)hB (λ)dλ (35)
processing of color in the visual cortex of the brain remains largely a mystery. ]
113
Texture and Color An RVL Tutorial by Avi Kak
Similarly, the G filter passes through light at or in close vicinity to the 545 nm wavelength, the
wavelength of the pure green hue. And, the B filter passes through light at or in close vicinity to the
] Mathematically, this
480 nm wavelength, the wavelength of the pure blue hue.
114
Texture and Color An RVL Tutorial by Avi Kak
115
Texture and Color An RVL Tutorial by Avi Kak
Figure 12: This figure shows how much red, how much green, and
how much blue is needed at each wavelength to match the spectral color
at that wavelength. Obviously, the wavelengths where the curve goes
negative means that it is not possible to match those spectral colors
with a combination of R, G, and B. This figure is from the Wikipedia
page on “CIE 1931 color space”.
other colors that are normally seen by humans could be synthesized by mixing them. ]
116
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
• So far I have talked about the RGB space in some detail, and I
have briefly mentioned the names of the XYZ and the HSI/V/L
spaces. Each of these color spaces amounts to representing color
by a point in three dimensions.
• In the rest of this section, I’ll first explain the idea of the
Chromaticity Space. Subsequently, I’ll discuss the relationship
between different types of 3D color spaces.
117
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
~ +YY
C = XX ~ + ZZ
~ (36)
shown next.]
Z
X = k P (λ)x̄(λ)dλ
Z
Y = k P (λ)ȳ(λ)dλ
Z
Z = k P (λ)z̄(λ)dλ (37)
X
C = Y (38)
Z
Figure 13: This figure shows how much of each of the primaries X,
Y, and Z it takes to produce a spectral color. This figure is from the
Wikipedia page on “CIE 1931 color space”.
119
Texture and Color An RVL Tutorial by Avi Kak
X
x =
X +Y +Z
Y
y =
X +Y +Z
Z
z =
X +Y +Z
(39)
x+y+z =1 (40)
u
u′ =
u+v
v
v′ =
u+v
(41)
120
Texture and Color An RVL Tutorial by Avi Kak
Just by substitution, the reader can easily verify that for all the
points along the line OA in the (u, v) space in Figure 14, the
corresponding u′ and v ′ values will be at A′ . Similarly, all the
points on the line OB will be mapped to the point B ′ , and so
on. [In other words, the entire positive quadrant in the (u, v) plane will be mapped to the line
PQ. Mathematically, this fact is inferred readily from the observation that u′ + v ′ must equal 1 for all
mapped points. ]
123
Texture and Color An RVL Tutorial by Avi Kak
as shown in Figure 17. This figure points to the main use of the
color depiction through Chromaticity Planes or Diagrams. The
triangle that is shown inside the overall rounded cone
corresponds to the sRGB color space. [sRGB is the RGB color space as
standardized by CEI. The prefix letter “s” stands for “standardized”.] The colors that
the periphery of the large rounded cone are the pure spectral
colors. So if you could tune the wavelength of a laser, you would
move around the rounded perimeter shown in the diagram.
124
Texture and Color An RVL Tutorial by Avi Kak
125
Texture and Color An RVL Tutorial by Avi Kak
Figure 18: Chromaticity Plane that shows the locations of red, green,
and blue on the plane.
126
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
mixtures, the positive “quadrant” of the RGB space is a subset of the positive quadrant
127
Texture and Color An RVL Tutorial by Avi Kak
are coplanar in Figure 18, they are non-coplanar in the RGB cube of
Figure 19. This contradiction is not real for the following reason: In the
chromaticity depiction, every color is forced to lie on the chromaticity
plane of Figure 18 whether or not it really does. In other words, the
chromaticity coordinates only give us the relative proportions of the
primaries in a mixture but not their true values. So, it may well be that
to produce the color white we may have to be at the point W ′ , but, as far
the chromaticity depiction is concerned, the color white will be
represented by the point W .]
128
Texture and Color An RVL Tutorial by Avi Kak
X 0.618 0.177 0.205 R
Y = 0.299 0.587 0.114 G (42)
Z 0.000 0.056 0.944 B
129
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
White, I=1.0
Intensity
Green Hue
120 degrees
Black
I=0.0 θ for hue
saturation
130
Texture and Color An RVL Tutorial by Avi Kak
131
Texture and Color An RVL Tutorial by Avi Kak
R C
B C
w G
I
v
S
H C
v
C
u
Figure 21: The RGB cube is tilted and rotated in the manner shown
here for deriving a relationship between RGB and HSI coordinates.
The longest diagonal of the cube becomes aligned with the vertical In-
tensity (I) axis in HSI. The Hue (H) coordinates of HSI is measured
counterclockwise from the projection of the RGB cube’s red corner on
the horizontal plane. Saturation (S) is the radial distance from the
vertical axis.
132
Texture and Color An RVL Tutorial by Avi Kak
Cv
H = tan−1
Cu
p
S = Cu2 + Cv2
I = Cw (43)
133
Texture and Color An RVL Tutorial by Avi Kak
r
2R − G − B
Cu =
6
r
G−B
Cv =
2
R+G+B
Cw = (44)
3
!
Cu
H = cos−1 p if G >= B
Cu2 + Cv2
!
C
= 360 − cos−1 p u if G < B
Cu2 + Cv2
(45)
134
Texture and Color An RVL Tutorial by Avi Kak
3 · min(R, G, B)
S = 1 − (47)
R+G+B
Although useful in an approximate sense, there are serious
conceptual shortcomings in the above derivation of the
transformation. First and foremost, we assumed the RGB space
to be orthogonal. As mentioned earlier, while the R, G, and B
vectors may be linearly independent in the XYZ space, they are
certainly not orthogonal. Their orthogonality in Figure 12 was
meant simply to make easier the visualization of color
distributions.
• The goal of what I have described so far was to give the reader
a sense how one can set up a connection between the RGB and
the HSI color spaces. Using this reasoning, along with some
refinements related to explicitly factoring in the piecewise
135
Texture and Color An RVL Tutorial by Avi Kak
]
modifications by me to reflect how they are actually implemented in code.
M = max(R, G, B)
m = min(R, G, B)
c = M −m
R+G+B
I =
3
G−B
60 c
mod 6 if M = R, c 6= 0
60 B−R +2 if M = G, c 6= 0
H = c
60 R−G +4 if M = B, c 6= 0
c
0.0 if C = 0
0 if c = 0
S =
1 − mc if c =6 0
(48)
• Shown below are the formulas that take you from HSI to RGB.
In these formulas, we represent a point in the HSI space by the
triplet (H, S, I). The variable hr stands for the value of H in
radians (as opposed to degrees) and the variable hk is the
corresponding angle offset in each of the 120◦ segments of the
hue circle. As you know from the previous discussion, the 0◦
point for H corresponds to pure red, the 120◦ point to pure
green, and the 240◦ point to pure blue. In terms of radians
these points are at 0, 2π/3 and 4π/3 radians. [Strictly speaking, I should
not have shown the expression for calculating the three variables (x, y, z) in a single line — since the
] The input to
calculation for z requires that you first have calculated the values for x and y.
137
Texture and Color An RVL Tutorial by Avi Kak
hr = 0.0174532925 × H
hr if 0 ≤ hr ≤ 23 π
hk = hr − 2 π if 23 π < hr ≤ 34 π
3
4
hr − 3 π if 43 π < hr < 2π
!
1 − S 1 + S cos(hk )
(x, y, z) = , , 1 − (x + y)
3 3 cos( π3 − hk )
(x′ , y ′, z ′ ) = 3 × I × x, 3 × I × y, 3 × I × z
(I, I, I) if S = 0
(y ′ , z ′ , x′ ) if 0 ≤ hr ≤ 2 π
(R, G, B) = ′ ′ ′
(x , y , z ) if 2 π < hr ≤ 4 π
3
3 3
(z ′ , y ′ , x′ ) if 43 π < hr < 2π
(49)
138
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
image. And let’s also assume that there is no blue or green in the image. By setting I = R/3 in
this case, the HSI formula would discount the “energy” coming off the pixels by two-thirds —
which really does not make a whole lot of sense. The fact that HSI mutes the I values
unless it sees strength in all three color channels can be highly problematic for
computer vision algorithms. For extracting the shape information, many computer
139
Texture and Color An RVL Tutorial by Avi Kak
span [0.0, 360.0], S values span [0.0, 1.0]; and both V and L values span [0.0, 1.0]. ]
max(R,G,B)−min(R,G,B)
• The S in HSV is calculated as V
. And the
max(R,G,B)−min(R,G,B)
same in HSL is calculated as 1−abs(2L−1)
.
• Here are the formulas that take you from RGB to HSV. The
input to the transformation shown below consists of a triplet of
values (R, G, B) with the individual color components
normalized to the [0, 1] range.
140
Texture and Color An RVL Tutorial by Avi Kak
Figure 22: The left image in the topmost row is the original image.
The right image in the same row is the depiction of I values in the
HSI model. In the second row, the left image shows the V in the HSV
representation of the colors and the right image the L in the HSL
representation. The image shown in the last row is the L∗ component
in the CIE L*a*b* representation of color. All these images are from
the Wikipedia page on “HSL and HSV”.
141
Texture and Color An RVL Tutorial by Avi Kak
M = max(R, G, B)
m = min(R, G, B)
c = M −m
V = M
G−B
60 c
mod 6 if M = R, c 6= 0
60 B−R + 2 if M = G, c 6= 0
H = c
R−G
60 c + 4 if M = B, c 6= 0
0 if c = 0
c
S = (50)
V
142
Texture and Color An RVL Tutorial by Avi Kak
c = V ×S
m = V −c
H
x = c 1− mod 2 − 1
60
(c + m, x + m, m) if 0 ≤ H ≤ 60
(x + m, c + m, m) if 60 < H ≤ 120
(m, c + m, x + m) if 120 < H ≤ 180
(R, G, B) =
(m, x + m, c + m) if 180 < H ≤ 240
(x + m, m, c + m) if 240 < H ≤ 300
(c + m, m, x + m) if 300 < H ≤ 360
(51)
143
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
yellow, and black as opposed to white. The human brain wants to receive a single signal for
• That is, as shown in Figure 23, the visual cortex in the brain
gets three independent signals from the retina: one regarding
how much of the red-green dimension exists at a point in the
scene; a second regarding how much of the blue-yellow
dimension exists; and a third regarding how much of the
black-white dimension exists at a scene point. The receptor
complexes that perceive these three different dimensions of the
color are referred to as the opponent cells. [The fact that we can see
orange, whose three independent components would be red, yellow, and white, and the fact
that we cannot see reddish-green or yellowish-blue supports the opponent color model. Since
the two color components in a reddish-green mixture are along the same dimension, the
144
Texture and Color An RVL Tutorial by Avi Kak
red-green receptor complex is unable to discern them separately. ] Note the very
important fact that if there was not considerable overlap
between the spectral sensitivities shown in Figure 11 for L, M,
and S, it would not be possible for a receptor complex to see
the colors in the opponent manner.
Figure 23: This figure depicts how the output produced by the L, M,
and S cone cells (whose spectral responses were shown previously in
Figure 11) are combined to produce the three opponent color signals
for the visual cortex in the brain. This figure is from the Wikipedia
page on “Opponent Processes”.
146
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
we mix together the cyan and magenta pigments, we obtain the blue pigment. ]
147
Texture and Color An RVL Tutorial by Avi Kak
Figure 24: The color wheel for pigment hues. The colors that
are diametrically opposites are subtractive vis-a-vis each other. The
opposite color pairs are considered to be complementary. The two
colors that are immediately adjacent to each color are considered
to be analogous. Finally, the three colors at the vertices of an
equilateral inside the wheel are considered to form a triad. From
http: // www. realcolorwheel. com/ newcolorwheel. htm
148
Texture and Color An RVL Tutorial by Avi Kak
149
Texture and Color An RVL Tutorial by Avi Kak
C = 0.2 = 1 − R
M = 0.7 = 1 − G
Y = 0.6 = 1 − B
(52)
• With the CMY values set as shown above, C being 0.2 will
cause the deposited cyan pigment to absorb 0.2 fraction of the
red hue in the supposedly white illumination of the hardcopy
surface, releasing 0.8 of the red hue in the direction of the
observer. Similarly, with M and Y for the generation of the
correct values of G and B for an observer.
C 1 R
M = 1 − G (53)
Y 1 B
150
Texture and Color An RVL Tutorial by Avi Kak
Back to TOC
– The color of the illumination. The color of the light coming off a
surface depends significantly on the color of the illumination.
151
Texture and Color An RVL Tutorial by Avi Kak
• That the color of the light coming off an object surface depends
significantly on the color composition of the illumination is
illustrated by Figure 25. As you can see in the figure, a yellow
ball looks green under mostly blue illumination. This figure also
shows how one can algorithmically correct for illumination
induced distortion of the color of a surface. The result shown in
(c) of the figure was obtained through the use of an
illumination-adaptive color space that was introduced in 2005
by Park and Kak in the report “A New Color Representation
for Non-White Illumination Conditions,” that was cited at
the end of Section 6.1.
Figure 25: (a) A green ball and a yellow ball imaged under ambient
white-light illumination. (b) The yellow ball imaged under blue illu-
mination. It now looks quite a bit like the green ball. (c) The image
of (b) after its processing by the algorithm in the 2005 Park and Kak
report titled “A New Color Representation for Non-White Illumina-
tion Conditions” that was cited at the end of Section 6.1.
The second row demonstrates the extent to which the true color
of the toy was restored in each case by the illumination-adaptive
color representation of Park and Kak mentioned in the previous
bullet.
153
Texture and Color An RVL Tutorial by Avi Kak
Figure 26: The photos in the top row are of the same plastic toy
and were recorded by the same digital camera using four different il-
lumination sources: (1) florescent, (2) blue incandescent, (3) green
incandescent, and (4) tungston. The second row demonstrates the ex-
tent to which the true color of the toy was restored in each case by the
illumination-adaptive color representation method of Park and Kak.
154
Texture and Color An RVL Tutorial by Avi Kak
separately. An incoming light ray is deflected to each of three cells in a grouping and light for each cell passed
through a color-sensitive filter specific to that cell. An alternative consists of using three separate sensor
chips, one for each color component, and a set of prisms that are shaped to deflect a particular color
light are also known as the surface component and the body component, respectively. Light reflected by
homogeneous materials such as metals is dominated by the surface components, whereas the light reflected by
155
Texture and Color An RVL Tutorial by Avi Kak
Figure 28: The yellow and the white objects shown in this pile were
used for demonstrating the dependence of the measured color on the
orientation of a surface.
156
Texture and Color An RVL Tutorial by Avi Kak
157
Texture and Color An RVL Tutorial by Avi Kak
when the surface is at slant of 15◦ , the camera registers the largest specular component. This is explained
approximately by the law of reflection, which says that the angle of reflection subtended by the specular
component of light with respect to the surface normal must equal the angle of incidence of the illumination
light with respect to the normal. More accurately, this phenomenon is explained by the Torrance-Sparrow
]
model of reflection.
• In the results shown in Figure 29, when the slant angle of the
surface becomes large, the reflected light consists mostly of the
body component. But the intensity of this light diminishes
rapidly as the surface slant angle approaches 90◦. This explains
the “darkness” of the result shown for the surface tilt angle of
75◦. This diminishing effect is a result of the fact that if we
assume a perfectly Lambertian surface, the magnitude of the
body component varies as a cosine of the angle of incidence.
158