Texture Histograms

A texture histogram describes an image region by how often local features take each value, pooled over all positions. Texture modeling has two design questions. The first is which features to measure: pixels, pixel patches, outputs of V1-like filters (9.2. Filter Banks), clusters of patches or filter outputs (9.4. Bag of Visual Words), or CNN features. The second is how to aggregate them, usually with some kind of histogram, built explicitly or implicitly.

A pixel histogram gives the fraction of the pixel positions of image that have value . It is a first-order statistic (9.1. Texture) and ignores where values sit, so an image and any shuffle of its pixels have equal histograms. Filters fix this by comparing neighbors before pooling. For filters with response maps (cross-correlation), the mean absolute response descriptor is

where is the number of values in . The absolute value keeps edges of both polarities, which a signed mean would cancel. With the finite differences and as the only filters, the descriptor is . A richer descriptor keeps a full histogram of for each filter.

A joint histogram bins all features together. It needs lots of data, and its bins must be coarse to avoid empty bins. Marginal histograms bin each feature separately. They describe the data fully only when the features are independent, but they hold more data per bin. With features and bins per feature, the joint histogram has bins and the marginals have bins in total. Spatial structure is added by computing a separate histogram for each cell of a grid and concatenating them. The SIFT descriptor is such a histogram of gradient orientations, with a grid of cells and 8 orientation bins, dimensions (4.3.2. SIFT). Binning gives invariance to small offsets of the patch. Descriptors built from oriented filters change when the texture rotates.

Equal Descriptors Do Not Mean Equal Textures

Every descriptor here maps many images to the same vector. A binary pattern and its inverse, with black and white swapped, always share . Inversion flips the sign of every difference, and the absolute value removes the sign. A pattern and its left-right mirror image also share . A descriptor separates two textures only if they differ in what the descriptor measures.

Intuition

A texture is the same stuff everywhere, so its description should not depend on where things are. A histogram pools values over all positions and discards position by design. The choice that matters is what to pool. Pixel values are a poor choice. A photo of a person and the same pixels in random order have equal pixel histograms, although the second looks like noise. Filter responses are a better choice. Each response already compares a pixel with its neighbors, so pooling responses keeps local structure, such as how much vertical edge there is, while discarding layout.

The figure shows the pipeline. Filter the image with every filter in the bank. Then either take absolute values and average each response map, or build a histogram of each response map. Two textures are compared through the resulting vectors. Bark with vertical ridges gives a large mean response for the filter elongated vertically. Bark with ridges slanted up to the right gives a large response for the filter slanted the same way. A blotchy rock surface responds mostly to the round blob filter.

\usepackage{tikz}
\begin{document}
\definecolor{hot}{HTML}{D9483B}
\definecolor{cold}{HTML}{2F80ED}
\begin{tikzpicture}[>=latex,box/.style={draw,rounded corners=2pt,minimum height=0.9cm,align=center,inner sep=4pt}]
\node[box] (I) at (0,0) {image $I$};
\node[box] (H) at (3.2,0) {filter bank\\$H_1, \dots, H_K$};
\node[box] (R) at (6.6,0) {responses\\$R_k = H_k \otimes I$};
\node[box,draw=hot,text=hot] (A) at (6.6,-1.9) {$|R_k|$};
\node[box,draw=hot,text=hot] (M) at (6.6,-3.6) {$m_k = \frac{1}{N_k}\sum_{\mathbf{p}} |R_k(\mathbf{p})|$};
\node[box,draw=cold,text=cold] (Hk) at (10.3,-1.9) {histogram $h_k$\\of the values of $R_k$};
\draw[->,thick] (I) -- (H);
\draw[->,thick] (H) -- (R);
\draw[->,thick,hot] (R) -- (A);
\draw[->,thick,hot] (A) -- node[right] {\small mean} (M);
\draw[->,thick,cold] (R.east) -| (Hk.north);
\node[hot,align=center] at (2.4,-3.6) {descriptor $(m_1, \dots, m_K)$:\\one number per filter};
\node[cold,align=center] at (10.7,-3.2) {descriptor $(h_1, \dots, h_K)$:\\one histogram per filter};
\end{tikzpicture}
\end{document}

Properties

(Why Absolute Values) A signed mean lets opposite edge polarities cancel, so a texture full of edges can have a signed mean near zero.

Across a stripe pattern, every dark-to-light step is followed by a light-to-dark step, with differences and . For tile in the Medium example, the signed means of and are both , while the mean absolute values are both . The absolute value has a second benefit. Every Gaussian-derivative filter is odd or even, so flipping the kernel changes it at most by a sign. Cross-correlation and convolution then give the same absolute responses. The mean absolute response is the norm of the response map divided by (3.5b p-Norm). The mean squared response, an energy measure, is a common alternative.

(Counting Bins) Joint histograms run out of data almost at once, and marginal histograms stay well filled but miss structure in how features occur together.

For the 48-filter LM bank with 10 bins per filter, the joint histogram has bins, while the 48 marginals have bins in total. A image supplies response vectors, so almost every joint bin stays empty. Marginals fill their bins well, but two textures can share every marginal and still differ in how features appear together (Hard example). In the figure, the points lie along a diagonal. The joint grid shows this dependence and leaves many cells empty. Each marginal fills all its strips and loses the diagonal. Synthesis methods that also match joint statistics of pairs of filters improve on methods that match marginals only (8.1. Parametric Texture Synthesis).

\usepackage{tikz}
\begin{document}
\definecolor{hot}{HTML}{D9483B}
\definecolor{cold}{HTML}{2F80ED}
\begin{tikzpicture}[x=0.75cm,y=0.75cm,>=latex]
\def\pts{(0.5,0.6),(0.8,1.1),(1.1,0.7),(1.3,1.4),(0.6,1.6),(1.6,1.2),(1.9,1.8),(2.2,2.3),(2.6,2.1),(2.4,2.8),(2.9,2.6),(3.2,3.1),(3.5,3.4),(3.1,3.6),(1.2,0.3)}
% joint
\draw[hot,step=0.75cm] (0,0) grid (4,4);
\foreach \p in \pts \fill \p circle (0.07);
\draw[->] (0,0) -- (4.5,0) node[below] {\small feature 1};
\draw[->] (0,0) -- (0,4.5) node[left] {\small feature 2};
\node[align=center] at (2,-1.1) {joint: $4^2 = 16$ cells,\\$10$ of them empty};
% marginal of feature 1
\begin{scope}[xshift=4.6cm]
\foreach \x in {0,1,2,3,4} \draw[cold] (\x,0) -- (\x,4);
\foreach \p in \pts \fill \p circle (0.07);
\draw[->] (0,0) -- (4.5,0) node[below] {\small feature 1};
\draw[->] (0,0) -- (0,4.5);
\node[align=center] at (2,-1.1) {marginal of feature 1:\\$4$ strips, none empty};
\end{scope}
% marginal of feature 2
\begin{scope}[xshift=9.2cm]
\foreach \y in {0,1,2,3,4} \draw[cold] (0,\y) -- (4,\y);
\foreach \p in \pts \fill \p circle (0.07);
\draw[->] (0,0) -- (4.5,0);
\draw[->] (0,0) -- (0,4.5) node[left] {\small feature 2};
\node[align=center] at (2,-1.1) {marginal of feature 2:\\$4$ strips, none empty};
\end{scope}
\end{tikzpicture}
\end{document}

(Adding Spatial Structure) One histogram per grid cell keeps coarse layout while staying tolerant to small shifts.

A single histogram over a whole photo cannot separate sky above grass from grass above sky. Splitting the image into a grid and concatenating one histogram per cell restores coarse layout. The cell size sets a trade-off. Small cells keep more layout, but content that shifts by a cell changes the descriptor. Large cells tolerate shifts but keep little layout. A feature that moves within its cell leaves the descriptor unchanged, which is the invariance to small offsets that binning provides.

Each pixel votes for the bin of its gradient orientation, with a weight equal to its gradient magnitude (2.1.2. Edge Detection). SIFT (Lowe, 1999) uses a grid of cells around a keypoint, with 8 orientation bins per cell. HOG (Dalal & Triggs, CVPR 2005) applies the same idea on a dense grid of cells over a whole detection window. The GIST descriptor (Oliva & Torralba, 2001) pools oriented filter energy over a coarse grid of a whole scene. Shape context (Belongie et al., 2001) bins edge points on a log-polar grid around a reference point. All of them give up exact positions in exchange for tolerance to small shifts. SIFT descriptors perform very well in image matching comparisons (Mikolajczyk & Schmid, 2003).

(Rotation Sensitivity) Rotating a texture moves its response from one orientation channel to another, and pooling over orientations removes this change along with the direction information.

With 6 orientations spaced apart, a rotation moves the response of the channel at angle to the channel at , three channels over. Summing, or taking the maximum, over orientations at each scale gives a descriptor that rotation barely changes. That descriptor can no longer tell vertical stripes from horizontal stripes. SIFT keeps direction information and still handles rotation, because it measures orientations relative to a dominant orientation found at each keypoint (4.3.2. SIFT).

Examples

(Medium) Three Tiles With Equal Histograms

Three binary tiles have black and white . Tile has thin horizontal stripes. Tile has diagonal stripes two pixels wide, running up to the right. Tile is rotated by counterclockwise, so its stripes run down to the right. As matrices, the three tiles are

Rows and columns are numbered from at the top left. Differences are taken without wrapping or padding. Besides and , consider the diagonal differences and , which have entries each.

(Hard) Same Marginals, Different Joint Histogram

Treat tiles and from the Medium example as one period of endlessly repeating textures. Differences then wrap around the tile edges, and each difference map has entries. At each pixel, record the pair .

See Also