SSIM calculation of 2 signals

15 views (last 30 days)
Jessica
Jessica on 18 Feb 2015
Answered: Prasanna on 22 Aug 2024
How can I calculate the SSIM (Structural similarity index) of 2 1D signals ?

Answers (1)

Prasanna
Prasanna on 22 Aug 2024
Hi Jessica,
The Structural Similarity Index (SSIM) is a method originally designed to measure the similarity between two images. However, it can be adapted to compare 1D signals as well. In MATLAB, you can use the ssim function from the Image Processing Toolbox, which is primarily intended for images, but with a little adjustment, by making the signals of equal size and reshaping the signals to a 2D array with one row, it can be applied to 1D signals. A sample code for the same looks as the following:
% Example 1D signals
signal1 = randn(1, 1000); % Replace with your first signal
signal2 = randn(1, 1000); % Replace with your second signal
% Ensure both the signals have same size
% Reshape the signals to 2D arrays with one row
signal1_2d = reshape(signal1, 1, []);
signal2_2d = reshape(signal2, 1, []);
% Calculate SSIM
ssimValue = ssim(signal1_2d, signal2_2d);
However, SSIM is sensitive to changes in signal amplitude, so the interpretations can be varied. If you want to measure signal similarities without using SSIM, you can refer to the following documentation: https://www.mathworks.com/help/signal/ug/measuring-signal-similarities.html.
For more information on the ‘ssim’ function, refer to the following documentation: https://www.mathworks.com/help/images/ref/ssim.html
Hope this helps!

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!