In addition to wiener filtering, inverse filtering and constrained least squares filtering, maximum likelihood method can be used to restore fuzzy images. Step flow: 1. Read in image 2. Convert from 8-bit type to double precision, so that the following operation 3. Create discrete point diffusion function h 4. The original image F is convolved with point diffusion function H to obtain defocused blurred image 5. According to the formula of 2D maximum likelihood method, the image restoration operation is demonstrated through convolution in the airspace. The picture box on the left is the original picture and, and the subsequent added noise picture and image degradation picture are also here. The picture box on the right is the image restoration picture and select the image button:

global img1; [filename, pathname] = uigetfile({'*.jpg'; '*.bmp'; '*.gif'},'choose image pathway'); str = [pathname filename]; if (filename~=0) img1=imread(str); axes(handles.axes1) imshow(img1) else %empty file clear; endCopy the code

Add noise + image degradation

%% Add noise global img1; global noise_img; Noise_img = imnoise(img1, 'gaussian', 0, 0.01); Axes (handles. Axes1) imshow(noise_img) global noise_img; PSF = fspecial('motion', 10, 60); img3= imfilter( noise_img, PSF, 'circular' ); axes(handles.axes1) imshow(img3)Copy the code

Image restoration

global img3; f=im2double(img3); % is changed from 8-bit to double for later operation R=5; h=fspecial('disk',R); H % h=fspecial('gaussian',5,1); H g= IMfilter (f, h, 'conv', 'replicate'); % The original image f is convolved with point spread function h to obtain defocused blurred image G. According to 2D maximum likelihood method formula, image restoration is done by convolution in spatial domain: Fi =g; for i=1:200 a=imfilter (fi, h, 'conv', 'replicate' ); The convolution of the denominator in %. b=g./a; % a,g should be the same size in order to do dot division. c=imfilter (b, h, 'conv', 'replicate' ); % correlation in the formula. fi=fi.*c; % maximum likelihood formula. F and c should be of the same magnitude. end axes(handles.axes3) imshow(fi);Copy the code