Why am i getting error in wthresh? please help

% Load the noisy image
noisyImage = imread('flower.jpg');
% Convert the noisy image to grayscale
grayImage = rgb2gray(noisyImage);
% Convert the grayscale image to double precision
grayImage = im2double(grayImage);
% Display the original noisy image
figure;
imshow(noisyImage);
title('Noisy Image');
% Perform Coiflet wavelet denoising
% Set the denoising parameters
waveletType = 'coif2'; % Coiflet wavelet type
level = 5; % Wavelet decomposition level
threshold = 'soft'; % Thresholding method
thrSettings = 3; % Thresholding settings
% Perform wavelet decomposition
[C, S] = wavedec2(grayImage, level, waveletType);
% Compute the noise estimate using universal thresholding
sigma = median(abs(C)) / 0.6745;
% Apply the thresholding
C = wthresh(C, threshold, sigma * thrSettings);
% Perform inverse wavelet transform to obtain the denoised image
denoisedImage = waverec2(C, S, waveletType);
% Display the denoised image
figure;
imshow(denoisedImage);
title('Denoised Image');

2 Comments

x is empty or length 1.
Thank you Sir!! code in the picture was different ...please do recheck.

Sign in to comment.

Answers (1)

I believe the issue is with your 2nd input. Valid inputs are 's' and 'h'. You are using 'soft'.
y = linspace(-1,1,100);
thr = 0.4;
% good
ythard = wthresh(y,'s',thr);
% error
ythard = wthresh(y,'soft',thr);
Error using wthresh
Invalid argument value.

Categories

Tags

Asked:

on 13 Apr 2023

Commented:

on 13 Apr 2023

Community Treasure Hunt

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

Start Hunting!