# log

Natural logarithm of 2-D scattering transform

## Description

slog = log(sf,s) returns the natural logarithm of the scattering coefficients in the cell array s. s is the output of scatteringTransform and is a cell array of structure arrays with an images field.

The precision of slog depends on the precision specified in the network sf.

ulog = log(sf,u) returns the natural logarithm of the scalogram coefficients in the cell array u. u is the output of scatteringTransform and is a cell array of structure arrays with a coefficients field.

The precision of ulog depends on the precision specified in the network sf.

example

xlog = log(sf,x) returns the natural logarithm of the 3-D matrix or 4-D tensor x. x is the output of featureMatrix.

The precision of xlog depends on the precision specified in the network sf.

## Examples

collapse all

This example shows how to obtain the natural logarithm of scattering coefficients.

Load the xbox image. Create an image scattering network that can be applied to the image.

sf = waveletScattering2('ImageSize',size(xbox),...
'InvarianceScale',min(size(xbox)))
sf =
waveletScattering2 with properties:

ImageSize: [128 128]
InvarianceScale: 128
NumRotations: [6 6]
QualityFactors: [1 1]
Precision: "single"
OversamplingFactor: 0
OptimizePath: 1

Obtain the scattering transform of the image and then the natural logarithm of the scattering coefficients. Display the number of rows in the table containing the first-order scattering coefficients.

S = scatteringTransform(sf,xbox);
Slog = log(sf,S);
coefOrder = 1;
display(['Number of rows: ',num2str(size(S{coefOrder+1},1))])
Number of rows: 30

Choose a row from the first-order scattering coefficients table. Take the natural logarithm of the absolute value of the scattering coefficients in that row. Compare with the corresponding row in Slog and confirm they are equal.

row = 11;
tmp1 = Slog{coefOrder+1}.images{row};
tmp2 = log(abs(S{coefOrder+1}.images{row}));
disp(['Max Difference of Scattering Coefficients: '...
num2str(max(abs(tmp1(:)-tmp2(:))))])
Max Difference of Scattering Coefficients: 0

## Input Arguments

collapse all

Wavelet image scattering network, specified as a waveletScattering2 object.

Scattering coefficients, specified as a cell array of structure arrays. s is the output of scatteringTransform for the image scattering network sf.

Scalogram coefficients, specified as a cell array of structure arrays. u is the output of scatteringTransform for the image scattering network sf.

Scattering feature matrix, specified as a real-valued 3-D matrix or a real-valued 4-D tensor. x is the output of featureMatrix for the image scattering network sf.

## Output Arguments

collapse all

Natural logarithm of scattering coefficients, returned as a cell array. The dimensions of slog are equal to the dimensions of s.

The precision of slog depends on the precision specified in the network sf.

Natural logarithm of scalogram coefficients, returned as a cell array. The dimensions of ulog are equal to the dimensions of u.

The precision of ulog depends on the precision specified in the network sf.

Natural logarithm of scattering feature matrix, returned as a real-valued matrix or tensor. The dimensions of xlog are equal to the dimensions of x.

The precision of xlog depends on the precision specified in the network sf.

## Algorithms

log returns the natural logarithm of the absolute value of the input argument.

## Version History

Introduced in R2019a