how to convert signal into 2D image gray scale
Show older comments
hello ,how to convert signal into 2D image gray scale by CWT
Answers (1)
Ameer Hamza
on 29 Oct 2020
0 votes
The documentation shows that if you call cwt(): https://www.mathworks.com/help/wavelet/ref/cwt.html with an output argument, then it will return a 2D matrix. You can take the absolute value of the matrix and display it as a grayscale image.
15 Comments
ahmed Altameemi
on 29 Oct 2020
Ameer Hamza
on 29 Oct 2020
Edited: Ameer Hamza
on 29 Oct 2020
The output of cwt should already by 2D matrix. You don't need to call mat2gray. You might need to rescale it to display it properly
M = cwt(input_signal);
M = abs(M);
M = rescale(M, 0, 1);
imshow(M)
ahmed Altameemi
on 29 Oct 2020
Ameer Hamza
on 30 Oct 2020
I don't have the toolbox so cannot run the code, but can you show the output of
M = cwt(input_signal);
M = abs(M);
size(M)
If it is a 2D matrix, then imwhow will automatically show a grayscale image.
Walter Roberson
on 30 Oct 2020
mat2gray() is an older routine that is suitable for rescaling data to the range [0 1]
However, you would not typically pass a second argument to mat2gray, and when you do pass a second argument it must be a vector of two values that is the range to scale to.
imshow() of a 2D array will not be color, but you might want to
imshow(M, [])
ahmed Altameemi
on 30 Oct 2020
ahmed Altameemi
on 30 Oct 2020
Edited: Walter Roberson
on 30 Oct 2020
Walter Roberson
on 30 Oct 2020
cwt() only accepts vectors, not images. For grayscale images use cwtft2()
ahmed Altameemi
on 30 Oct 2020
Edited: Walter Roberson
on 30 Oct 2020
Walter Roberson
on 30 Oct 2020
If the code is designed for color images, then take your grayscale images and repmat(GRAYSCALE,[1 1 3]) to get a color image and process it through the code.
However, the code you posted is for processing 1D EEG signals, not for images of any kind.
Mathworks does not provide any equivalent of cwtfilterbank for 2D.
ahmed Altameemi
on 30 Oct 2020
ahmed Altameemi
on 6 Nov 2020
Ameer Hamza
on 6 Nov 2020
You can use rgb2gray() to convert 3 channels to 1.
ahmed Altameemi
on 6 Nov 2020
ahmed Altameemi
on 6 Nov 2020
Categories
Find more on Continuous Wavelet Transforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!