7

Im new to MatLab. Been playing around and reading through the help guide but i can't seem to solve this situation.

enter image description here

I have removed the noise by using gaussian algorithm. That was successful but I've not managed to get the image to be clear, i've tried using Richardson-Lucy deblurring algorithm but it doesn't work. Any idea how can i solve this? Thnx in advance.

Here's what i've done so far.

image size = 21kb image dimension = 264 x 126

img = imread('car_plate.jpg')
subplot(331);
imshow(img), title('Original Image')

PSF = fspecial('gaussian',15,15);
blur = imfilter(img,PSF,'replicate');
subplot(332);imshow(blur);title('Filter image');

motion_noise = fspecial('disk', 7);

luc1 = deconvlucy(img,motion_noise);
subplot(333); imshow(luc1);
title('Disk and Lucy');

LEN = 9; THETA = 1;
motion_noise2 = fspecial('motion', LEN, THETA);


luc2 = deconvlucy(blur,motion_noise2);
subplot(334); imshow(luc2);
title('Motion and Lucy');

When i tried using median filter, i got this output

Error using medfilt2
Expected input number 1, A, to be two-dimensional.

Error in medfilt2>parse_inputs (line 106)
validateattributes(a, {'numeric','logical'}, {'2d','real'}, mfilename, 'A', 1);

Error in medfilt2 (line 48)
[a, mn, padopt] = parse_inputs(varargin{:});

Error in a1q21 (line 2)
J = medfilt2(img);

and my current results are this.

enter image description here

Harvin
  • 179
  • 2
  • 12
  • the noise in the input image looks more like "salt-and-pepper" noise. Try using [median filter](http://www.mathworks.com/help/images/ref/medfilt2.html) to remove it. – Shai Aug 27 '13 at 08:55
  • @shai Thnx. Ive tried using median filter. Problem is, the image is not in 2-D and my lecturer told me that i don't have to convert the image in anyway. The only thing she told me was that im supposed to use Richardson-Lucy deblurring algorithm. – Harvin Aug 27 '13 at 09:02
  • what do you mean your "image is not 2-D"? you can median-filter each channel and re-combine them. Try comparing the results. – Shai Aug 27 '13 at 09:06
  • "but it does not work" - how? why? please show us the results you got, and try and be more specific as to why and what exactly "did not work". – Shai Aug 27 '13 at 09:06
  • @shai i updated the question. thnx – Harvin Aug 27 '13 at 09:15
  • What is your image size? using gauss filter with width 15 seems like a very strong blurring. Try median filter on each channel of the image, I believe you'll manage to do better denoising. – Shai Aug 27 '13 at 09:17
  • the image size is 21 kb, dimension is 264 x 126 RGB. Ok, ill read up on how to do that. Thnx @shai – Harvin Aug 27 '13 at 09:22
  • Yes, I would follow Shai's advice. Use *rgb2gray* to convert the TGB image to grayscale image and then use *medfilt2* to filter the image. – Lokesh A. R. Aug 27 '13 at 22:27

1 Answers1

5

You are using the wrong point spread functions for your debluring algorithm (pillbox is a bad choice). For best results filter with a median filter to remove the S&P noise and then deblur with a gaussian kernal. I would skip the motion deblur as the image doesn't seem to have strongly directional blur. You will need to play with the sigma of the sharpening filter to get the best results.

img = imread('car_plate.jpg')
subplot(331);
imshow(img), title('Original Image')

blur = medfilt2(img,[3 3]);
subplot(332);imshow(blur);title('Filter image');

deblurSigma = 10; %Adjust this to get the most visually pleasing results
motion_noise = fspecial('gaussian', 15,deblurSigma);
luc1 = deconvlucy(img,motion_noise);
subplot(333); imshow(luc1);
title('Disk and Lucy');
PeterM
  • 2,372
  • 1
  • 26
  • 35