How can I use the iswt2 from the wavelet toolbox with a different dwtmode?
6 ビュー (過去 30 日間)
古いコメントを表示
The iswt2 is the inverse function of the swt2. In the swt2 the dwtmode is set to:
modeDWT = 'per';
I want to customize the swt2 to extend images in a symmetric manner, so changed the code to:
modeDWT = 'sym';
Unfortunately, I have not found an explicit parameter to consider the dwtmode in the iswt2. Is there a way to modify the iswt2 in this respect?
0 件のコメント
回答 (1 件)
Umeshraja
2024 年 8 月 8 日
編集済み: Umeshraja
2024 年 9 月 21 日
I understand you are trying to use Symmetrization mode for 'swt2' and 'iswt2' function. According to MATLAB R2021a documentation, 'swt2' uses periodic extension:
However, you can symmetrically extend the images manually before performing transform using ‘swt2’ function and then remove the redundant coefficients after taking inverse wavelet transform. Assuming the application of performing the transform and reconstruction on a 2-D image, here's an example:
% Load example image from MATLAB documentation
load woman; % This loads the image 'X' into the workspace
portion=0.25; %Portion of image that can be extended symmetrically
% Symmetrically extend the image manually
X_extended = padarray(X, size(X)*portion, 'symmetric');
% Display the original and extended images
figure;
subplot(1, 2, 1);
imshow(X, []);
title('Original Image');
subplot(1, 2, 2);
imshow(X_extended, []);
title('Symmetrically Extended Image');
% Perform stationary wavelet transform on the extended image
wavelet = 'db1';
N = 2; % Level of decomposition
[A, H, V, D] = swt2(X_extended, N, wavelet);
% Perform inverse stationary wavelet transform
X_reconstructed_extended = iswt2(A, H, V, D, wavelet);
% Remove the redundant coefficients to get the original size
X_reconstructed = X_reconstructed_extended(size(X,1)*portion+1:end-size(X,1)*portion,...
size(X,2)*portion+1:end-size(X,2)*portion);
% Display the reconstructed image
figure;
imshow(X_reconstructed, []);
title('Reconstructed Image after Removing Redundant Coefficients', 'FontSize', 8);
% Sanity check if the reconstructed image is close to the original image
tolerance = 1e-12; % Define a small tolerance
mse = mean((X(:) - X_reconstructed(:)).^2);
if mse<tolerance
disp("Input image and Reconstructed image are same.")
else
disp("Reconstructed image differ.")
end
For more information regarding ‘padarray’ function, Please refer to the following MATLAB R2021a documentation
I hope this helps!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Signal Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!