I have a reference image and output image which is having lot of noise.I created a mask for a portion in both images.I wanna design a filter which when applied to this region,can be applied to whole region.i am using least mean square method to reduce noise.But each time the mean square keeps increasing.Any idea how to sort out this problem.I am using MAT LAB to do this.Here is my code.
output=double(imread('obtained_output.jpg'));
reference=double(imread('reference_output.jpg'));
[M,N]=size(output);
upper_mask_obtained = output(1:100, 1:100);
lower_mask_obtained=output(201:300,1:100);
total_mask_obtained=[upper_mask_obtained;lower_mask_obtained];
upper_mask_reference = reference(1:100, 1:100);
lower_mask_reference=reference(201:300,1:100);
total_mask_reference=[upper_mask_reference;lower_mask_reference];
Ns=5;
[a,b]=size(total_mask_reference);
u=.000000001;
W=ones(Ns,Ns);
Y=zeros(Ns,Ns);
DD=zeros(Ns,Ns);
error=zeros(M,N);
e=zeros(Ns,Ns);
error_mask=abs(total_mask_obtained-total_mask_reference);
s= sum(sum(error_mask.^2));
mean_square_error=(s/(a*b));
while(mean_square_error>7)
for m=1+Ns:200
for n=1+Ns:100
for l=1:Ns
for k=1:Ns
Y(l,k)=total_mask_obtained(m-Ns+l-1,n-Ns+k-1);
DD(l,k)=total_mask_reference(m-Ns+l-1,n-Ns+k-1);
end
end
Z=conv2(Y,W,'same')/sum(sum(W));
e=DD(3,3)-Z(3,3);
W=(W+u*e*Y);
total_mask_obtained(m-Ns+2,n-Ns+2)=Z(3,3);
end
end
error=total_mask_reference-total_mask_obtained;
mean_square_error=sum(sum(error.^2))/(a*b);
end
figure(2);
final_output=(conv2(output,W,'same')/(sum(sum(W))));
imshow(uint8(final_output));
I think your task could be well-accomplished by using Gaussian filter. It is already built-in in Matlab. http://www.mathworks.com/help/images/ref/fspecial.html Check this for your reference. Sorry I'm new in StackOverflow. So I can't add comments yet. Sorry if it is not answer to your question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.