is their a problem with the blurring filter in the given code?? the image as a result is divided into 4 blocks which are out of order....... how can i blur it properly?
2 次查看(过去 30 天)
显示 更早的评论
i m trying to blur an image and then deblur it using a wiener filter that i created. but the blurred image shows unexpected results. it appears the image is getting divided into blocks which are then arranged out o order. what's the issue.?
i am trying to create a wiener filer to blur the image. i use a low pass LSI filter and then add gaussian noise to the blurred image. i assume the expected noise to be white and hence has a flat spectral density.
but before i can create by wiener filter to deblur it, the blurring filter(h) gives unexpected results. i am highlighting in bold letters the portion i assume is creating the problem. will the code not workfor those images for which number of rows is not eual to number of columns? in any case, its not working i guess when rows = columns either......please help me in correcting the error. in my code:
h=low pass filter
Snn=noise power
Suu = signal power
Code:
% function wien2(name,xdim,No,Snn)
%
% name = 'input image' (as in 'lenna.256')
% xdim = x dimension of input image (usually 256 or 512)
% No = Variance of Noise
% Snn = Power Spectral Density of Noise (Assumed White)
%
% This function takes an input image, runs it through a LSI filter h,
% and adds Gaussian noise to it. The MSE between the degraded and
% original image is then calculated. Weiner Filtering is then performed
% (using known h) and the degraded image is restored using
% the filter. The MSE between the restored and original image is then
% calculated and returned. Snn is set to a constant (assumes white noise)
%
No = 80;
% Load and Plot image
pict = imread('C:\Documents and Settings\All Users\Documents\My Pictures\Matlab pics\planet.png');
pict=rgb2gray(pict)
;
[xdim xdim]=size(pict)
;
clf
subplot(221)
imagesc(pict);
colormap(gray);
txt = ' before degradation';
title(txt)
axis square
axis off
*% Create LSI degradation model, need it to be phaseless
hi = 3.5^(-2);
h = zeros(256);
xl = 4;
xh = xdim - xl + 2;
h(1:xl,1:xl) = hi;
h(xh:xdim,1:xl) = hi;
h(1:xl,xh:xdim) = hi;
h(xh:xdim,xh:xdim) = hi;
% Create Gaussian noise, mean = 0, variance comes from input (No)
noise = sqrt(No)*randn(xdim,xdim);
% Run image through LSI Filter and then add noise
dpict = imfilter(pict,h);
dpict =double(dpict)+noise;
% Plot degraded image
subplot(222)
imagesc(dpict);
colormap(gray);
txt = [' with additive Gaussian Noise (mean=0, var=' , num2str(No), ')'];
title(txt)
axis square
axis off
1 个评论
Sebastian Holmqvist
2012-7-18
This is exhausting to read. Please reformulate your question and format your code with the Code button.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!