Fix Matlab Filter Error: Pseudo Inverse Filter for Image Restoration

In summary, it is important to define and initialize all necessary variables, check the compatibility of image sizes, and break down your code for easier troubleshooting. As for which filter to use, it depends on your project and its specific requirements.
  • #1
jerin_007
7
0

Homework Statement


I am doing a project on mathematical analysis of image restoration techniques, using linear restoration filters such as
1.inverse filter
2.pseudo inverse filter
3.weiner filter and
4.constrained least square filter


Homework Equations





The Attempt at a Solution


For the pseudo inverse filter, I've programmed as following:

clc;
clear all;
close all;
f=imread('C:\Documents and Settings\Jerin\Desktop\lenna.gif');
PSF=fspecial('motion', 14,0);
gb=imfilter(f,PSF);
g=imnoise (gb,'gaussian',0,200/(255*255));
fr=deconvwnr (g,PSF);
k=fft(fr);
for i=1:1:150;
H=pfilter('ideal',size(fr,1),size(fr,2),i);
G=H.*k;
g1=real(ifft2(G));
g1=g1(1:size(fr,1),1:size(fr,2));
e=double (f)-double(g1);
[m,n]=size(e);
rmse(i)=sqrt(sum(e(:).^2)/(m*n));
end;
i=1:1:150;
figure(2);
plot(i,rmse(i));

Now i am getting an error like this:
2rwnuwn.jpg


The output should be like this:
23hao9f.jpg


If posssible, guys please copy the program and work it out in MATLAB for the correct output, i know you can sort it out very easily. Please its urgent.

What filter i should use? is the pfilter correct? I got this programmed from a friend.
 
Physics news on Phys.org
  • #2


Hi there,

It seems like you are trying to implement the pseudo inverse filter in MATLAB for image restoration. From the code you have provided, it looks like you are on the right track. However, there are a few things that could be causing the error you are getting.

Firstly, make sure that all necessary variables are defined and initialized before running the code. For example, the variables "f" (input image), "PSF" (point spread function), and "g" (noisy blurred image) should all be defined and initialized before using them in the code.

Secondly, it is important to check the size of the images and filters being used. Make sure that the size of the PSF and the input image are compatible with the size of the filter being used (in this case, the "pfilter" function). If they are not compatible, you may get an error like the one you are getting.

Lastly, it is always a good idea to break down your code into smaller parts and test each part separately to identify where the error is coming from. This will help you in troubleshooting and finding the correct solution.

As for your question about which filter to use, it ultimately depends on your specific project and the type of image restoration you are trying to achieve. Each filter has its own advantages and limitations, so it is important to understand them and choose the one that best suits your needs.

I hope this helps and good luck with your project!
 

Related to Fix Matlab Filter Error: Pseudo Inverse Filter for Image Restoration

1. What is a pseudo inverse filter in Matlab?

A pseudo inverse filter in Matlab is a mathematical technique used for image restoration. It involves finding the inverse of a matrix using a method called the Moore-Penrose pseudo inverse, which is used to solve a system of linear equations. In image restoration, this filter is used to remove noise and improve the quality of an image.

2. How does the pseudo inverse filter work in Matlab?

The pseudo inverse filter works by taking the noisy image as the input and multiplying it with the pseudo inverse of the system matrix. This process helps to reduce the effect of noise and restore the original image. The resulting image is a filtered version of the noisy image with improved quality.

3. What are the advantages of using a pseudo inverse filter in Matlab?

One advantage of using a pseudo inverse filter in Matlab is that it is a straightforward and efficient method for image restoration. It also allows for the restoration of images with a wide range of noise levels. Additionally, it can be easily implemented in Matlab using built-in functions.

4. Are there any limitations to using the pseudo inverse filter in Matlab?

One limitation of using the pseudo inverse filter in Matlab is that it may not always be able to accurately restore images with extremely high levels of noise. Additionally, it may also introduce artifacts or distortions in the restored image if not used correctly.

5. Can the pseudo inverse filter be used for other purposes besides image restoration?

Yes, the pseudo inverse filter can also be used for other purposes, such as signal processing, data compression, and pattern recognition. It is a versatile tool that can be applied in various fields of science and engineering.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top