Just only cwtft2 is used for 2D continuous wavelet transform (2D CWT)?

9 次查看(过去 30 天)
Hello everyone,
I want to detect a singularity of my data (x, y, z matrices) by using 2-dimensional continuous wavelet transform (2D CWT). My code is no error but it cannot perform the sigularity.
My questions are
  1. What command can be used for 2D CWT? Just only cwtft2? From searching, the cwtft2 is 2D CWT from Fourier transform.
  2. What wavelet is supported for cwtft2? As I know there are few types availavle such as mexh, gaus. When I read papers, researchers who study 2D CWT can use a variety of wavelet types.
  3. This is my code, but i cannot detect singularity. I am not sure the problem is from my code, wavelet type, or scale. Can you reccomend?
wavelet = 'gaus';
scales = 1:32;
cwt_result = cwtft2(Z, 'wavelet', wavelet, 'scales', scales);
coef= cwt_result.cfs;
specific_scale = 10;
Z_wavelet = abs((coef(:,:,specific_scale)));
figure;
surf(X, Y, Z_wavelet);
Thank you in advance

采纳的回答

Shashi Kiran
Shashi Kiran 2024-8-20
I understood that you want to detect singularities of your data using 2D CWT. Below are my observations on your queries.
  1. cwtft2 is used for calculating the 2D continuous wavelet transform.
  2. There are many wavelets supported by cwtft2 based on the requirement. You can find the list of those here https://www.mathworks.com/help/wavelet/ref/cwtftinfo2.html#bt1o3sf-wname
  3. Based on your data, you can pick one of the listed wavelets in the documentation. Here, I am using mexh as it is sensitive to changes in the signal, such as edges or singularities.
%% Data Generation(Replace your data)
[X, Y] = meshgrid(1:100, 1:100);
Z = zeros(size(X));
Z(40:60, 40:60) = 1; % Introduce singularities
known_singularities = [40, 60, 40, 60]; % [x_start, x_end, y_start, y_end]
%% Set parameters for 2D CWT
wavelet = 'mexh'; % Gaussian wavelet
scales = 1:32;
cwt_result = cwtft2(Z, 'wavelet', wavelet, 'scales', scales);
coef = cwt_result.cfs;
specific_scale = 10;
Z_wavelet = abs(coef(:, :, specific_scale));
%% Singularity Detection
threshold = 0.5 * max(Z_wavelet(:)); % Example threshold
detected_singularities = Z_wavelet > threshold;
% Visualize the wavelet coefficients and detected singularities
figure;
surf(X, Y, Z_wavelet);
title(['2D CWT Coefficients at Scale ', num2str(specific_scale)]);
xlabel('X');
ylabel('Y');
zlabel('Wavelet Coefficient Magnitude');
hold on;
% Highlight detected singularities
[detected_x, detected_y] = find(detected_singularities);
scatter3(detected_x, detected_y, Z_wavelet(detected_singularities), 'r', 'filled');
%% Comapring Detected and known singularities
matches = 0;
x_range = known_singularities(1):known_singularities(2);
y_range = known_singularities(3):known_singularities(4);
for i = 1:length(detected_x)
if ismember(detected_x(i), x_range) && ismember(detected_y(i), y_range)
matches = matches + 1;
end
end
disp(['Number of matches: ', num2str(matches)]);
Number of matches: 293
disp(['Total detected singularities: ', num2str(length(detected_x))]);
Total detected singularities: 293
Refer the below documentation for further information.
  1. https://www.mathworks.com/help/wavelet/ref/cwtftinfo2.html#bt1o3sf-wname
  2. https://www.mathworks.com/help/wavelet/ref/cwtft2.html?s_tid=doc_ta#bt1oh8w-wavelet

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Continuous Wavelet Transforms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by