i have written code for color filtering method for cfa images based on gradient.

1 view (last 30 days)
This is the code written for color filtering method for CFA images based on Gradient. According to this project during image acquisition through single sensor digital camera, there may be some noise created during demosaicking process and also artifacts.which iam trying to remove it by gradient. After running the program, iam getting the simulation result as that there is no noise in the image according to the code.*so suggest me if any correction in the code ie, after the comment regarding TH enumeration variable *
for i=2:1:m-1
for j=2:1:n-1
A1=abs(r(i-1,j-1)-r(i+1,j+1)); % horizontal internal gradient
B1=abs(r(i-1,j+1)-r(i+1,j-1)); % vertical internal gradient
end
end
for i=3:1:m-2
for j=3:1:n-2
A2=abs(2*g(i,j)-g(i-1,j-2)-g(i+1,j+2)); % horizontal external gradient
B2=abs(2*g(i,j)-g(i-2,j-1)-g(i+2,j+1)); % vertical external gradient
end
end
% to find existence of edge or influence of the noise TH (enumeration variable) is used for noise that in the up and down or in any point of g(i,j)
for k=2:2:m-1
for l=3:2:n-1
x=[k-1,k+1];
y=[l-1,l+1];
up=(A1<B1) & (eq(A2,B2)) & eq(max(abs(2*r(k,y)-r(k-1,l)-r(k+1,l))),l-1); %up says that g(i,j-1) is the noise
down=(A1<B1) & (eq(A2,B2)) & eq(max(abs(2*r(k,y)-r(k-1,l)-r(k+1,l))),l+1); %down says that g(i,j+1) is the noise
left=(A1>B1) & (eq(A2,B2)) & eq(max(abs(2*r(x,l)-r(k,l-1)-r(k,l+1))),k-1); %left says that g(i-1,j) is the noise
right=(A1>B1) & (eq(A2,B2)) & eq(max(abs(2*r(x,l)-r(k,l-1)-r(k,l+1))),k+1);
%right says that g(i+1,j) is the noise
no=(eq(A1,B1)) & (eq(A2,B2));
%no says that there is no noise and also no edge
level=(A1>B1) & (A2>B2);
% level says that there is a edge in vertical direction
erect=(A1>B1) & (A2<B2);
% erect says that there is a edge in horizontal direction
end
end
p=[1 2 3 4 5 6 7]
TH=[up down left right no level erect]
is it right way to find the existence of noise and edges in a color image ie, horizantal and vertical gradient in horizantal and vertical direction
  5 Comments

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!