8 views (last 30 days)

function resim = Inverse_Filtering(ifbl, LEN, THETA, handle) %Function to restore the image using Inverse Filter %Inputs: ifbl, LEN, THETA. %Returns: resim. % %ifbl: It is the input image. %THETA: It is the blur angle. The angle at which the image is blurred. %LEN: It is the blur length. The length is the number % of pixels by which the image is blurred. %handle:It is the handle to the waitbar(progress bar). %resim: It is the restored image. % %Example: % resim = Inverse(image, LEN, THETA); % This call takes image, blur length & blur angle as input % and returns the restored image.

%No of steps in the algorithm steps = 6;

%Converting to frequency domain fbl = fft2(ifbl); waitbar(1/steps, handle);

%Create PSF of degradation PSF = fspecial('motion',LEN,THETA); waitbar(2/steps, handle);

%Convert psf to otf of desired size %OTF is Optical Transfer Function OTF = psf2otf(PSF, size(fbl)); waitbar(3/steps, handle);

%To avoid divide by zero error for i = 1:size(OTF, 1) for j = 1:size(OTF, 2) if OTF(i, j) == 0 OTF(i, j) = 0.000001; end end end waitbar(4/steps, handle);

%Restoring the image using Inverse Filter fdebl = fbl./OTF; waitbar(5/steps, handle);

%Converting back to spatial domain using IFFT resim = ifft2(fdebl); waitbar(6/steps, handle);

Fangjun Jiang
on 25 Apr 2018

If a function requires two input arguments but you provided only one, you'll get this error. Try:

strcmp('a','b')

strcmp('a')

The message will tell you which line of code caused the error. So follow the code and check the number of input arguments.

Ahmet Cecen
on 25 Apr 2018

You named your variable handle, and probably didn't define it. handle is already defined in MATLAB so it thinks that your trying to call the function "handle" instead of referring to the specific handle you want.

Firstly, if you wanted to use your code as is, you would call it like this (note the "h" variable instead of "handle"):

h = waitbar(0,'Example')

resim = Inverse_Filtering(rand(11), 3, 30, h)

But, this makes no sense to me. Just get rid of the handle all together by modifying your code here (I am keeping the name "handle" but I advise you to change it, and do so everywhere in the function):

function resim = Inverse_Filtering(ifbl, LEN, THETA)

%... Same Code Here

%Converting to frequency domain

fbl = fft2(ifbl);

handle = waitbar(1/steps,'Example');

%... Same Code Here

end

Now you can just call:

resim = Inverse_Filtering(rand(11), 3, 30)

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/397299-how-can-i-solve-not-enough-input-arguments-error#comment_560800

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/397299-how-can-i-solve-not-enough-input-arguments-error#comment_560800

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/397299-how-can-i-solve-not-enough-input-arguments-error#comment_560823

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/397299-how-can-i-solve-not-enough-input-arguments-error#comment_560823

Sign in to comment.