Monday, August 2, 2010

Application of Rough Set Theory in Coal Gangue Image Processing

% Application of Rough Set Theory in Coal Gangue Image Processing
% This program will remove the salt & pepper noise from the coal image without much image degradation.
% IEEE 2009
clear all; close all; clc;
f = imread('20090506-anthracite-coal');
%f=rgb2gray(f);
f=im2double(f);
[m,n o]=size(f);
figure,imshow(f),title('Input Image');
if o == 1
f1=imnoise(f,'salt & pepper',0.5);
figure,imshow(f1),title('Noise Image');
Q=0.1;
t(1:9)=0;
S1(1:m,1:n)=0;
S2(1:m,1:n)=0;
for i=2:m-1
for j=2:n-1
co=0;
for k=i-1:i+1
for p=j-1:j+1
co=co+1;
t(co)=f1(k,p);
end
end
fi=t(5);
me=median(t);
C1=[t(2),t(3),t(5),t(6)];
C2=[t(1),t(2),t(4),t(5)];
C3=[t(4),t(5),t(7),t(8)];
C4=[t(5),t(6),t(8),t(9)];
tm(1)=mean(abs(fi-C1));
tm(2)=mean(abs(fi-C2));
tm(3)=mean(abs(fi-C3));
tm(4)=mean(abs(fi-C4));
tR=min(tm);
if tR>Q
S1(i,j)=me;
else
S1(i,j)=f1(i,j);
end
S2(i,j)=me;
end
end
figure,imshow(S1),title('rough set');
figure,imshow(S2),title('median');
elseif o == 3
Ns=0.05;
f1(:,:,1)=imnoise(f(:,:,1),'salt & pepper',Ns);
f1(:,:,2)=imnoise(f(:,:,2),'salt & pepper',Ns);
f1(:,:,3)=imnoise(f(:,:,3),'salt & pepper',Ns);
figure,imshow(f1),title('Noise Image');
Q=0.1;
t(1:9)=0;
S1(1:m,1:n,1:o)=0;
S2(1:m,1:n,1:o)=0;
for q=1:o
for i=2:m-1
for j=2:n-1
co=0;
for k=i-1:i+1
for p=j-1:j+1
co=co+1;
t(co)=f1(k,p,q);
end
end
fi=t(5);
me=median(t);
C1=[t(2),t(3),t(5),t(6)];
C2=[t(1),t(2),t(4),t(5)];
C3=[t(4),t(5),t(7),t(8)];
C4=[t(5),t(6),t(8),t(9)];
tm(1)=mean(abs(fi-C1));
tm(2)=mean(abs(fi-C2));
tm(3)=mean(abs(fi-C3));
tm(4)=mean(abs(fi-C4));
tR=min(tm);
if tR>Q
S1(i,j,q)=me;
else
S1(i,j,q)=f1(i,j,q);
end
S2(i,j,q)=me;
end
end
end
figure,imshow(S1),title('roughset Result');
figure,imshow(S2),title('median filter result');
end

1 comment:

Tejas Thakur(mumbai) said...

u did a gr8 job sir for me..thanks a lot