%% Compare Normalized and Original Data
% Values at the edges of an array are normalized using contributions from fewer channels, depending on the size of the channel window.
% Create the input data as an array of ones with a height and width of two and three channels.

height = 2;
width = 2;
channels = 3;

X = ones(height,width,channels);
dlX = dlarray(X);

% Normalize the data using a channel-window size of 3, an \alpha of 1, a \beta of 1, and a K of 1e-5. Specify a data format of 'SSC'.

dlY = crosschannelnorm(dlX,3,'Alpha',1,'Beta',1,'K',1e-5,'DataFormat','SSC');

% Compare the values in the original and the normalized data by reshaping the three-channel arrays into 2-D matrices.

dlX = reshape(dlX,2,6)
dlY = reshape(dlY,2,6)

% For the first and last channels, the sum of squares is calculated using only two values. For the middle channel, the sum of squares contains the values of all three channels.
% Copyright 2019 The MathWorks, Inc.