Chromaticity control center
All closed
Clean up all
%%% Generate Gaussian smoothing filter template%%%
%%%%%%%%%%%%%%%%%%%%%%%%%
Hg = zero (3,3); % Set the size of Gaussian smoothing filter template to 3*3.
δ= 0.5;
Because x= 1: 1:3.
Because y= 1: 1:3.
u = x-2;
v = y-2;
hg(x,y)=exp(-(u^2+v^2)/(2*pi*delta^2));
end
end
h = Hg/sum(Hg(:));
%%%%%%%%%%%%%
%%%%%%%%% Read-in image%%%%%%%%
%%%%%%%%%%%%%
f = imread(' 1 1 1 1 . TIF '); % Read in image file
f = RGB 2 gray(im 2 double(f));
imshow(f)
Title ("original");
[m, n]= size (f);
ftemp=zeros(m,n);
row high = m- 1;
col high = n- 1;
%%% Gaussian filtering%%%
For x=2: 1:rowhigh- 1
For y=2: 1:colhigh- 1
mod=[f(x- 1,y- 1) f(x- 1,y) f(x- 1,y+ 1); f(x,y- 1) f(x,y) f(x,y+ 1); f(x+ 1,y- 1) f(x+ 1,y) f(x+ 1,y+ 1)];
A = h. * mod
ftemp(x,y)= sum(A(:);
end
end
f=ftemp
Figure, imshow(f)
Title ('Gaussian filtered image');
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Use roberts operator for edge detection%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sx =[- 1-2- 1; 0 0 0; 1 2 1];
sy =[- 1 0 1; -2 0 2; - 1 0 1];
For x=2: 1:rowhigh- 1
For y=2: 1:colhigh- 1
mod=[f(x- 1,y- 1) f(x- 1,y) f(x- 1,y+ 1); f(x,y- 1) f(x,y) f(x,y+ 1); f(x+ 1,y- 1) f(x+ 1,y) f(x+ 1,y+ 1)];
fsx=sx。 * mod
fsy=sy。 * mod
ftemp(x,y)=sqrt((sum(fsx(:)))^2+(sum(fsy(:)))^2);
end
end
fr = im 2 uint 8(ft EMP);
Figure, imshow (France)
Title ("original image detected by roberts operator edge");
%%% Domain value division%%%
th 1 = 60; % Set threshold
For x=2: 1:rowhigh- 1
For y=2: 1:colhigh- 1
if (fr(x,y)>= th 1)& amp; ((fr(x,y- 1)& lt; = fr(x,y))& amp; (fr(x,y)>fr(x,y+ 1)))
fr(x,y)= 200;
elseif(fr(x,y)>= th 1)& amp; ((fr(x- 1,y)& lt; =fr(x,y))& amp; (fr(x,y)>fr(x+ 1,y)))
fr(x,y)= 200;
else fr(x,y)= 50;
end
end
end
Figure, imshow (France)
Title ("Image after Edge Detection and Thinning by roberts Operator");