- After decompression, you have the variable CRestaurados, which represents the restored signal coefficients.
- To perform sparse decoding, you need to reconstruct the signal using the dictionary that was used in the sparse encoding step.
- Initialize an empty array to store the reconstructed signal.
- Iterate through the restored signal coefficients:
- a. For each coefficient, multiply it by the corresponding column of the dictionary matrix dictionaryFull. This will give you a vector representing a dictionary entry.
How to implement sparse decoding after signal decompression
5 次查看(过去 30 天)
显示 更早的评论
Hi all,
I am trying to do the compression and subsequent decompression of polysomnographic signals based on the Lempel-Ziv-Welch (LZW) algorithm. The pre-call step of the LZW algorithm is sparse encoding which I have implemented as follows and it seems to work. However, I don't know how to implement the sparse decoding after the subsequent decompression to compare it with the original signal.
%----------------------------COMPRESS--------------------------------
[...]
%Construct a dictionary consisting of the Daubechies' extremal-phase wavelet least-asymmetric
%wavelet with 4 vanishing moments at levels 1 and 4, the discrete cosine transform-II basis,
%and the sine basis.
dictionary= {{'db4',2},'dct','sin',{'sym4',1},{'sym4',4}};
[mpdict,nbvect]= wmpdictionary(length(originalSignal),'lstcpt',dictionary);
%SPARSE ENCODING
dictionarySparse= mpdict; %1) The dictionary created that contains the entry is saved
dictionaryFull= full(dictionarySparse); %2) The full dictionary is obtained. The sparse
% dictionary is changed to the full one
alpha= randi ([0,10000],1152,1);%3) A random vector of the same size as the
% dictionary matrix necessary to make the
% dictionary more manageable is created
dicVector = dictionaryFull*alpha; %4) The dictionary is multiplied by the previous vector and a
% vector of the size of the dictionary (256 values) is obtained
[...]
%----------------------------DECOMPRESS--------------------------------
%Call LZW algorithm function to decompress.
[lzwOutputd, lzwTabled] = lzw2norm(lzwOutput);
lzwOutputdTime=0:1:length(lzwOutputd)-1;
%To RESTORE COEFFICIENTS a change from uint8 to double to return to
%having the same data type as when beginning is made. They are then
%normalized by dividing by their norm.
S2 = im2double (lzwOutputd); %S2 = cast (lzwOutputd,'double');
CRestaurados = S2/norm(S2);
CR_final = CRestaurados';
%SPARSE DECODING: Obtain the dictionary containing the restored signal:
%an array of 256x1152 values. Do the inverse step to sparse encoding.
%--?--
%Reconstructed signal
%The 256 values of the signal obtained in the previous step and the time
%vector are stored within the same vector and file
reconstructedEOG = originalSignal_salida;
tempReconsEOG = lzwOutputdTime';
reconstructedEOG = [tempReconsEOG reconstructedEOG];
This is the flowchart that I follow in my implementation according to the literature
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1235272/image.png)
If anyone can guide me I would be very grateful.
Kind regards,
0 个评论
采纳的回答
Piyush
2023-10-12
I can understand that you are trying to implement compression and decompression of polysomnographic
signals based on the Lempel-Ziv-Welch (LZW) algorithm. While attempting to write the code for the algorithm you are unable to implement the sparse decoding, which is the pre-call step of the LZW algorithm.
Sparse decoding is a process used in certain compression or signal processing techniques to recover or reconstruct a sparse representation of the original signal or data. Sparse decoding aims to reconstruct the original signal from a compressed or sparse representation, typically achieved by using a dictionary or basis functions. To implement the sparse decoding step of the LZW algorithm after decompression, you can follow these steps:
5. b. Append the vector to the reconstructed signal array.
6. The reconstructed signal array now contains the sparse decoding of the compressed signal.
The below attached code snippet demonstrates the implementation of sparse coding:
reconstructedSignal = []; % Initialize the reconstructed signal array
for i = 1:size(CR_final, 1)
coefficient = CR_final(i); % Get the current coefficient
% Multiply the coefficient with the corresponding column of the dictionary
dictionaryEntry = dictionaryFull(:, i) * coefficient;
% Append the dictionary entry to the reconstructed signal
reconstructedSignal = [reconstructedSignal; dictionaryEntry];
end
% The reconstructed signal is now available in the 'reconstructedSignal' array
After implementing the sparse decoding step, you can compare the reconstructedSignal with the original signal to assess the accuracy of the decompression. Please note that the code provided assumes that the dimensions of CR_final and dictionaryFull are compatible.
Hope this helps!
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Read, Write, and Modify Image 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!