# The features Package¶

Package to calculate feature vectors for steganalysis. The functions are designed to be simpler and more straight forward than the older analysis package, without the complex hierarchical data structure.

Future completion of the SQL based framework for feature storage will depend on this package, and not on the analysis package.

Module: pysteg.features \$Date\$ \$Revision\$ © 2012: Hans Georg Schaathun

## Cover selection heuristics¶

### The correlation module¶

Calculating the correlation coefficient of adjacent pixels as used in cover selection.

Module: pysteg.features.correlation \$Date\$ \$Revision\$ 2012: Hans Georg Schaathun
pysteg.features.correlation.corrfeature(I)[source]

Calculate the correlation coefficients corr-hor, corr-ver.

### The texture module¶

Functions to estimate the beta coefficient to quantify the level of texture in an image.

Module: pysteg.features.texture \$Date\$ \$Revision\$ © 2012 Hans Georg Schaathun
pysteg.features.texture.ggdBeta(im=None, wavelet='haar', verbosity=4)[source]

Estimate the beta coefficient of the Generalised Gaussian Distribution modelling the wavelet coefficients of an image im.

## Wavelet domain features¶

### The farid module¶

The original feature vector of Lyu and Farid (2002). 36 simple statistics + 36 statistics of prediction errors. Each 36-set has 12 features per wavelet decomposition level (levels 1,2,3). Each 12-set has 4 features per direction (horizontal, vertical, diagonal). Each 4-set is the mean, var, skew(ness), and kurtosis.

Module: pysteg.features.farid \$Date\$ \$Revision\$ © 2012: Hans Georg Schaathun
pysteg.features.farid.farid36(I, name='qmf9', *a, **kw)[source]

Calculate the 36 Farid features from the image I, excluding the prediction image features. Optionally a wavelet name can be given as well.

pysteg.features.farid.farid36pred(I, name='qmf9', *a, **kw)[source]

Calculate the 36 Farid features from the prediction image of I. Optionally a wavelet name can be given as well.

pysteg.features.farid.fxbase(H, *a, **kw)[source]
pysteg.features.farid.pred(H, *a, **kw)[source]

Given a tuple H containing a wavelet decomposition of an image, calculate the Lyu-Farid feature based on the linear predictor.

pysteg.features.farid.pred1(hv, verbosity=0, *a, **kw)[source]

Compute the linear prediction error statistics from one level of the wavelet decomposition.

pysteg.features.farid.predictionFeatures(L, verbosity=0)[source]

Compute the linear predictions and its error statistics from a series of matrices. (Auxiliary function for pred1().

pysteg.features.farid.reshape(A)[source]
pysteg.features.farid.stats(E)[source]

Given an array E, calculate mean, variance, skewness and kurtosis. (Auxiliary function for the Lyu-Farid feature vector.)

### The wam module¶

The WAM features. Only WAM based on NxN LAW-ML is provided. An implementation of the original WAM features of Fridrich et al. can be found in pysteg.analysis.wfeatures.

This module follows the sample code provided in my book.

Module: pysteg.features.wam \$Date\$ \$Revision\$ 2012: Hans Georg Schaathun
pysteg.features.wam.lawmlN(X, N=3, sig0=0.5)[source]

Return the denoised image using NxN LAW-ML.

pysteg.features.wam.subm(X, N, i, j)[source]

Return an NxN submatrix of X, centered at element (i,j).

pysteg.features.wam.wam9(C, N=3, nmom=9)[source]

Calculate 9 WAM features from the wavelet component C.

pysteg.features.wam.wamNxN(I, N=3, nmom=9)[source]

Calculate the WAM(N)-27 from the pixmap array I.

pysteg.features.wam.wamNxNnames(N=3, nmom=9)[source]

## Spatial domain features¶

### The bitplane module¶

pysteg.features.bitplane.BPM(C, shape=(2, 2), depth=2)[source]

Features based on the histogram of bit patterns. Note that absolute frequencies are given; for relative frequencies, use nBPM().

pysteg.features.bitplane.nBPM(*a, **kw)[source]

The BPM features normalised to relative frequencies.

pysteg.features.bitplane.BPH(C)[source]

Entropy of normalised BPM features.

### The homgen module¶

Functions to calculate generic higher-order features, following the lines of HOLMES. Both SPAM and HOLMES are supported.

Module: pysteg.features.homgen \$Date\$ \$Revision\$ © 2012 Hans Georg Schaathun

It appears to be safe for various input constituent types, because the scipy.signal module converts to 64-bit integers in calculation. Thus 8-, 16-, and 32-bit images should be safe, whether signed or unsigned.

pysteg.features.homgen.residual(M, dir=None, order=1, s=None, q=1, T=None)

Calculate the residual matrix (aka. difference matrix) of an image or matrix M. Higher-order differences are supported following Fridrich et al, with a span s of order+1. Optionally the matrix can be quantised by an integer factor q and capped by T. If the filter defining the difference is one-dimensional, dir may be specified to apply it horizontally (h), vertically (v), diagonally (d), or along the minor diagonal (m).

pysteg.features.homgen.residualMM(im, f, dir='hv', q=1, s=1, m=3, T=4)

Get the MINMAX residual matrix. The parameter f should be either np.min or np.max, specifying whether to take the minimum or the maximum. The MINMAX residual is defined as the element-wise minimum or maximum of R^h and R^v. Optionally the dir parameter can be set. To get the EDGE residuals of HOLMES use dir=”edge”. If dir=”diag” the min/max is taken of R^d and R^m.

pysteg.features.homgen.CM(C, dir, T, order=2)[source]

Return the co-occurrence matrix of C of the given order along direction dir. Relative frequencies are used, so the result is a floating point array.

pysteg.features.homgen.HolmesMAX(im, *a, **kw)
pysteg.features.homgen.HolmesMIN(im, *a, **kw)
pysteg.features.homgen.HolmesHV(im, *a, **kw)
pysteg.features.homgen.HolmesD(im, *a, **kw)
pysteg.features.homgen.HolmesSQmax(im, *a, **kw)
pysteg.features.homgen.HolmesSQmin(im, *a, **kw)
pysteg.features.homgen.HolmesKB(im, q=1, m=3, T=4)

Calculate the Holmes features for the KB filter using quantisation factor q. This gives 729 features per value of q. The Holmes features use q=1,2,4.

pysteg.features.homgen.HolmesCALImax(im, *a, **kw)
pysteg.features.homgen.HolmesCALImin(im, *a, **kw)
pysteg.features.homgen.HolmesEDGEmin(im, s, q, m, T)

The EDGEMIN features of HOLMES.

pysteg.features.homgen.HolmesEDGEmax(im, s, q, m, T)

The EDGEMAX features of HOLMES.

pysteg.features.homgen.HolmesHVsum(im, m, T)
pysteg.features.homgen.HolmesDsum(im, m, T)
pysteg.features.homgen.HolmesMINsum(im, m, T)
pysteg.features.homgen.HolmesMAXsum(im, m, T)
pysteg.features.homgen.HOM(C, dir, difforder=1, order=2, capvalue=None, limit=None)[source]

Calculate features based on a generalised higher-order model. Either capvalue or limit has to be specified. To cap the underlying difference matrix, use capvalue. To use the unmodified difference matrix, use limit to select the central portion of the co-occurrence matrix.

pysteg.features.homgen.SPAM(C, dir, order)[source]

The SPAM features of Fridrich et al. Only one direction (hv or diag) and one order (1 or 2) is calculated at a time.

### The bsm module¶

Calculate the BSM features of Avcibas et al (2005).

The paper present the features in 3 groups (i)-(iii), where the features within each group are calculated in very similar ways, based on the same basic statistics. These groups are recognised as subvectors in the bsmVector object.

Module: pysteg.features.bsm \$Date\$ \$Revision\$ © 2012: Hans Georg Schaathun
pysteg.features.bsm.bsmraw(I)[source]

Return the raw BSM features underlying groups (i) and (ii).

pysteg.features.bsm.bsm12(I)[source]

Return groups (i) and (ii) of the BSM features.

pysteg.features.bsm.bsm3(I)[source]

Return group (iii) of the BSM features.

### The ale module¶

Module: pysteg.features.ale \$Date\$ \$Revision\$ © 2012: Hans Georg Schaathun
pysteg.features.ale.ale1d(I)[source]

Return the first-order ALE features f_1 and f_2.

pysteg.features.ale.ale2d(I, dir=None)[source]

Return the second-order ALE features for the given direction dir.

### The ac module¶

Calculate the Autocorrelation features of Yadollahpour and Naimi (2009).

Module: pysteg.features.ac \$Date\$ \$Revision\$ © 2012: Hans Georg Schaathun
pysteg.features.ac.ac(I=None, idxs=[(0, 1), (0, 2), (0, 3), (0, 4), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (3, 0), (3, 1), (4, 0)])[source]

Calculate the AC features of the image I. If I is None, the names of the features are returned. The second argument can be used to specify the shifts used for the autocorrelation.